assertEquals(sortKey, entity.getStr());
}
@Test
public void testHistoryOfEntity1() throws Exception {
SortedSetEntity entity1 = getAuditReader().find(SortedSetEntity.class, 1, 1);
assertEquals("sortedEntity1", entity1.getData());
assertEquals(Integer.valueOf(1), entity1.getId());
SortedSet<StrTestEntity> sortedSet = entity1.getSortedSet();
assertEquals(StrTestEntityComparator.class, sortedSet.comparator().getClass());
assertEquals(0, sortedSet.size());
SortedMap<StrTestEntity, String> sortedMap = entity1.getSortedMap();
assertEquals(StrTestEntityComparator.class, sortedMap.comparator().getClass());
assertEquals(0, sortedMap.size());
entity1 = getAuditReader().find(SortedSetEntity.class, 1, 2);
assertEquals("sortedEntity1", entity1.getData());
assertEquals(Integer.valueOf(1), entity1.getId());
sortedSet = entity1.getSortedSet();
assertEquals(StrTestEntityComparator.class, sortedSet.comparator().getClass());
assertEquals(1, sortedSet.size());
Iterator<StrTestEntity> iterator = sortedSet.iterator();
checkStrTestEntity(iterator.next(), id1, "abc");
sortedMap = entity1.getSortedMap();
assertEquals(StrTestEntityComparator.class, sortedMap.comparator().getClass());
assertEquals(1, sortedMap.size());
Iterator<Map.Entry<StrTestEntity, String>> mapIterator = sortedMap.entrySet().iterator();
checkStrTestEntity(mapIterator.next().getKey(), id1, "abc");
mapIterator = sortedMap.entrySet().iterator();
assertEquals(mapIterator.next().getValue(), "abc");
entity1 = getAuditReader().find(SortedSetEntity.class, 1, 3);
assertEquals("sortedEntity1", entity1.getData());
assertEquals(Integer.valueOf(1), entity1.getId());
sortedSet = entity1.getSortedSet();
assertEquals(StrTestEntityComparator.class, sortedSet.comparator().getClass());
assertEquals(2, sortedSet.size());
iterator = sortedSet.iterator();
checkStrTestEntity(iterator.next(), id2, "aaa");
checkStrTestEntity(iterator.next(), id1, "abc");
sortedMap = entity1.getSortedMap();
assertEquals(StrTestEntityComparator.class, sortedMap.comparator().getClass());
assertEquals(2, sortedMap.size());
mapIterator = sortedMap.entrySet().iterator();
checkStrTestEntity(mapIterator.next().getKey(), id2, "aaa");
checkStrTestEntity(mapIterator.next().getKey(), id1, "abc");
mapIterator = sortedMap.entrySet().iterator();
assertEquals(mapIterator.next().getValue(), "aaa");
assertEquals(mapIterator.next().getValue(), "abc");
entity1 = getAuditReader().find(SortedSetEntity.class, 1, 4);
assertEquals("sortedEntity1", entity1.getData());
assertEquals(Integer.valueOf(1), entity1.getId());
sortedSet = entity1.getSortedSet();
assertEquals(StrTestEntityComparator.class, sortedSet.comparator().getClass());
assertEquals(3, sortedSet.size());
iterator = sortedSet.iterator();
checkStrTestEntity(iterator.next(), id2, "aaa");
checkStrTestEntity(iterator.next(), id3, "aba");
checkStrTestEntity(iterator.next(), id1, "abc");
sortedMap = entity1.getSortedMap();
assertEquals(StrTestEntityComparator.class, sortedMap.comparator().getClass());
assertEquals(3, sortedMap.size());
mapIterator = sortedMap.entrySet().iterator();
checkStrTestEntity(mapIterator.next().getKey(), id2, "aaa");
checkStrTestEntity(mapIterator.next().getKey(), id3, "aba");
checkStrTestEntity(mapIterator.next().getKey(), id1, "abc");
mapIterator = sortedMap.entrySet().iterator();
assertEquals(mapIterator.next().getValue(), "aaa");
assertEquals(mapIterator.next().getValue(), "aba");
assertEquals(mapIterator.next().getValue(), "abc");
entity1 = getAuditReader().find(SortedSetEntity.class, 1, 5);
assertEquals("sortedEntity1", entity1.getData());
assertEquals(Integer.valueOf(1), entity1.getId());
sortedSet = entity1.getSortedSet();
assertEquals(StrTestEntityComparator.class, sortedSet.comparator().getClass());
assertEquals(4, sortedSet.size());
iterator = sortedSet.iterator();
checkStrTestEntity(iterator.next(), id2, "aaa");
checkStrTestEntity(iterator.next(), id4, "aac");
checkStrTestEntity(iterator.next(), id3, "aba");
checkStrTestEntity(iterator.next(), id1, "abc");
sortedMap = entity1.getSortedMap();
assertEquals(StrTestEntityComparator.class, sortedMap.comparator().getClass());
assertEquals(4, sortedMap.size());
mapIterator = sortedMap.entrySet().iterator();
checkStrTestEntity(mapIterator.next().getKey(), id2, "aaa");
checkStrTestEntity(mapIterator.next().getKey(), id4, "aac");