コード例 #1
0
  @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);
  }
コード例 #2
0
  @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);
  }
コード例 #3
0
  @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);
  }
コード例 #4
0
 @Test(expected = IllegalArgumentException.class)
 public void testInit_whenKeyIsNull_thenThrowIllegalArgumentException() {
   Data key = null;
   entry(key, new Object(), Extractors.empty());
 }
コード例 #5
0
 private CachedQueryEntry entry(Object key) {
   Data keyData = serializationService.toData(key);
   return new CachedQueryEntry(serializationService, keyData, new Object(), Extractors.empty());
 }