Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into 1430-custom-generator-interface
Browse files Browse the repository at this point in the history
# 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
willsalt-sl committed Nov 11, 2019
2 parents b9153fe + b22e440 commit 3d96dec
Show file tree
Hide file tree
Showing 419 changed files with 8,958 additions and 7,380 deletions.
22 changes: 20 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -81,6 +94,11 @@ workflows:
filters:
branches:
ignore: master
- check_license_messages:
filters:
branches:
ignore: master

release:
jobs:
- release:
Expand Down
26 changes: 7 additions & 19 deletions .github/ISSUE_TEMPLATE/Feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,16 @@ about: I have a suggestion (and may want to implement it 🙂)!

## Feature Request

### Description of Problem - *As a DataHelix user, I want..., so that...*
#### Description of Problem

### Potential Solutions
#### Acceptance Criteria
- Will any cucumber tests be required?
- Will this require a documentation change?

## Before bringing the story into 'Ready' please consider the following:
#### Tasks

### Acceptance Criteria - *Given, When, Then*
#### Estimate - *Fibonacci number sequence 1,2,3,5,8,13 etc*

### Estimate - *Fibonacci number sequence 1,2,3,5,8,13 etc*

### Tasks

### Dependencies

### Testing - *Can any tests be written up front?*

### Risks - *Likelihood of a bug and impact*

### Documentation - *Does it need updating?*

### Demo - *Should we demo this change? To who?*

## Is this feature done?
#### (Optional) Potential approaches to solution

Please run through the [Definition of Done checklist](https://github.com/finos/datahelix/blob/master/docs/developer/DefinitionOfDone.md)
File renamed without changes.
2 changes: 2 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ dependencies {
compile "com.fasterxml.jackson.core:jackson-core:${JACKSON_VERSION}"
compile "com.fasterxml.jackson.core:jackson-annotations:${JACKSON_VERSION}"
compile "com.fasterxml.jackson.core:jackson-databind:${JACKSON_VERSION}"
compile group: "com.google.inject", name: "guice", version: "${GUICE_VERSION}"

implementation "org.threeten:threeten-extra:${THREE_TEN_VERSION}"
testCompile "org.junit.jupiter:junit-jupiter-api:${JUNIT_JUPITER_VERSION}"
testCompile "junit:junit:${JUNIT_4_VERSION}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ValidationException(String msg) {
}

public ValidationException(List<String> errorMessages){
super();
super(String.join("\n", errorMessages));
this.errorMessages = errorMessages;
}
}
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();
}
}
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);
}
}
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);
}

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);
}
}

This file was deleted.

Loading

0 comments on commit 3d96dec

Please sign in to comment.