org.springframework.data.mapping.IdentifierAccessor Java Examples

The following examples show how to use org.springframework.data.mapping.IdentifierAccessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultNeo4jIsNewStrategyTest.java    From sdn-rx with Apache License 2.0 6 votes vote down vote up
@Test
void shouldDealWithNonPrimitives() {
	Object a = new Object();
	Object b = new Object();

	IdDescription idDescription = IdDescription.forInternallyGeneratedIds();
	doReturn(Long.class).when(idProperty).getType();
	doReturn(idDescription).when(entityMetaData).getIdDescription();
	doReturn(idProperty).when(entityMetaData).getRequiredIdProperty();
	doReturn((IdentifierAccessor) () -> null).when(entityMetaData).getIdentifierAccessor(a);
	doReturn((IdentifierAccessor) () -> Long.valueOf(1)).when(entityMetaData).getIdentifierAccessor(b);

	IsNewStrategy strategy = DefaultNeo4jIsNewStrategy.basedOn(entityMetaData);
	assertThat(strategy.isNew(a)).isTrue();
	assertThat(strategy.isNew(b)).isFalse();
}
 
Example #2
Source File: DefaultNeo4jIsNewStrategyTest.java    From sdn-rx with Apache License 2.0 6 votes vote down vote up
@Test
void shouldDealWithPrimitives() {
	Object a = new Object();
	Object b = new Object();
	Object c = new Object();

	IdDescription idDescription = IdDescription.forInternallyGeneratedIds();
	doReturn(long.class).when(idProperty).getType();
	doReturn(idDescription).when(entityMetaData).getIdDescription();
	doReturn(idProperty).when(entityMetaData).getRequiredIdProperty();
	doReturn((IdentifierAccessor) () -> -1L).when(entityMetaData).getIdentifierAccessor(a);
	doReturn((IdentifierAccessor) () -> 0L).when(entityMetaData).getIdentifierAccessor(b);
	doReturn((IdentifierAccessor) () -> 1L).when(entityMetaData).getIdentifierAccessor(c);

	IsNewStrategy strategy = DefaultNeo4jIsNewStrategy.basedOn(entityMetaData);
	assertThat(strategy.isNew(a)).isTrue();
	assertThat(strategy.isNew(b)).isFalse();
	assertThat(strategy.isNew(c)).isFalse();
}
 
Example #3
Source File: DefaultNeo4jIsNewStrategyTest.java    From sdn-rx with Apache License 2.0 6 votes vote down vote up
@Test
void shouldDealWithNonPrimitives() {

	Object a = new Object();
	Object b = new Object();
	IdDescription idDescription = IdDescription.forExternallyGeneratedIds(DummyIdGenerator.class, null, "na");
	doReturn(String.class).when(idProperty).getType();
	doReturn(idDescription).when(entityMetaData).getIdDescription();
	doReturn(idProperty).when(entityMetaData).getRequiredIdProperty();
	doReturn((IdentifierAccessor) () -> null).when(entityMetaData).getIdentifierAccessor(a);
	doReturn((IdentifierAccessor) () -> "4711").when(entityMetaData).getIdentifierAccessor(b);

	IsNewStrategy strategy = DefaultNeo4jIsNewStrategy.basedOn(entityMetaData);
	assertThat(strategy.isNew(a)).isTrue();
	assertThat(strategy.isNew(b)).isFalse();
}
 
Example #4
Source File: DefaultArangoPersistentEntity.java    From spring-data with Apache License 2.0 4 votes vote down vote up
@Override
public IdentifierAccessor getArangoIdAccessor(final Object bean) {
	return getArangoIdProperty().isPresent() ? new ArangoIdPropertyIdentifierAccessor(this, bean)
			: new AbsentAccessor(bean);
}
 
Example #5
Source File: ArangoPersistentEntity.java    From spring-data with Apache License 2.0 votes vote down vote up
IdentifierAccessor getArangoIdAccessor(Object bean);