Package org.apache.deltaspike.data.test.domain

Examples of org.apache.deltaspike.data.test.domain.Simple


        return createSimple(name, null);
    }

    public Simple createSimple(String name, Integer counter)
    {
        Simple result = new Simple(name);
        result.setCounter(counter);
        entityManager.persist(result);
        entityManager.flush();
        return result;
    }
View Full Code Here


    public Object mapParameter(Object parameter)
    {
        if (parameter instanceof SimpleDto)
        {
            SimpleDto dto = (SimpleDto) parameter;
            Simple simple = new Simple(dto.getName());
            simple.setId(dto.getId() != null ? dto.getId().getId() : null);
            simple.setEnabled(dto.getEnabled());
            return simple;
        }
        return ((SimpleId) parameter).getId();
    }
View Full Code Here

        dto.setEnabled(Boolean.TRUE);

        // when
        SimpleDto saved = repository.saveAndFlush(dto);
        SimpleDto loadedDto = repository.findBy(saved.getId());
        Simple loaded = entityManager.find(Simple.class, saved.getId().getId());

        // then
        assertNotNull(loadedDto);
        assertNotNull(loaded);
        assertEquals(saved.getName(), loaded.getName());
        assertEquals(saved.getEnabled(), loaded.getEnabled());
    }
View Full Code Here

    @Test
    public void should_map_method_expression()
    {
        // given
        Simple simple = new Simple("should_map_method_expression");
        simple.setEnabled(Boolean.TRUE);
        entityManager.persist(simple);

        // when
        List<SimpleDto> result = repository.findByEnabled(Boolean.TRUE);

        // then
        boolean found = false;
        for (SimpleDto dto : result)
        {
            if (dto.getName().equals(simple.getName()))
            {
                found = true;
                break;
            }
        }
View Full Code Here

        // given
        final String name = "should_query_optional";
        builder.createSimple(name);

        // when
        Simple result1 = repo.queryResultWithNamed(name).getOptionalResult();
        Simple result2 = repo.queryResultWithNamed("this_does_not_exist").getOptionalResult();

        // then
        assertNotNull(result1);
        assertEquals(name, result1.getName());
        assertNull(result2);
View Full Code Here

    @Test
    public void should_override_class_config_with_method_config()
    {
        // given
        Simple simple = new Simple("should_map_method_expression");
        simple.setEnabled(Boolean.TRUE);
        entityManager.persist(simple);

        // when
        List<SimpleDto> result = repository.findByEnabled(new BooleanWrapper(Boolean.TRUE));

        // then
        boolean found = false;
        for (SimpleDto dto : result)
        {
            if (dto.getName().equals(simple.getName()))
            {
                found = true;
                break;
            }
        }
View Full Code Here

        final String name = "should_query_any";
        builder.createSimple(name);
        builder.createSimple(name);

        // when
        Simple result1 = repo.queryResultWithNamed(name).getAnyResult();
        Simple result2 = repo.queryResultWithNamed("this_does_not_exist").getAnyResult();

        // then
        assertNotNull(result1);
        assertEquals(name, result1.getName());
        assertNull(result2);
View Full Code Here

    @Test
    public void should_find_with_queryresult()
    {
        // given
        final String name = "should_find_with_queryresult";
        Simple simple = new Simple(name);
        simple.setEnabled(Boolean.TRUE);
        entityManager.persist(simple);

        // when
        List<SimpleDto> result = repository.findByNameToo(name)
                .changeOrder(Simple_.name.getName())
View Full Code Here

    @Test
    public void should_update_existing_entity_with_simplemapper()
    {
        // given
        final String name = "should_update_existing_entity_with_simplemapper";
        Simple simple = new Simple(name);
        simple.setEnabled(Boolean.TRUE);
        entityManager.persist(simple);

        SimpleDto dto = new SimpleDto();
        dto.setName(name + "_updated");
        dto.setEnabled(Boolean.TRUE);
        dto.setId(new SimpleId(simple.getId()));

        // when
        dtoRepository.save(dto);
        Simple lookup = entityManager.find(Simple.class, simple.getId());

        // then
        assertNotNull(lookup);
        assertEquals(name + "_updated", lookup.getName());
    }
View Full Code Here

    @Test
    @InSequence(2)
    public void should_save_in_transaction() throws Exception
    {
        // given
        Simple simple = new Simple(NAME);

        // when
        simple = repository.save(simple);

        // then
        assertNotNull(simple.getId());
        assertTrue(wrapper.isRunInTx());
    }
View Full Code Here

TOP

Related Classes of org.apache.deltaspike.data.test.domain.Simple

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.