Search in sources :

Example 1 with Cake

use of uk.gov.justice.services.example.cakeshop.persistence.entity.Cake in project microservice_framework by CJSCommonPlatform.

the class CakeMadeEventListenerTest method shouldSaveCake.

@Test
public void shouldSaveCake() {
    final Envelope<Cake> envelope = mock(Envelope.class);
    final Cake cake = mock(Cake.class);
    when(envelope.payload()).thenReturn(cake);
    cakeMadeEventListener.handle(envelope);
    verify(cakeRepository).save(cake);
}
Also used : Cake(uk.gov.justice.services.example.cakeshop.persistence.entity.Cake) Test(org.junit.Test)

Example 2 with Cake

use of uk.gov.justice.services.example.cakeshop.persistence.entity.Cake in project microservice_framework by CJSCommonPlatform.

the class CakeRepositoryTest method shouldReturnCakes.

@Test
public void shouldReturnCakes() throws Exception {
    final UUID id = randomUUID();
    final String name = "name123";
    final UUID id2 = randomUUID();
    final String name2 = "name456";
    cakeRepository.save(new Cake(id, name));
    cakeRepository.save(new Cake(id2, name2));
    final List<Cake> cakes = cakeRepository.findAll();
    assertThat(cakes, hasSize(2));
    assertThat(cakes.get(0).getCakeId(), is(id));
    assertThat(cakes.get(0).getName(), is(name));
    assertThat(cakes.get(1).getCakeId(), is(id2));
    assertThat(cakes.get(1).getName(), is(name2));
}
Also used : Cake(uk.gov.justice.services.example.cakeshop.persistence.entity.Cake) UUID.randomUUID(java.util.UUID.randomUUID) UUID(java.util.UUID) BaseTransactionalTest(uk.gov.justice.services.test.utils.persistence.BaseTransactionalTest) Test(org.junit.Test)

Example 3 with Cake

use of uk.gov.justice.services.example.cakeshop.persistence.entity.Cake in project microservice_framework by CJSCommonPlatform.

the class CakeServiceTest method shouldReturnCakes.

@Test
public void shouldReturnCakes() throws Exception {
    final UUID id = randomUUID();
    final UUID id2 = randomUUID();
    final String name = "Xmass Cake";
    final String name2 = "Easter Cake";
    when(cakeRepository.findAll()).thenReturn(asList(new Cake(id, name), new Cake(id2, name2)));
    final CakesView cakes = cakeService.cakes();
    assertThat(cakes.getCakes().get(0).getId(), is(id));
    assertThat(cakes.getCakes().get(0).getName(), is(name));
    assertThat(cakes.getCakes().get(1).getId(), is(id2));
    assertThat(cakes.getCakes().get(1).getName(), is(name2));
}
Also used : Cake(uk.gov.justice.services.example.cakeshop.persistence.entity.Cake) UUID(java.util.UUID) UUID.randomUUID(java.util.UUID.randomUUID) CakesView(uk.gov.justice.services.example.cakeshop.query.view.response.CakesView) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Cake (uk.gov.justice.services.example.cakeshop.persistence.entity.Cake)3 UUID (java.util.UUID)2 UUID.randomUUID (java.util.UUID.randomUUID)2 CakesView (uk.gov.justice.services.example.cakeshop.query.view.response.CakesView)1 BaseTransactionalTest (uk.gov.justice.services.test.utils.persistence.BaseTransactionalTest)1