@Test public void shouldThrowExceptionIfNoProgramProductExistForGivenProgramIdAndProductId() { when(programProductMapper.getIdByProgramAndProductId(1L, 2L)).thenReturn(null); expectedEx.expect(DataException.class); expectedEx.expectMessage("programProduct.product.program.invalid"); programProductRepository.getIdByProgramIdAndProductId(1L, 2L); }
@Test public void shouldGetProgramProductIdByProgramAndProductId() { when(programProductMapper.getIdByProgramAndProductId(1L, 2L)).thenReturn(3L); assertThat(programProductRepository.getIdByProgramIdAndProductId(1L, 2L), is(3L)); verify(programProductMapper).getIdByProgramAndProductId(1L, 2L); }