Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Stopwatch and negate to all PredicateType
- Loading branch information
Showing
5 changed files
with
149 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/test/java/com/speedment/field/predicate/PredicateTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,78 @@ | |||
/* | |||
* To change this license header, choose License Headers in Project Properties. | |||
* To change this template file, choose Tools | Templates | |||
* and open the template in the editor. | |||
*/ | |||
package com.speedment.field.predicate; | |||
|
|||
import static com.speedment.field.predicate.PredicateType.EQUAL; | |||
import static com.speedment.field.predicate.PredicateType.NOT_EQUAL; | |||
import java.util.EnumMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import static java.util.stream.Collectors.toList; | |||
import org.junit.After; | |||
import org.junit.AfterClass; | |||
import org.junit.Before; | |||
import org.junit.BeforeClass; | |||
import org.junit.Test; | |||
import static org.junit.Assert.*; | |||
|
|||
/** | |||
* | |||
* @author pemi | |||
*/ | |||
public class PredicateTypeTest { | |||
|
|||
public PredicateTypeTest() { | |||
} | |||
|
|||
@BeforeClass | |||
public static void setUpClass() { | |||
} | |||
|
|||
@AfterClass | |||
public static void tearDownClass() { | |||
} | |||
|
|||
@Before | |||
public void setUp() { | |||
} | |||
|
|||
@After | |||
public void tearDown() { | |||
} | |||
|
|||
@Test | |||
public void testComplementType() { | |||
// Make sure that each Type has a (unique) negated type | |||
final Map<PredicateType, PredicateType> map = new EnumMap(PredicateType.class); | |||
|
|||
for (PredicateType pt : PredicateType.values()) { | |||
final PredicateType negated = pt.negate(); | |||
assertNotNull(negated); | |||
assertFalse(map.containsKey(negated)); | |||
map.put(negated, pt); | |||
} | |||
|
|||
final List<PredicateType> keys = map.keySet().stream().sorted().collect(toList()); | |||
final List<PredicateType> values = map.values().stream().sorted().collect(toList()); | |||
assertEquals(keys, values); | |||
|
|||
} | |||
|
|||
@Test | |||
public void testGetComplementType() { | |||
System.out.println("getComplementType"); | |||
assertEquals(EQUAL, NOT_EQUAL.negate()); | |||
assertEquals(NOT_EQUAL, EQUAL.negate()); | |||
} | |||
|
|||
@Test | |||
public void testEffectiveType() { | |||
System.out.println("effectiveType"); | |||
assertEquals(EQUAL, EQUAL.effectiveType(false)); | |||
assertEquals(NOT_EQUAL, EQUAL.effectiveType(true)); | |||
} | |||
|
|||
} |