| | |
| | | import static org.junit.jupiter.api.Assertions.assertThrows; |
| | | import static org.mockito.ArgumentMatchers.any; |
| | | import static org.mockito.ArgumentMatchers.anyLong; |
| | | import static org.mockito.ArgumentMatchers.eq; |
| | | import static org.mockito.ArgumentMatchers.isNull; |
| | | import static org.mockito.Mockito.doAnswer; |
| | | import static org.mockito.Mockito.never; |
| | |
| | | assertEquals(10L, testService.createTest(test)); |
| | | |
| | | verify(testMapper, never()).countCollectorEnabled(anyLong()); |
| | | } |
| | | |
| | | @Test |
| | | void createShouldAllowPlanStepsToBeConfiguredLater() |
| | | { |
| | | TTest test = validTest(); |
| | | test.setPlanSteps(Collections.emptyList()); |
| | | mockEnabledOptions(); |
| | | when(testMapper.insertTest(any(TTest.class))).thenAnswer(invocation -> { |
| | | invocation.<TTest>getArgument(0).setTestId(10L); |
| | | return 1; |
| | | }); |
| | | doAnswer(invocation -> { |
| | | invocation.<TTestBattery>getArgument(0).setRelationId(20L); |
| | | return 1; |
| | | }).when(testMapper).insertTestBattery(any(TTestBattery.class)); |
| | | |
| | | assertEquals(10L, testService.createTest(test)); |
| | | |
| | | verify(testMapper, never()).insertTestPlanStep(any(TTestPlanStep.class)); |
| | | } |
| | | |
| | | @Test |
| | |
| | | verify(testMapper).insertTestAudit(anyLong(), any(), anyLong(), any(), any(), any()); |
| | | } |
| | | |
| | | @Test |
| | | void deleteBeforeMonitoringShouldAppendAudit() |
| | | { |
| | | TTest current = validTest(); |
| | | current.setTestId(10L); |
| | | current.setMonitoringStatus("NOT_MONITORED"); |
| | | when(testMapper.selectTestByIdForUpdate(10L)).thenReturn(current); |
| | | when(testMapper.deleteTestById(10L, "operator")).thenReturn(1); |
| | | |
| | | assertEquals(1, testService.deleteTestByIds(new Long[] { 10L }, 7L, "operator")); |
| | | |
| | | verify(testMapper).insertTestAudit(eq(10L), eq("TEST_DELETED"), eq(7L), eq("operator"), any(), isNull()); |
| | | } |
| | | |
| | | private void mockEnabledOptions() |
| | | { |
| | | mockEnabledPeopleAndType(); |