@Test public void testGetKey() { String keyObject = "key"; Data keyData = serializationService.toData(keyObject); QueryableEntry entry = entry(keyData, new Object(), Extractors.empty()); Object key = entry.getKey(); assertEquals(keyObject, key); }
@Test public void testGetTargetObject_givenKeyDataIsPortable_whenKeyFlagIsTrue_thenReturnKeyData() { // given Data keyData = mockPortableData(); QueryableEntry entry = entry(keyData, new Object(), Extractors.empty()); // when Object targetObject = entry.getTargetObject(true); // then assertSame(keyData, targetObject); }
@Test public void testGetTargetObject_givenKeyDataIsNotPortable_whenKeyFlagIsTrue_thenReturnKeyObject() { // given Object keyObject = "key"; Data keyData = serializationService.toData(keyObject); QueryableEntry entry = entry(keyData, new Object(), Extractors.empty()); // when Object targetObject = entry.getTargetObject(true); // then assertEquals(keyObject, targetObject); }
@Test(expected = IllegalArgumentException.class) public void testInit_whenKeyIsNull_thenThrowIllegalArgumentException() { Data key = null; entry(key, new Object(), Extractors.empty()); }
private CachedQueryEntry entry(Object key) { Data keyData = serializationService.toData(key); return new CachedQueryEntry(serializationService, keyData, new Object(), Extractors.empty()); }