@Test @Ignore public void testGetDogsByOwner() { Customer customer1 = new Customer("Martin", "Sakac", "Purkynova 4", "111"); Customer customer2 = new Customer("Martin", "Haha", "Purkynova 55", "9999"); Dog dog1 = new Dog("Martin", "doga", new LocalDate(1998, 05, 22), customer1); Dog dog2 = new Dog("Martin", "doga", new LocalDate(1998, 05, 22), customer2); Dog dog3 = new Dog("Pepan", "doga", new LocalDate(1998, 05, 22), customer2); List<Dog> listAll = Arrays.asList(dog1, dog2, dog3); List<Dog> listExpected = Arrays.asList(dog2, dog3); Mockito.stub(dogDaoImplMock.getDogsByOwner(CustomerConverter.CustomerToCustomerDto(customer2))) .toReturn(listExpected); List<DogDto> listActual = dogService.getDogsByOwner(CustomerConverter.CustomerToCustomerDto(customer2)); Mockito.verify(dogDaoImplMock) .getDogsByOwner(CustomerConverter.CustomerToCustomerDto(customer2)); for (int i = 0; i < 2; i++) { assertDog(listExpected.get(i), listActual.get(i)); } }
@Test public void testGetDog() { Dog dog = new Dog( "Martin", "doga", new LocalDate(1998, 05, 22), new Customer("Martin", "Sakac", "Purkynova 4", "111")); dog.setId(1L); Mockito.stub(dogDaoImplMock.getDog(Mockito.anyLong())).toReturn(dog); DogDto dogActual = dogService.getDogById(1L); Mockito.verify(dogDaoImplMock).getDog(1L); assertDog(dog, dogActual); }
@Test public void testGetAllDogs() { Dog dog1 = new Dog( "Martin", "doga", new LocalDate(1998, 05, 22), new Customer("Martin", "Sakac", "Purkynova 4", "111")); Dog dog2 = new Dog( "Martin", "doga", new LocalDate(1998, 05, 22), new Customer("Martin", "Sakac", "Purkynova 4", "111")); List<Dog> dogList = Arrays.asList(dog1, dog2); Mockito.stub(dogDaoImplMock.getAllDogs()).toReturn(dogList); List<DogDto> list = dogService.getAllDogs(); Mockito.verify(dogDaoImplMock).getAllDogs(); for (int i = 0; i < 2; i++) { assertDog(dogList.get(i), list.get(i)); } }