Search in sources :

Example 1 with Simple

use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.

the class EntityManagerDelegateHandlerTest method should_delete_detached_entity.

@Test
public void should_delete_detached_entity() {
    // given
    Simple simple = testData.createSimple("should_merge_entity");
    Long id = simple.getId();
    // when
    repository.detach(simple);
    repository.remove(repository.merge(simple));
    // then
    assertNotNull(id);
    Simple search = repository.findBy(id);
    assertNull(search);
}
Also used : Simple(org.apache.deltaspike.data.test.domain.Simple) Test(org.junit.Test)

Example 2 with Simple

use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.

the class EntityRepositoryHandlerTest method should_remove.

@Test
public void should_remove() {
    // given
    Simple simple = testData.createSimple("testRemove");
    // when
    repo.remove(simple);
    repo.flush();
    Simple lookup = getEntityManager().find(Simple.class, simple.getId());
    // then
    assertNull(lookup);
}
Also used : Simple(org.apache.deltaspike.data.test.domain.Simple) Test(org.junit.Test)

Example 3 with Simple

use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.

the class EntityRepositoryHandlerTest method should_find_by_example_with_no_attributes.

@Test
@SuppressWarnings("unchecked")
public void should_find_by_example_with_no_attributes() throws Exception {
    // given
    Simple simple = testData.createSimple("testFindByExample");
    SingularAttribute<Simple, ?>[] attributes = new SingularAttribute[] {};
    // when
    List<Simple> find = repo.findBy(simple, attributes);
    // then
    assertNotNull(find);
    assertFalse(find.isEmpty());
    assertEquals(simple.getName(), find.get(0).getName());
}
Also used : SingularAttribute(javax.persistence.metamodel.SingularAttribute) Simple(org.apache.deltaspike.data.test.domain.Simple) Test(org.junit.Test)

Example 4 with Simple

use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.

the class EntityRepositoryHandlerTest method should_count_by_like.

@Test
@SuppressWarnings("unchecked")
public void should_count_by_like() {
    // given
    testData.createSimple("testFindAll1");
    testData.createSimple("testFindAll2");
    Simple example = new Simple("test");
    // when
    Long count = repo.countLike(example, Simple_.name);
    // then
    assertEquals(Long.valueOf(2), count);
}
Also used : Simple(org.apache.deltaspike.data.test.domain.Simple) Test(org.junit.Test)

Example 5 with Simple

use of org.apache.deltaspike.data.test.domain.Simple in project deltaspike by apache.

the class CriteriaTest method should_create_select_criteria_with_any_result.

@Test
public void should_create_select_criteria_with_any_result() {
    // given
    final String name = "should_create_select_criteria_with_any_result";
    createSimple(name, 10);
    createSimple(name, 10);
    // when
    Simple result1 = repo.queryAny(name);
    Simple result2 = repo.queryAny(name + "_doesnt exist");
    // then
    assertNotNull(result1);
    assertEquals(name, result1.getName());
    assertNull(result2);
}
Also used : Simple(org.apache.deltaspike.data.test.domain.Simple) Test(org.junit.Test)

Aggregations

Simple (org.apache.deltaspike.data.test.domain.Simple)67 Test (org.junit.Test)64 SimpleDto (org.apache.deltaspike.data.test.domain.dto.SimpleDto)6 InSequence (org.jboss.arquillian.junit.InSequence)3 SingularAttribute (javax.persistence.metamodel.SingularAttribute)2 SimpleId (org.apache.deltaspike.data.test.domain.dto.SimpleId)2 Calendar (java.util.Calendar)1 Date (java.util.Date)1 BooleanWrapper (org.apache.deltaspike.data.test.domain.dto.BooleanWrapper)1