DATAKV-225 - Add support for immutable objects.
Add return type to KeyValueOperations.insert/update methods to return potentially changed object instances. Return KeyValueOperations.insert/update method result in SimpleKeyValueRepository.save(…).
This commit is contained in:
committed by
Oliver Gierke
parent
c2da46a5b7
commit
4f49fe98f4
@@ -110,6 +110,15 @@ public class KeyValueTemplateUnitTests {
|
||||
verify(adapterMock, times(1)).put("1", FOO_ONE, Foo.class.getName());
|
||||
}
|
||||
|
||||
@Test // DATACMNS-225
|
||||
public void insertShouldReturnInsertedObject() {
|
||||
|
||||
ClassWithStringId object = new ClassWithStringId();
|
||||
|
||||
assertThat(template.insert(object), is(object));
|
||||
assertThat(template.insert("1", object), is(object));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-525
|
||||
public void insertShouldThrowExceptionWhenObectWithIdAlreadyExists() {
|
||||
|
||||
@@ -225,6 +234,16 @@ public class KeyValueTemplateUnitTests {
|
||||
verify(adapterMock, times(1)).put("1", FOO_TWO, Foo.class.getName());
|
||||
}
|
||||
|
||||
@Test // DATAKV-225
|
||||
public void updateShouldReturnUpdatedObject() {
|
||||
|
||||
ClassWithStringId object = new ClassWithStringId();
|
||||
object.id = "foo";
|
||||
|
||||
assertThat(template.update(object), is(object));
|
||||
assertThat(template.update("1", object), is(object));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class) // DATACMNS-525
|
||||
public void updateShouldThrowExceptionWhenGivenNullId() {
|
||||
template.update(null, FOO_ONE);
|
||||
|
||||
Reference in New Issue
Block a user