diff --git a/common/src/main/java/com/scottlogic/deg/common/profile/constraintdetail/AtomicConstraintType.java b/common/src/main/java/com/scottlogic/deg/common/profile/constraintdetail/AtomicConstraintType.java index a5aeb10de..edbf47426 100644 --- a/common/src/main/java/com/scottlogic/deg/common/profile/constraintdetail/AtomicConstraintType.java +++ b/common/src/main/java/com/scottlogic/deg/common/profile/constraintdetail/AtomicConstraintType.java @@ -24,12 +24,8 @@ public enum AtomicConstraintType { IS_IN_SET("inSet"), IS_IN_MAP("inMap"), IS_NULL("null"), - IS_UNIQUE("unique"), - IS_OF_TYPE("ofType"), - MATCHES_REGEX("matchingRegex"), CONTAINS_REGEX("containingRegex"), - FORMATTED_AS("formattedAs"), // String HAS_LENGTH("ofLength"), diff --git a/orchestrator/src/main/java/com/scottlogic/deg/orchestrator/violate/ViolationFiltersProvider.java b/orchestrator/src/main/java/com/scottlogic/deg/orchestrator/violate/ViolationFiltersProvider.java index 5d468ec93..4ee792fba 100644 --- a/orchestrator/src/main/java/com/scottlogic/deg/orchestrator/violate/ViolationFiltersProvider.java +++ b/orchestrator/src/main/java/com/scottlogic/deg/orchestrator/violate/ViolationFiltersProvider.java @@ -18,8 +18,6 @@ import com.google.inject.Inject; import com.google.inject.Provider; -import com.scottlogic.deg.common.profile.constraintdetail.AtomicConstraintType; -import com.scottlogic.deg.generator.generation.GenerationConfigSource; import com.scottlogic.deg.generator.violations.filters.ConstraintTypeViolationFilter; import com.scottlogic.deg.generator.violations.filters.ViolationFilter; @@ -44,7 +42,6 @@ public List get() { } return commandLine.getConstraintsToNotViolate().stream() - .filter(atomicConstraint -> !atomicConstraint.equals(AtomicConstraintType.IS_OF_TYPE)) .map(mapper::toConstraintClass) .map(ConstraintTypeViolationFilter::new) .collect(Collectors.toList()); diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/Contradictions.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/Contradictions.feature deleted file mode 100644 index cafc247f4..000000000 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/Contradictions.feature +++ /dev/null @@ -1,14 +0,0 @@ -Feature: Hard contradictions produce nothing, soft contradictions produce only null. - - Background: - Given the generation strategy is RANDOM - And there is a field foo - -### Hard Contradictions ### - - Scenario: Contradicting inferred and actual types should not produce any data. - Given foo is anything but null - And foo has type "integer" - And foo is less than 1 - And foo is greater than 0 - Then no data is created diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/Violation.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/Violation.feature index c519870d2..b32218374 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/Violation.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/Violation.feature @@ -4,13 +4,11 @@ Feature: The violations mode of the Data Helix app can be run in violations mode Given there is a field foo And the data requested is violating And the generator can generate at most 5 rows - And we do not violate any of type constraints Scenario: Running the generator in violate mode for not equal to is successful (decimal) Given foo is anything but equal to 8 And foo has type "decimal" And foo is granular to 1 - And we do not violate any of type constraints And we do not violate any granular to constraints And the generation strategy is full Then the following data should be generated: @@ -22,7 +20,6 @@ Feature: The violations mode of the Data Helix app can be run in violations mode And foo has type "decimal" And the generation strategy is full And we do not violate any equal to constraints - And we do not violate any of type constraints Then the following data should be generated: | foo | | 8 | @@ -43,7 +40,6 @@ Feature: The violations mode of the Data Helix app can be run in violations mode And foo has type "decimal" And the generation strategy is random And the data requested is violating - And we do not violate any of type constraints Then 5 rows of data are generated And foo contains anything but null @@ -53,7 +49,6 @@ Feature: The violations mode of the Data Helix app can be run in violations mode And foo is anything but null And foo is before 2019-01-01T00:00:00.000Z And the data requested is violating - And we do not violate any of type constraints Then 5 rows of data are generated And foo contains only datetime data And foo contains datetimes after or at 2019-01-01T00:00:00.000Z @@ -64,7 +59,6 @@ Feature: The violations mode of the Data Helix app can be run in violations mode And the generation strategy is random And foo is less than 10 And the data requested is violating - And we do not violate any of type constraints Then 5 rows of data are generated And foo contains only numeric data And foo contains numeric values greater than or equal to 10 @@ -75,7 +69,6 @@ Feature: The violations mode of the Data Helix app can be run in violations mode And foo is anything but null And foo is shorter than 10 And the data requested is violating - And we do not violate any of type constraints Then 5 rows of data are generated And foo contains only string data And foo contains strings longer than or equal to 10 @@ -86,7 +79,6 @@ Feature: The violations mode of the Data Helix app can be run in violations mode And foo is anything but null And foo is matching regex /[a-z]{0,9}/ And the data requested is violating - And we do not violate any of type constraints Then 5 rows of data are generated And foo contains only string data And foo contains anything but strings matching /[a-z]{0,9}/ @@ -97,7 +89,6 @@ Feature: The violations mode of the Data Helix app can be run in violations mode And the generation strategy is random And foo is anything but matching regex /[a-z]{0,9}/ And the data requested is violating - And we do not violate any of type constraints Then 5 rows of data are generated And foo contains only string data And foo contains strings matching /[a-z]{0,9}/ diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature index ea76a2c60..346ed890b 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/operators/grammatical/If.feature @@ -1512,122 +1512,6 @@ Feature: Values can be specified by using if, then and else constraints | foo | bar | | "dddd" | "4444" | - Scenario: An if constraint that contains an ISIN constraint in the then clause generates valid ISINs when the if clause applies - Given foo is in set: - | "GB0002634946" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "GB0002634946" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And foo has type "string" - And bar has type "string" - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "bb" }, - "then": { "field": "bar", "is": "ofType", "value": "ISIN" }, - "else": { "field": "bar", "is": "equalTo", "value": "333" } - } - """ - Then the following data should be generated: - | foo | bar | - | "GB0002634946" | "333" | - | "bb" | "GB0002634946" | - | "ccc" | "333" | - | "dddd" | "333" | - - Scenario: An if constraint that contains an ISIN constraint in the else clause generates valid ISINs when the if clause does not apply - Given foo is in set: - | "GB0002634946" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "GB0002634946" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And foo has type "string" - And bar has type "string" - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "bb" }, - "then": { "field": "bar", "is": "equalTo", "value": "22" }, - "else": { "field": "bar", "is": "ofType", "value": "ISIN" } - } - """ - Then the following data should be generated: - | foo | bar | - | "GB0002634946" | "GB0002634946" | - | "bb" | "22" | - | "ccc" | "GB0002634946" | - | "dddd" | "GB0002634946" | - - Scenario: An if constraint that contains an ISIN constraint in the then clause combined with an in set constraint that does not contain any valid ISINs only generates data that matches the else clause - Given foo is in set: - | "aa" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "11" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And foo has type "string" - And bar has type "string" - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "ccc" }, - "then": { "field": "bar", "is": "ofType", "value": "ISIN" }, - "else": { "field": "bar", "is": "equalTo", "value": "333" } - } - """ - Then the following data should be generated: - | foo | bar | - | "aa" | "333" | - | "bb" | "333" | - | "dddd" | "333" | - - Scenario: An if constraint with an else clause containing an ISIN constraint which contradicts an in set constraint generates data that only matches the then clause - Given foo is in set: - | "aa" | - | "bb" | - | "ccc" | - | "dddd" | - And foo is anything but null - And bar is in set: - | "11" | - | "22" | - | "333" | - | "4444" | - And bar is anything but null - And foo has type "string" - And bar has type "string" - And there is a constraint: - """ - { - "if": { "field": "foo", "is": "equalTo", "value": "ccc" }, - "then": { "field": "bar", "is": "equalTo", "value": "333" }, - "else": { "field": "bar", "is": "ofType", "value": "ISIN" } - } - """ - Then the following data should be generated: - | foo | bar | - | "ccc" | "333" | - Scenario: Running an if request that contains a non contradictory greaterThan constraint within its if statement should be successful Given foo is in set: | 10 | diff --git a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/validation/TypeMandation.feature b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/validation/TypeMandation.feature index 962988ae3..469b3b4bf 100644 --- a/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/validation/TypeMandation.feature +++ b/orchestrator/src/test/java/com/scottlogic/deg/orchestrator/cucumber/features/validation/TypeMandation.feature @@ -53,14 +53,3 @@ Feature: Type mandation validation And there is a field purchase_time Then the profile is invalid because "Fields price, purchase_time are not typed; add their type to the field definition" - Scenario: An anyOf constraint whose branches don't all satisfy type mandation should not satisfy type mandation - Given there is a field user_id - And there is a constraint: - """ - { "anyOf": [ - { "field": "user_id", "is": "ofType", "value": "string" }, - { "not": { "field": "user_id", "is": "null" } } - ]} - """ - Then the profile is invalid because "Field \[user_id\]: is not typed; add its type to the field definition" - diff --git a/profile/src/main/java/com/scottlogic/deg/profile/reader/JsonProfileReader.java b/profile/src/main/java/com/scottlogic/deg/profile/reader/JsonProfileReader.java index 0f8774202..20f342e60 100644 --- a/profile/src/main/java/com/scottlogic/deg/profile/reader/JsonProfileReader.java +++ b/profile/src/main/java/com/scottlogic/deg/profile/reader/JsonProfileReader.java @@ -25,6 +25,8 @@ import com.scottlogic.deg.generator.profile.Rule; import com.scottlogic.deg.generator.profile.RuleInformation; import com.scottlogic.deg.profile.dto.ConstraintDTO; +import com.scottlogic.deg.profile.reader.atomic.ConstraintReaderHelpers; +import com.scottlogic.deg.profile.reader.atomic.OfTypeConstraintFactory; import com.scottlogic.deg.profile.serialisation.ProfileDeserialiser; import com.scottlogic.deg.profile.dto.ProfileDTO; @@ -71,9 +73,6 @@ public Profile read(String profileJson) throws IOException { throw new InvalidProfileException("Profile is invalid: 'rules' have not been defined."); } - //This is the types of the field that have not been set by the field def - Map fieldTypes = getTypesFromConstraints(profileDto); - List inMapFields = getInMapConstraints(profileDto).stream() .map(file -> new Field( @@ -86,14 +85,7 @@ public Profile read(String profileJson) throws IOException { List fields = profileDto.fields.stream() - .map(fDto -> - new Field( - fDto.name, - getFieldType(fieldTypes.getOrDefault(fDto.name, fDto.type)), - fDto.unique, - fDto.formatting, - false) - ) + .map(fDto -> new Field(fDto.name, ConstraintReaderHelpers.getFieldType(fDto.type), fDto.unique, fDto.formatting,false)) .collect(Collectors.toList()); fields.addAll(inMapFields); @@ -119,25 +111,17 @@ public Profile read(String profileJson) throws IOException { // add types Collection typeRules = profileDto.fields.stream() - .filter(fieldDTO -> fieldDTO.type != null ) - .map(fieldDTO -> create(AtomicConstraintType.IS_OF_TYPE, profileFields.getByName(fieldDTO.name), fieldDTO.type)) - .filter(constraint -> !(constraint instanceof RemoveFromTree)) - .collect(Collectors.toList()); + .filter(fieldDTO -> fieldDTO.type != null ) + .map(fieldDTO -> OfTypeConstraintFactory.create(profileFields.getByName(fieldDTO.name), fieldDTO.type)) + .filter(Optional::isPresent) + .map(Optional::get) + .collect(Collectors.toList()); if (typeRules.size() > 0) { rules.add(new Rule(new RuleInformation("type-rules"), typeRules)); } - return new Profile(profileFields, rules, profileDto.description); } - private Map getTypesFromConstraints(ProfileDTO profileDto) { - return getTopLevelConstraintsOfType(profileDto, AtomicConstraintType.IS_OF_TYPE.getText()) - .collect(Collectors.toMap( - constraintDTO -> constraintDTO.field, - constraintDTO -> (String)constraintDTO.value, - (a, b) -> a - )); - } private Set getInMapConstraints(ProfileDTO profileDto) { return profileDto.rules.stream() @@ -149,27 +133,11 @@ private Set getInMapConstraints(ProfileDTO profileDto) { .collect(Collectors.toSet()); } - private Stream getTopLevelConstraintsOfType(ProfileDTO profileDto, String constraint) { - return profileDto.rules.stream() - .flatMap(ruleDTO -> ruleDTO.constraints.stream()) - .flatMap(this::getConstraintOrAllOfConstraints) - .filter(constraintDTO -> constraintDTO.is != null) - .filter(constraintDTO -> constraintDTO.is.equals(constraint)); - } - private Stream getAllAtomicConstraints(Stream constraints) { return constraints.flatMap(this::getUnpackedConstraintsToStream); } - private Stream getConstraintOrAllOfConstraints(ConstraintDTO constraintDTO) { - if (constraintDTO.allOf != null){ - return constraintDTO.allOf.stream(); - } - - return Stream.of(constraintDTO); - } - private Stream getUnpackedConstraintsToStream(ConstraintDTO constraintDTO) { if (constraintDTO.then != null) { return getAllAtomicConstraints(constraintDTO.else_ == null ? diff --git a/profile/src/main/java/com/scottlogic/deg/profile/reader/MainConstraintReader.java b/profile/src/main/java/com/scottlogic/deg/profile/reader/MainConstraintReader.java index 93f910759..b8a3c545e 100644 --- a/profile/src/main/java/com/scottlogic/deg/profile/reader/MainConstraintReader.java +++ b/profile/src/main/java/com/scottlogic/deg/profile/reader/MainConstraintReader.java @@ -122,7 +122,6 @@ private InMapRelation createInMapRelation(Field field, Field other, DistributedL Set getSubConstraints(ProfileFields fields, Collection allOf) { return allOf.stream() .map(subConstraintDto -> apply(subConstraintDto, fields)) - .filter(constraint -> !(constraint instanceof RemoveFromTree)) .collect(Collectors.toSet()); } } diff --git a/profile/src/main/java/com/scottlogic/deg/profile/reader/RemoveFromTree.java b/profile/src/main/java/com/scottlogic/deg/profile/reader/RemoveFromTree.java deleted file mode 100644 index 80ee72ae4..000000000 --- a/profile/src/main/java/com/scottlogic/deg/profile/reader/RemoveFromTree.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.scottlogic.deg.profile.reader; - -import com.scottlogic.deg.generator.profile.constraints.Constraint; - -public class RemoveFromTree implements Constraint { - public RemoveFromTree() { - } - - @Override - public Constraint negate() { - throw new UnsupportedOperationException(); - } -} diff --git a/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/AtomicConstraintFactory.java b/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/AtomicConstraintFactory.java index 3ac0d0fbf..0e6ce950b 100644 --- a/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/AtomicConstraintFactory.java +++ b/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/AtomicConstraintFactory.java @@ -1,17 +1,15 @@ package com.scottlogic.deg.profile.reader.atomic; import com.scottlogic.deg.common.profile.Field; +import com.scottlogic.deg.common.profile.constraintdetail.AtomicConstraintType; import com.scottlogic.deg.common.profile.constraintdetail.NumericGranularityFactory; -import com.scottlogic.deg.generator.profile.constraints.Constraint; import com.scottlogic.deg.common.util.NumberUtils; import com.scottlogic.deg.generator.fieldspecs.whitelist.DistributedList; -import com.scottlogic.deg.common.profile.constraintdetail.AtomicConstraintType; +import com.scottlogic.deg.generator.profile.constraints.Constraint; import com.scottlogic.deg.generator.profile.constraints.atomic.*; -import com.scottlogic.deg.profile.reader.RemoveFromTree; import java.math.BigDecimal; import java.time.OffsetDateTime; -import java.util.Optional; import java.util.regex.Pattern; import static com.scottlogic.deg.profile.reader.atomic.ConstraintReaderHelpers.getDateTimeGranularity; @@ -30,14 +28,12 @@ public static Constraint create(AtomicConstraintType type, Field field, Object v return new MatchesRegexConstraint(field, pattern(value)); case CONTAINS_REGEX: return new ContainsRegexConstraint(field, pattern(value)); - case HAS_LENGTH: return new StringHasLengthConstraint(field, integer(value)); case IS_STRING_SHORTER_THAN: return new IsStringShorterThanConstraint(field, integer(value)); case IS_STRING_LONGER_THAN: return new IsStringLongerThanConstraint(field, integer(value)); - case IS_GREATER_THAN_CONSTANT: return new IsGreaterThanConstantConstraint(field, (BigDecimal) value); case IS_GREATER_THAN_OR_EQUAL_TO_CONSTANT: @@ -55,22 +51,11 @@ public static Constraint create(AtomicConstraintType type, Field field, Object v return new IsBeforeConstantDateTimeConstraint(field, (OffsetDateTime)value); case IS_BEFORE_OR_EQUAL_TO_CONSTANT_DATE_TIME: return new IsBeforeOrEqualToConstantDateTimeConstraint(field, (OffsetDateTime)value); - case IS_GRANULAR_TO: if (value instanceof Number) return new IsGranularToNumericConstraint(field, NumericGranularityFactory.create(value)); else return new IsGranularToDateConstraint(field, getDateTimeGranularity((String)value)); - - case IS_UNIQUE: - case FORMATTED_AS: - return new RemoveFromTree(); - - case IS_OF_TYPE: { - Optional constraint = OfTypeConstraintFactory.create(field, (String) value); - return constraint.orElseGet(RemoveFromTree::new); - } - default: throw new IllegalArgumentException("constraint type not found"); } diff --git a/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/ConstraintValueValidator.java b/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/ConstraintValueValidator.java index c158116fe..629b3ec0b 100644 --- a/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/ConstraintValueValidator.java +++ b/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/ConstraintValueValidator.java @@ -45,16 +45,11 @@ private static void validateConstraintValue(Field field, AtomicConstraintType ty case IS_IN_MAP: validateSet(field, type, value); break; - case IS_OF_TYPE: - validateOfTypes(field, value); - break; - case MATCHES_REGEX: case CONTAINS_REGEX: validatePattern(value); validateTypeIs(field, type, STRING); break; - case HAS_LENGTH: case IS_STRING_SHORTER_THAN: case IS_STRING_LONGER_THAN: @@ -134,10 +129,6 @@ private static void validateSet(Field field, AtomicConstraintType type, Object v .forEach(val->validateAny(field, type, val)); } - private static void validateOfTypes(Field field, Object value) { - OfTypeConstraintFactory.create(field, (String)value); - } - private static void validatePattern(Object value) { try { Pattern.compile((String)value); diff --git a/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/OfTypeConstraintFactory.java b/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/OfTypeConstraintFactory.java index 68416d524..17df39685 100644 --- a/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/OfTypeConstraintFactory.java +++ b/profile/src/main/java/com/scottlogic/deg/profile/reader/atomic/OfTypeConstraintFactory.java @@ -18,12 +18,10 @@ public static Optional create(Field field, String value){ case "string": case "datetime": return Optional.empty(); - case "integer": return Optional.of(new IsGranularToNumericConstraint(field, NumericGranularityFactory.create(BigDecimal.ONE)) ); - case "ISIN": case "SEDOL": case "CUSIP": @@ -32,7 +30,6 @@ public static Optional create(Field field, String value){ field, StandardConstraintTypes.valueOf(value.toUpperCase())) ); - case "firstname": case "lastname": case "fullname": diff --git a/profile/src/test/java/com/scottlogic/deg/profile/reader/ConstraintValidationAndReadingTests.java b/profile/src/test/java/com/scottlogic/deg/profile/reader/ConstraintValidationAndReadingTests.java index 60ecc99aa..65a04f5d3 100644 --- a/profile/src/test/java/com/scottlogic/deg/profile/reader/ConstraintValidationAndReadingTests.java +++ b/profile/src/test/java/com/scottlogic/deg/profile/reader/ConstraintValidationAndReadingTests.java @@ -133,14 +133,6 @@ private static Stream stringLengthInvalidOperandProvider() { Arguments.of(IS_STRING_SHORTER_THAN, nullValueDto)); } - private static Stream ofTypeInvalidValueProvider() { - ConstraintDTO numericTypeValueDto = new ConstraintDTO(); - numericTypeValueDto.field = "test"; - numericTypeValueDto.value = "numeric"; - - return Stream.of(Arguments.of(AtomicConstraintType.IS_OF_TYPE, numericTypeValueDto)); - } - private static Stream numericOutOfBoundsOperandProvider() { ConstraintDTO maxValueDtoPlusOne = new ConstraintDTO(); maxValueDtoPlusOne.field = "test"; @@ -218,18 +210,11 @@ public void testAtomicConstraintReader(AtomicConstraintType type, ConstraintDTO @DisplayName("Should fail when operators have an invalid operand") @ParameterizedTest(name = "{0} should be invalid") - @MethodSource({"stringLengthInvalidOperandProvider", "ofTypeInvalidValueProvider"}) + @MethodSource({"stringLengthInvalidOperandProvider"}) public void testAtomicConstraintReaderWithInvalidOperands(AtomicConstraintType type, ConstraintDTO dto) { Assertions.assertThrows(InvalidProfileException.class, () -> ConstraintValueValidator.validate(createField(dto.field), type, dto.value)); } - @Test - public void testBaseConstraintReaderMapWithUnmappedOperands() { - Assertions.assertThrows( - InvalidProfileException.class, - () -> ConstraintValueValidator.validate(createField("test"), IS_OF_TYPE, "garbage")); - } - @DisplayName("Should fail when value property is numeric and out of bounds") @ParameterizedTest(name = "{0} should be invalid") @MethodSource("numericOutOfBoundsOperandProvider") diff --git a/profile/src/test/java/com/scottlogic/deg/profile/reader/JsonProfileReaderTests.java b/profile/src/test/java/com/scottlogic/deg/profile/reader/JsonProfileReaderTests.java index a2a37b5fc..61c25d90b 100644 --- a/profile/src/test/java/com/scottlogic/deg/profile/reader/JsonProfileReaderTests.java +++ b/profile/src/test/java/com/scottlogic/deg/profile/reader/JsonProfileReaderTests.java @@ -1062,101 +1062,6 @@ public void type_setsFieldTypeProperty_whenSetInFieldDefinition() throws IOExcep expectRules(); } - @Test - public void type_setsFieldTypeProperty_whenSetInConstraintDefinition() throws IOException { - givenJson( - "{" + - " \"schemaVersion\": " + schemaVersion + "," + - " \"fields\": [ { " + - " \"name\": \"foo\"" + - " }, { " + - " \"name\": \"bar\" ," + - " \"type\": \"string\"" + - " }]," + - " \"rules\": [" + - " {" + - " \"rule\": \"fooRule\"," + - " \"constraints\": [{ \"field\": \"foo\", \"is\": \"ofType\", \"value\": \"decimal\" }]" + - " }" + - " ]" + - "}"); - - expectFields( - field -> { - Assert.assertThat(field.getType(), equalTo(Types.NUMERIC)); - }, - field -> { - Assert.assertThat(field.getType(), equalTo(Types.STRING)); - } - ); - } - - @Test - public void type_setsFieldTypeProperty_whenSetInNestedConstraintDefinition() throws IOException { - givenJson( - "{" + - " \"schemaVersion\": " + schemaVersion + "," + - " \"fields\": [ { " + - " \"name\": \"foo\"" + - " }, { " + - " \"name\": \"bar\" ," + - " \"type\": \"string\"" + - " }]," + - " \"rules\": [" + - " {" + - " \"rule\": \"fooRule\"," + - " \"constraints\": [" + - " { \"allOf\": [" + - " { \"field\": \"foo\", \"is\": \"ofType\", \"value\": \"decimal\" }," + - " { \"not\": { \"field\": \"foo\", \"is\": \"null\" } }" + - " ] }" + - " ]" + - " }" + - " ]" + - "}"); - - expectFields( - field -> { - Assert.assertThat(field.getType(), equalTo(Types.NUMERIC)); - }, - field -> { - Assert.assertThat(field.getType(), equalTo(Types.STRING)); - } - ); - } - - @Test - public void type_setsFieldTypeProperty_whenSetInMultipleConstraintDefinitions() throws IOException { - givenJson( - "{" + - " \"schemaVersion\": " + schemaVersion + "," + - " \"fields\": [ { " + - " \"name\": \"foo\"" + - " }, { " + - " \"name\": \"bar\" ," + - " \"type\": \"string\"" + - " }]," + - " \"rules\": [" + - " {" + - " \"rule\": \"fooRule\"," + - " \"constraints\": [" + - " { \"field\": \"foo\", \"is\": \"ofType\", \"value\": \"decimal\" }," + - " { \"field\": \"foo\", \"is\": \"ofType\", \"value\": \"datetime\" }" + - " ]" + - " }" + - " ]" + - "}"); - - expectFields( - field -> { - Assert.assertThat(field.getType(), equalTo(Types.NUMERIC)); - }, - field -> { - Assert.assertThat(field.getType(), equalTo(Types.STRING)); - } - ); - } - @Test void parser_createsInternalField_whenProfileHasAnInMapConstraint() throws IOException { givenJson(