@Test public void testMultiply_invalidInput_noNumbers() throws Exception { // No numbers provided final NumbersDto numbersDto = new NumbersDto(Arrays.asList()); thrown.expect(IllegalArgumentException.class); thrown.expectMessage("No numbers provided"); controller.multiply(numbersDto); }
@Test public void testMultiply() throws Exception { final NumbersDto numbersDto = new NumbersDto(Arrays.asList(BigDecimal.ONE, BigDecimal.TEN)); // expectations when(calculatorService.multiply(numbersDto)).thenReturn(BigDecimal.TEN); final BigDecimal result = controller.multiply(numbersDto); // verifications assertEquals(BigDecimal.TEN, result); }