Skip to content

Commit

Permalink
gh-1804 - text fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
m55624 committed Oct 17, 2018
1 parent 0280d17 commit 888ac11
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@
import uk.gov.gchq.koryphe.ValidationResult;
import uk.gov.gchq.koryphe.impl.predicate.IsMoreThan;

import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.function.BinaryOperator;
import java.util.function.Predicate;

Expand All @@ -51,7 +49,7 @@ public void shouldValidateComponentTypesAndReturnTrueWhenNoIdentifiersOrProperti
final SchemaElementDefinitionValidator validator = new SchemaElementDefinitionValidator();

given(elementDef.getIdentifiers()).willReturn(new HashSet<>());
given(elementDef.getOrderedProperties()).willReturn(new HashSet<>());
given(elementDef.getOrderedProperties()).willReturn(new LinkedHashSet<>());

// When
final ValidationResult result = validator.validateComponentTypes(elementDef);
Expand All @@ -66,7 +64,7 @@ public void shouldValidateComponentTypesAndErrorWhenPropertyNameIsAReservedWord(
// Given
final SchemaElementDefinition elementDef = mock(SchemaElementDefinition.class);
final SchemaElementDefinitionValidator validator = new SchemaElementDefinitionValidator();
final Set<String> properties = new HashSet<>();
final LinkedHashSet<String> properties = new LinkedHashSet<>();
properties.add(TestPropertyNames.COUNT);
properties.add(identifierType.name());

Expand All @@ -89,7 +87,7 @@ public void shouldValidateComponentTypesAndReturnTrueWhenIdentifiersAndPropertie
final SchemaElementDefinitionValidator validator = new SchemaElementDefinitionValidator();

given(elementDef.getIdentifiers()).willReturn(Sets.newSet(IdentifierType.DESTINATION, IdentifierType.SOURCE));
given(elementDef.getOrderedProperties()).willReturn(Sets.newSet(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2));
given(elementDef.getOrderedProperties()).willReturn(new LinkedHashSet<>(Sets.newSet(TestPropertyNames.PROP_1, TestPropertyNames.PROP_2)));

given(elementDef.getIdentifierClass(IdentifierType.DESTINATION)).willReturn((Class) Double.class);
given(elementDef.getIdentifierClass(IdentifierType.SOURCE)).willReturn((Class) Long.class);
Expand All @@ -110,7 +108,7 @@ public void shouldValidateComponentTypesAndReturnFalseForInvalidPropertyClass()
final SchemaElementDefinitionValidator validator = new SchemaElementDefinitionValidator();

given(elementDef.getIdentifiers()).willReturn(new HashSet<>());
given(elementDef.getOrderedProperties()).willReturn(Sets.newSet(TestPropertyNames.PROP_1));
given(elementDef.getOrderedProperties()).willReturn(new LinkedHashSet<>(Sets.newSet(TestPropertyNames.PROP_1)));
given(elementDef.getPropertyClass(TestPropertyNames.PROP_1)).willThrow(new IllegalArgumentException());

// When
Expand Down Expand Up @@ -219,7 +217,7 @@ public void shouldValidateAndReturnTrueWhenAggregationIsDisabled() {
// Given
final SchemaElementDefinition elementDef = mock(SchemaElementDefinition.class);
final SchemaElementDefinitionValidator validator = new SchemaElementDefinitionValidator();
final Map<String, String> properties = new HashMap<>();
final LinkedHashMap<String, String> properties = new LinkedHashMap<>();
properties.put(TestPropertyNames.PROP_1, "int");
properties.put(TestPropertyNames.PROP_2, "string");
final BinaryOperator<Integer> function1 = mock(BinaryOperator.class);
Expand All @@ -229,7 +227,7 @@ public void shouldValidateAndReturnTrueWhenAggregationIsDisabled() {
.build();

given(elementDef.getIdentifiers()).willReturn(new HashSet<>());
given(elementDef.getOrderedProperties()).willReturn(properties.keySet());
given(elementDef.getOrderedProperties()).willReturn(new LinkedHashSet<>(properties.keySet()));
given(elementDef.getOrderedPropertyMap()).willReturn(properties);
given(elementDef.getValidator()).willReturn(mock(ElementFilter.class));
given(elementDef.getFullAggregator()).willReturn(aggregator);
Expand Down Expand Up @@ -278,7 +276,7 @@ public void shouldValidateAndReturnFalseWhenAggregatorIsInvalid() {
// Given
final SchemaElementDefinition elementDef = mock(SchemaElementDefinition.class);
final SchemaElementDefinitionValidator validator = new SchemaElementDefinitionValidator();
final Map<String, String> properties = new HashMap<>();
final LinkedHashMap<String, String> properties = new LinkedHashMap<>();
properties.put(TestPropertyNames.PROP_1, "int");
properties.put(TestPropertyNames.PROP_2, "string");
final BinaryOperator<Integer> function1 = mock(BinaryOperator.class);
Expand All @@ -288,7 +286,7 @@ public void shouldValidateAndReturnFalseWhenAggregatorIsInvalid() {
.build();

given(elementDef.getIdentifiers()).willReturn(new HashSet<>());
given(elementDef.getOrderedProperties()).willReturn(properties.keySet());
given(elementDef.getOrderedProperties()).willReturn(new LinkedHashSet<>(properties.keySet()));
given(elementDef.getOrderedPropertyMap()).willReturn(properties);
given(elementDef.getValidator()).willReturn(mock(ElementFilter.class));
given(elementDef.getFullAggregator()).willReturn(aggregator);
Expand All @@ -309,16 +307,16 @@ public void shouldValidateAndReturnFalseWhenAggregatorIsInvalid() {
@Test
public void shouldValidateAndReturnFalseWhenNoAggregatorByGroupBysSet() {
// Given
Set<String> groupBys = new HashSet<>();
LinkedHashSet<String> groupBys = new LinkedHashSet<>();
groupBys.add("int");
final SchemaElementDefinition elementDef = mock(SchemaElementDefinition.class);
final SchemaElementDefinitionValidator validator = new SchemaElementDefinitionValidator();
final Map<String, String> properties = new HashMap<>();
final LinkedHashMap<String, String> properties = new LinkedHashMap<>();
properties.put(TestPropertyNames.PROP_1, "int");
properties.put(TestPropertyNames.PROP_2, "string");

given(elementDef.getOrderedGroupBy()).willReturn(groupBys);
given(elementDef.getOrderedProperties()).willReturn(properties.keySet());
given(elementDef.getOrderedProperties()).willReturn(new LinkedHashSet<>(properties.keySet()));
given(elementDef.getOrderedPropertyMap()).willReturn(properties);
given(elementDef.getValidator()).willReturn(mock(ElementFilter.class));
given(elementDef.getPropertyClass(TestPropertyNames.PROP_1)).willReturn((Class) Integer.class);
Expand All @@ -342,7 +340,7 @@ public void shouldValidateAndReturnTrueWhenNoPropertiesSoAggregatorIsValid() {
final SchemaElementDefinitionValidator validator = new SchemaElementDefinitionValidator();

given(elementDef.getIdentifiers()).willReturn(new HashSet<>());
given(elementDef.getOrderedPropertyMap()).willReturn(Collections.emptyMap());
given(elementDef.getOrderedPropertyMap()).willReturn(new LinkedHashMap<>());
given(elementDef.getValidator()).willReturn(mock(ElementFilter.class));
given(elementDef.getFullAggregator()).willReturn(null);
given(elementDef.isAggregate()).willReturn(true);
Expand Down

0 comments on commit 888ac11

Please sign in to comment.