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

Commit

Permalink
Merge branch 'master' into feature/improve-online-ux
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Laing authored Jan 15, 2020
2 parents da70d1e + fe2ff00 commit 3086123
Show file tree
Hide file tree
Showing 16 changed files with 1,201 additions and 8 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions .idea/runConfigurations/Example_generation__demo_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions .idea/runConfigurations/Example_generation__faker_.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions orchestrator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ dependencies {
testCompile project(':core').sourceSets.test.output

testImplementation("org.junit.jupiter:junit-jupiter:${JUNIT_JUPITER_VERSION}")

implementation('org.jetbrains.kotlin:kotlin-stdlib') {
version {
strictly "1.3.30"
}
because "Security issue with 1.3.20"
}
implementation('org.jetbrains.kotlin:kotlin-stdlib-common') {
version {
strictly "1.3.30"
}
because "Security issue with 1.3.20"
}
implementation('org.jetbrains.kotlin:kotlin-reflect') {
version {
strictly "1.3.30"
}
because "Security issue with 1.3.20"
}
}

test {
Expand Down
20 changes: 20 additions & 0 deletions profile/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ dependencies {
testImplementation "org.mockito:mockito-junit-jupiter:${MOCKITO_JUNIT_JUPITER_VERSION}"
testImplementation("org.junit.jupiter:junit-jupiter:${JUNIT_JUPITER_VERSION}")
testImplementation "org.threeten:threeten-extra:${THREE_TEN_VERSION}"

implementation('org.jetbrains.kotlin:kotlin-stdlib') {
version {
strictly "1.3.30"
}
because "Security issue with 1.3.20"
}
implementation('org.jetbrains.kotlin:kotlin-stdlib-common') {
version {
strictly "1.3.30"
}
because "Security issue with 1.3.20"
}
implementation('org.jetbrains.kotlin:kotlin-reflect') {
version {
strictly "1.3.30"
}
because "Security issue with 1.3.20"
}

}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.scottlogic.datahelix.generator.profile.validators.profile;

import com.scottlogic.datahelix.generator.common.profile.SpecificFieldType;
import com.scottlogic.datahelix.generator.common.profile.StandardSpecificFieldType;
import com.scottlogic.datahelix.generator.common.validators.ValidationResult;
import com.scottlogic.datahelix.generator.profile.creation.ConstraintDTOBuilder;
Expand Down Expand Up @@ -82,6 +81,8 @@ public void validateAtomicConstraint_withNullField_fails()
// Assert
assertFalse(validationResult.isSuccess);
}

@Test
public void validateAtomicConstraint_withEmptyField_fails()
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* 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.datahelix.generator.profile.validators.profile.constraints.atomic;

import com.scottlogic.datahelix.generator.common.validators.ValidationResult;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class DateTimeGranularityValidatorTests {

@Test
public void validateDateTimeGranularityConstraint_withValidChronoUnit_succeeds()
{
// Act
ValidationResult validationResult = new DateTimeGranularityValidator("errorInfo").validate("millis");

// Assert
assertTrue(validationResult.isSuccess);
}

@Test
public void validateDateTimeGranularityConstraint_withWorkingDay_succeeds()
{
// Act
ValidationResult validationResult = new DateTimeGranularityValidator("errorInfo").validate("working days");

// Assert
assertTrue(validationResult.isSuccess);
}

@Test
public void validateDateTimeGranularityConstraint_withEmptyValue_fails()
{
// Act
ValidationResult validationResult = new DateTimeGranularityValidator("errorInfo").validate("");

// Assert
assertFalse(validationResult.isSuccess);
}

@Test
public void validateDateTimeGranularityConstraint_withInvalidValue_fails()
{
// Act
ValidationResult validationResult = new DateTimeGranularityValidator("errorInfo").validate("mills");

// Assert
assertFalse(validationResult.isSuccess);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* 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.datahelix.generator.profile.validators.profile.constraints.atomic;

import com.scottlogic.datahelix.generator.common.profile.StandardSpecificFieldType;
import com.scottlogic.datahelix.generator.common.validators.ValidationResult;
import com.scottlogic.datahelix.generator.profile.creation.FieldDTOBuilder;
import com.scottlogic.datahelix.generator.profile.dtos.FieldDTO;
import com.scottlogic.datahelix.generator.profile.dtos.constraints.atomic.EqualToConstraintDTO;
import org.junit.jupiter.api.Test;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class EqualToConstraintValidatorTests {

private final List<FieldDTO> fields = Arrays.asList
(
FieldDTOBuilder.create("text", StandardSpecificFieldType.STRING.toSpecificFieldType())
);

@Test
public void validateEqualToConstraint_withValidData_succeeds()
{
// Arrange
EqualToConstraintDTO dto = new EqualToConstraintDTO();
dto.field = "text";
dto.value = "test";

// Act
ValidationResult validationResult = new EqualToConstraintValidator(fields).validate(dto);

// Assert
assertTrue(validationResult.isSuccess);
}

@Test
public void validateEqualToConstraint_withNullField_fails()
{
// Arrange
EqualToConstraintDTO dto = new EqualToConstraintDTO();
dto.field = null;
dto.value = 1;

// Act
ValidationResult validationResult = new EqualToConstraintValidator(fields).validate(dto);

// Assert
assertFalse(validationResult.isSuccess);
}

@Test
public void validateEqualToConstraint_withEmptyField_fails()
{
// Arrange
EqualToConstraintDTO dto = new EqualToConstraintDTO();
dto.field = "";
dto.value = 1;

// Act
ValidationResult validationResult = new EqualToConstraintValidator(fields).validate(dto);

// Assert
assertFalse(validationResult.isSuccess);
}

@Test
public void validateEqualToConstraint_withUndefinedField_fails()
{
// Arrange
EqualToConstraintDTO dto = new EqualToConstraintDTO();
dto.field = "unknown";
dto.value = 1;

// Act
ValidationResult validationResult = new EqualToConstraintValidator(fields).validate(dto);

// Assert
assertFalse(validationResult.isSuccess);
}

@Test
public void validateEqualToConstraint_withIncorrectValueType_fails() {
// Arrange
EqualToConstraintDTO dto = new EqualToConstraintDTO();
dto.field = "text";
dto.value = 1;

// Act
ValidationResult validationResult = new EqualToConstraintValidator(fields).validate(dto);

// Assert
assertFalse(validationResult.isSuccess);
}
}
Loading

0 comments on commit 3086123

Please sign in to comment.