Package org.baeldung.persistence.model

Examples of org.baeldung.persistence.model.Foo


    // find - one

    @Test
    /**/public final void givenResourceDoesNotExist_whenResourceIsRetrieved_thenNoResourceIsReceived() {
        // When
        final Foo createdResource = getApi().findOne(IDUtil.randomPositiveLong());

        // Then
        assertNull(createdResource);
    }
View Full Code Here


        assertNull(createdResource);
    }

    @Test
    public void givenResourceExists_whenResourceIsRetrieved_thenNoExceptions() {
        final Foo existingResource = persistNewEntity();
        getApi().findOne(existingResource.getId());
    }
View Full Code Here

        getApi().findOne(IDUtil.randomPositiveLong());
    }

    @Test
    public void givenResourceExists_whenResourceIsRetrieved_thenTheResultIsNotNull() {
        final Foo existingResource = persistNewEntity();
        final Foo retrievedResource = getApi().findOne(existingResource.getId());
        assertNotNull(retrievedResource);
    }
View Full Code Here

        assertNotNull(retrievedResource);
    }

    @Test
    public void givenResourceExists_whenResourceIsRetrieved_thenResourceIsRetrievedCorrectly() {
        final Foo existingResource = persistNewEntity();
        final Foo retrievedResource = getApi().findOne(existingResource.getId());
        assertEquals(existingResource, retrievedResource);
    }
View Full Code Here

        assertThat(allResources, not(Matchers.<Foo> empty()));
    }

    @Test
    /**/public void givenAnResourceExists_whenAllResourcesAreRetrieved_thenTheExistingResourceIsIndeedAmongThem() {
        final Foo existingResource = persistNewEntity();

        final List<Foo> resources = getApi().findAll();

        assertThat(resources, hasItem(existingResource));
    }
View Full Code Here

        persistNewEntity();
    }

    @Test
    /**/public void whenResourceIsCreated_thenResourceIsRetrievable() {
        final Foo existingResource = persistNewEntity();

        assertNotNull(getApi().findOne(existingResource.getId()));
    }
View Full Code Here

        assertNotNull(getApi().findOne(existingResource.getId()));
    }

    @Test
    /**/public void whenResourceIsCreated_thenSavedResourceIsEqualToOriginalResource() {
        final Foo originalResource = createNewEntity();
        final Foo savedResource = getApi().create(originalResource);

        assertEquals(originalResource, savedResource);
    }
View Full Code Here

        assertEquals(originalResource, savedResource);
    }

    @Test(expected = RuntimeException.class)
    public void whenResourceWithFailedConstraintsIsCreated_thenException() {
        final Foo invalidResource = createNewEntity();
        invalidate(invalidResource);

        getApi().create(invalidResource);
    }
View Full Code Here

     * -- specific to the persistence engine
     */
    @Test(expected = DataAccessException.class)
    @Ignore("Hibernate simply ignores the id silently and still saved (tracking this)")
    public void whenResourceWithIdIsCreated_thenDataAccessException() {
        final Foo resourceWithId = createNewEntity();
        resourceWithId.setId(IDUtil.randomPositiveLong());

        getApi().create(resourceWithId);
    }
View Full Code Here

    }

    @Test
    /**/public void givenResourceExists_whenResourceIsUpdated_thenNoExceptions() {
        // Given
        final Foo existingResource = persistNewEntity();

        // When
        getApi().update(existingResource);
    }
View Full Code Here

TOP

Related Classes of org.baeldung.persistence.model.Foo

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.