From 64676d5ab1785a54e82667fefb882b39623c87dc Mon Sep 17 00:00:00 2001 From: Thomas Hull Date: Thu, 3 Oct 2019 10:10:06 +0100 Subject: [PATCH] refactor(#1390): deal with commented out test --- .../EqualToFieldReaderTest.java | 101 ------------------ 1 file changed, 101 deletions(-) delete mode 100644 profile/src/test/java/com/scottlogic/deg/profile/reader/constraintreaders/EqualToFieldReaderTest.java diff --git a/profile/src/test/java/com/scottlogic/deg/profile/reader/constraintreaders/EqualToFieldReaderTest.java b/profile/src/test/java/com/scottlogic/deg/profile/reader/constraintreaders/EqualToFieldReaderTest.java deleted file mode 100644 index aac41f79b..000000000 --- a/profile/src/test/java/com/scottlogic/deg/profile/reader/constraintreaders/EqualToFieldReaderTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* -package com.scottlogic.deg.profile.reader.constraintreaders; - -import com.scottlogic.deg.common.profile.Field; -import com.scottlogic.deg.common.profile.ProfileFields; -import com.scottlogic.deg.common.profile.constraintdetail.AtomicConstraintType; -import com.scottlogic.deg.profile.dto.ConstraintDTO; -import com.scottlogic.deg.profile.reader.AtomicConstraintReader; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.time.OffsetDateTime; -import java.time.ZoneOffset; -import java.time.temporal.ChronoUnit; -import java.util.Arrays; -import java.util.stream.Collectors; - -import static org.junit.jupiter.api.Assertions.*; - -class EqualToFieldReaderTest { - - private static final String FIRST = "first"; - - private static final String SECOND = "second"; - - private AtomicConstraintReader equalToFieldReader; - - private ProfileFields fields; - - private ConstraintDTO dto; - - @BeforeEach - public void setUp() { - equalToFieldReader = new EqualToFieldReader(); - fields = fieldsOf(FIRST, SECOND); - dto = baseDTO(); - } - - @Test - public void apply_noOffset_createsTwoEqualFields() { - IsEqualToDynamicDateConstraint constraint = createConstraint(equalToFieldReader, dto, fields); - - assertEquals(new Field(FIRST), constraint.getOtherField()); - assertEquals(new Field(SECOND), constraint.field()); - assertNull(constraint.unit()); - } - - @Test - public void apply_withTwoDayOffset_createsTwoFieldsOffset() { - dto.offset = 2; - dto.offsetUnit = ChronoUnit.DAYS.toString(); - - IsEqualToDynamicDateConstraint constraint = createConstraint(equalToFieldReader, dto, fields); - assertEquals(2, constraint.offset()); - } - - @Test - public void apply_withWorkingDayOffset_createsTwoFieldsWithWorkingDayOffset() { - final int days = 5; - dto.offset = days; - dto.offsetUnit = "WORKING DAYS"; - - IsEqualToDynamicDateConstraint constraint = createConstraint(equalToFieldReader, dto, fields); - - OffsetDateTime initial = OffsetDateTime.of( - 2000, - 6, - 5, - 4, - 3, - 2, - 1, - ZoneOffset.UTC - ); - - - OffsetDateTime producedDate = OffsetDateTime.from(constraint.unit().adjuster(days).adjustInto(initial)); - assertEquals(initial.minusDays(7), producedDate); - } - - private static ConstraintDTO baseDTO() { - ConstraintDTO dto = new ConstraintDTO(); - dto.field = FIRST; - dto.is = AtomicConstraintType.IS_EQUAL_TO_FIELD.getText(); - dto.value = SECOND; - return dto; - } - - private static ProfileFields fieldsOf(String... fields) { - return new ProfileFields( - Arrays.stream(fields) - .map(Field::new) - .collect(Collectors.toList())); - } - - private static IsEqualToDynamicDateConstraint createConstraint(AtomicConstraintReader reader, - ConstraintDTO dto, - ProfileFields fields) { - return (IsEqualToDynamicDateConstraint) reader.apply(dto, fields); - } -}*/