new custom query operation for spring data and tests

This commit is contained in:
eugenp
2014-05-24 12:17:05 +03:00
parent 6da20ff4db
commit 39b7570d82
4 changed files with 22 additions and 8 deletions
@@ -1,6 +1,7 @@
package org.baeldung.persistence.service;
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
import static org.junit.Assert.assertNotNull;
import org.baeldung.persistence.IOperations;
import org.baeldung.persistence.model.Foo;
@@ -39,16 +40,20 @@ public class FooServicePersistenceIntegrationTest extends AbstractServicePersist
service.create(new Foo());
}
// @Test(expected = DataIntegrityViolationException.class)
// public final void whenEntityWithLongNameIsCreated_thenDataException() {
// service.create(new Foo(randomAlphabetic(2048)));
// }
@Test(expected = DataIntegrityViolationException.class)
public final void whenEntityWithLongNameIsCreated_thenDataException() {
service.create(new Foo(randomAlphabetic(2048)));
}
// custom Query method
@Test
public final void givenUsingCustomQuery_whenExecuting_thenNoExceptions() {
// service.create(new Foo(randomAlphabetic(2048)));
public final void givenUsingCustomQuery_whenRetrievingEntity_thenFound() {
final String name = randomAlphabetic(6);
service.create(new Foo(name));
final Foo retrievedByName = service.retrieveByName(name);
assertNotNull(retrievedByName);
}
// work in progress