This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 1430-custom-generator-interface
# Conflicts: # orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/testframework/utils/CucumberProfileReader.java # profile/src/main/java/com/scottlogic/deg/profile/reader/JsonProfileReader.java # profile/src/test/java/com/scottlogic/deg/profile/ProfileSchemaImmutabilityTests.java # profile/src/test/java/com/scottlogic/deg/profile/reader/JsonProfileReaderTests.java
- Loading branch information
Showing
419 changed files
with
8,958 additions
and
7,380 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,19 @@ orbs: | |
codecov: codecov/[email protected] | ||
jobs: | ||
|
||
check_license_messages: | ||
docker: | ||
- image: circleci/openjdk:8-jdk-browsers | ||
working_directory: ~/datahelix/ | ||
steps: | ||
- checkout | ||
- run: | ||
name: Set header script priviledges | ||
command: chmod +x license-check.sh | ||
- run: | ||
name: Check commit messages | ||
command: ./license-check.sh | ||
|
||
check_commit_message: | ||
docker: | ||
- image: circleci/openjdk:8-jdk-browsers | ||
|
@@ -11,10 +24,10 @@ jobs: | |
- checkout | ||
- run: | ||
name: Set commit script priviledges | ||
command: chmod +x commit_check.sh | ||
command: chmod +x commit-check.sh | ||
- run: | ||
name: Check commit messages | ||
command: ./commit_check.sh | ||
command: ./commit-check.sh | ||
|
||
build: | ||
docker: | ||
|
@@ -81,6 +94,11 @@ workflows: | |
filters: | ||
branches: | ||
ignore: master | ||
- check_license_messages: | ||
filters: | ||
branches: | ||
ignore: master | ||
|
||
release: | ||
jobs: | ||
- release: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
common/src/main/java/com/scottlogic/deg/common/commands/Command.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2019 Scott Logic Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.scottlogic.deg.common.commands; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
public abstract class Command<TResponse> | ||
{ | ||
public Type commandType; | ||
|
||
protected Command() | ||
{ | ||
commandType = getClass(); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
common/src/main/java/com/scottlogic/deg/common/commands/CommandBus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright 2019 Scott Logic Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.scottlogic.deg.common.commands; | ||
|
||
import org.apache.commons.lang3.tuple.ImmutablePair; | ||
import org.apache.commons.lang3.tuple.Pair; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public abstract class CommandBus | ||
{ | ||
private final Map<Class<?>, Pair<Class<? extends CommandHandler>, ? extends CommandHandler>> map = new HashMap<>(); | ||
|
||
protected <TCommand extends Command<TResponse>, TResponse> void register(Class<TCommand> commandClass, CommandHandler handler) | ||
{ | ||
map.put(commandClass, new ImmutablePair<>(handler.getClass(), handler)); | ||
} | ||
|
||
public <TCommand extends Command<TResponse>, TResponse> CommandResult<TResponse> send(TCommand command) | ||
{ | ||
Class<? extends Command> commandClass = command.getClass(); | ||
Class<? extends CommandHandler> commandHandlerClass = map.get(commandClass).getKey(); | ||
CommandHandler commandHandler = map.get(commandClass).getValue(); | ||
|
||
return commandHandlerClass.cast(commandHandler).handle(command); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
common/src/main/java/com/scottlogic/deg/common/commands/CommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2019 Scott Logic Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.scottlogic.deg.common.commands; | ||
|
||
import com.scottlogic.deg.common.validators.ValidationResult; | ||
import com.scottlogic.deg.common.validators.Validator; | ||
|
||
public abstract class CommandHandler<TCommand extends Command<TResponse>, TResponse> | ||
{ | ||
private final Validator<TCommand> validator; | ||
|
||
protected CommandHandler(Validator<TCommand> validator) | ||
{ | ||
this.validator = validator; | ||
} | ||
|
||
public CommandResult<TResponse> handle(TCommand command) | ||
{ | ||
ValidationResult validationResult = validator.validate(command); | ||
if (validationResult.isSuccess) return handleCommand(command); | ||
return CommandResult.failure(validationResult.errors); | ||
} | ||
|
||
public abstract CommandResult<TResponse> handleCommand(TCommand command); | ||
} | ||
|
68 changes: 68 additions & 0 deletions
68
common/src/main/java/com/scottlogic/deg/common/commands/CommandResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Copyright 2019 Scott Logic Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.scottlogic.deg.common.commands; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.List; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
public class CommandResult<T> | ||
{ | ||
public final T value; | ||
public final boolean isSuccess; | ||
public final List<String> errors; | ||
|
||
private CommandResult(T value, boolean isSuccess, List<String> errors) | ||
{ | ||
this.value = value; | ||
this.isSuccess = isSuccess; | ||
this.errors = errors; | ||
} | ||
|
||
public static <T> CommandResult<T> success(T value) | ||
{ | ||
return new CommandResult<>(value, true, new ArrayList<>()); | ||
} | ||
|
||
@SafeVarargs | ||
public static <T> CommandResult<T> failure(List<String>... errors) | ||
{ | ||
return new CommandResult<>(null, false, Arrays.stream(errors).flatMap(Collection::stream).collect(Collectors.toList())); | ||
} | ||
|
||
public <TResult> CommandResult<TResult> map(Function<T, TResult> mapping) | ||
{ | ||
return isSuccess ? success(mapping.apply(value)) : failure(errors); | ||
} | ||
|
||
|
||
public static <T> CommandResult<List<T>> combine(List<CommandResult<T>> results) | ||
{ | ||
List<T> values = new ArrayList<>(); | ||
List<String> errors = new ArrayList<>(); | ||
results.forEach(result -> | ||
{ | ||
if(result.isSuccess) values.add(result.value); | ||
else errors.addAll(result.errors); | ||
}); | ||
|
||
return values.size() == results.size() ? CommandResult.success(values) : CommandResult.failure(errors); | ||
} | ||
} |
67 changes: 0 additions & 67 deletions
67
common/src/main/java/com/scottlogic/deg/common/profile/AtomicConstraintType.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.