-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
typetools: tests, serialization improvements
Signed-off-by: Ketoth Xupack <ketoth.xupack@gmail.com>
- Loading branch information
1 parent
6d11d86
commit b9668a4
Showing
17 changed files
with
265 additions
and
60 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
32 changes: 0 additions & 32 deletions
32
projects/typetools/src/main/java/org/nohope/typetools/TMap.java
This file was deleted.
Oops, something went wrong.
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
38 changes: 38 additions & 0 deletions
38
projects/typetools/src/test/java/org/nohope/SeriesElementTest.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.nohope; | ||
|
||
import org.joda.time.DateTime; | ||
import org.junit.Test; | ||
import org.nohope.test.SerializationUtils; | ||
|
||
import static com.mongodb.util.MyAsserts.assertFalse; | ||
import static com.mongodb.util.MyAsserts.assertTrue; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a> | ||
* @since 2013-10-11 13:56 | ||
*/ | ||
public class SeriesElementTest { | ||
|
||
@Test | ||
@SuppressWarnings({"ObjectEqualsNull", "EqualsBetweenInconvertibleTypes"}) | ||
public void serialization() { | ||
final DateTime date = DateTime.parse("2000-01-01T01:01:01.001"); | ||
final SeriesElement<Integer> e = new SeriesElement<>(date, 1); | ||
assertEquals("{\"timestamp\":946666861001,\"value\":1}", e.toString()); | ||
final SeriesElement<Integer> mongoCloned = SerializationUtils.assertMongoClonedEquals(e); | ||
final SeriesElement<Integer> javaCloned = SerializationUtils.assertJavaClonedEquals(e); | ||
|
||
assertTrue(date.isEqual(mongoCloned.getTimestamp())); | ||
assertTrue(date.isEqual(javaCloned.getTimestamp())); | ||
assertEquals(1, (int) mongoCloned.getValue()); | ||
assertEquals(1, (int) javaCloned.getValue()); | ||
|
||
assertFalse(e.equals(null)); | ||
assertFalse(e.equals(1)); | ||
assertTrue(e.equals(e)); | ||
|
||
assertEquals(e.hashCode(), javaCloned.hashCode()); | ||
assertEquals(e.hashCode(), mongoCloned.hashCode()); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
projects/typetools/src/test/java/org/nohope/reflection/ModifierMatcherTest.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.nohope.reflection; | ||
|
||
import org.junit.Test; | ||
import org.nohope.test.EnumTestSupport; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.nohope.reflection.ModifierMatcher.*; | ||
|
||
/** | ||
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a> | ||
* @since 2013-10-11 13:39 | ||
*/ | ||
public class ModifierMatcherTest extends EnumTestSupport<ModifierMatcher> { | ||
|
||
@Override | ||
protected Class<ModifierMatcher> getEnumClass() { | ||
return ModifierMatcher.class; | ||
} | ||
|
||
@Test | ||
public void reprTest() { | ||
assertEquals("!((PUBLIC && ABSTRACT) || FINAL)", not(or(and(PUBLIC, ABSTRACT), FINAL)).toString()); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
projects/typetools/src/test/java/org/nohope/typetools/SortedListTest.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.nohope.typetools; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* @author <a href="mailto:ketoth.xupack@gmail.com">Ketoth Xupack</a> | ||
* @since 2013-10-11 12:59 | ||
*/ | ||
public class SortedListTest { | ||
|
||
@Test | ||
public void sortingTest() { | ||
final SortedList<Integer> list = new SortedList<>(new SortedList.SerializableComparator<Integer>() { | ||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public int compare(final Integer o1, final Integer o2) { | ||
return o1.compareTo(o2); | ||
} | ||
}); | ||
|
||
list.add(2); | ||
list.add(3); | ||
list.add(1); | ||
|
||
try { | ||
list.add(1, 0); | ||
fail(); | ||
} catch (final UnsupportedOperationException ignored) { | ||
} | ||
|
||
assertEquals(1, (int) list.get(0)); | ||
assertEquals(1, (int) list.get(0)); | ||
assertEquals(2, (int) list.get(1)); | ||
assertEquals(3, (int) list.get(2)); | ||
} | ||
} |
Oops, something went wrong.