Search in sources :

Example 6 with MergeLaunchesRQ

use of com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ in project service-api by reportportal.

the class LaunchAsyncControllerTest method mergeLaunch.

@Test
void mergeLaunch() {
    ReportPortalUser user = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    MergeLaunchesRQ mergeLaunchesRQ = new MergeLaunchesRQ();
    ArgumentCaptor<ReportPortalUser.ProjectDetails> projectDetailsArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.ProjectDetails.class);
    ArgumentCaptor<ReportPortalUser> userArgumentCaptor = ArgumentCaptor.forClass(ReportPortalUser.class);
    ArgumentCaptor<MergeLaunchesRQ> requestArgumentCaptor = ArgumentCaptor.forClass(MergeLaunchesRQ.class);
    when(projectExtractor.extractProjectDetails(any(ReportPortalUser.class), anyString())).thenReturn(user.getProjectDetails().get("test_project"));
    launchAsyncController.mergeLaunches("test_project", mergeLaunchesRQ, user);
    verify(mergeLaunchHandler).mergeLaunches(projectDetailsArgumentCaptor.capture(), userArgumentCaptor.capture(), requestArgumentCaptor.capture());
    assertEquals(user, userArgumentCaptor.getValue());
    assertEquals(user.getProjectDetails().get("test_project"), projectDetailsArgumentCaptor.getValue());
    assertEquals(mergeLaunchesRQ, requestArgumentCaptor.getValue());
}
Also used : MergeLaunchesRQ(com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 7 with MergeLaunchesRQ

use of com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ in project service-api by reportportal.

the class LaunchControllerValidationTest method mergeLaunchShouldReturnErrorWhenNameIsNull.

@Test
public void mergeLaunchShouldReturnErrorWhenNameIsNull() throws Exception {
    // GIVEN
    MergeLaunchesRQ mergeLaunchesRQ = prepareLaunchesMerge();
    // WHEN
    MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + LAUNCH_PATH + MERGE_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(mergeLaunchesRQ)).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest()).andReturn();
    // THEN
    ErrorRS error = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), ErrorRS.class);
    assertEquals(INCORRECT_REQUEST, error.getErrorType());
    assertEquals(INCORRECT_REQUEST_MESSAGE + FIELD_NAME_IS_NULL_MESSAGE, error.getMessage());
}
Also used : MergeLaunchesRQ(com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ) ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 8 with MergeLaunchesRQ

use of com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ in project service-api by reportportal.

the class LaunchControllerValidationTest method prepareLaunchesMerge.

private MergeLaunchesRQ prepareLaunchesMerge() {
    MergeLaunchesRQ mergeLaunchesRQ = new MergeLaunchesRQ();
    HashSet<Long> set = new HashSet<>();
    set.add(1L);
    set.add(2L);
    mergeLaunchesRQ.setLaunches(set);
    mergeLaunchesRQ.setMergeStrategyType("BASIC");
    mergeLaunchesRQ.setStartTime(new Date());
    mergeLaunchesRQ.setEndTime(new Date());
    return mergeLaunchesRQ;
}
Also used : MergeLaunchesRQ(com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ) Date(java.util.Date) HashSet(java.util.HashSet)

Aggregations

MergeLaunchesRQ (com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ)8 Test (org.junit.jupiter.api.Test)6 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)5 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)4 MvcResult (org.springframework.test.web.servlet.MvcResult)4 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 EntityUtils (com.epam.ta.reportportal.commons.EntityUtils)1 TO_LOCAL_DATE_TIME (com.epam.ta.reportportal.commons.EntityUtils.TO_LOCAL_DATE_TIME)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1 Suppliers (com.epam.ta.reportportal.commons.validation.Suppliers)1 IdentityUtil (com.epam.ta.reportportal.core.item.identity.IdentityUtil)1 TestItemUniqueIdGenerator (com.epam.ta.reportportal.core.item.identity.TestItemUniqueIdGenerator)1 LaunchMergeStrategy (com.epam.ta.reportportal.core.item.merge.LaunchMergeStrategy)1 AttachmentRepository (com.epam.ta.reportportal.dao.AttachmentRepository)1 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)1 LogRepository (com.epam.ta.reportportal.dao.LogRepository)1 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)1 ItemAttribute (com.epam.ta.reportportal.entity.ItemAttribute)1 IN_PROGRESS (com.epam.ta.reportportal.entity.enums.StatusEnum.IN_PROGRESS)1 TestItemTypeEnum (com.epam.ta.reportportal.entity.enums.TestItemTypeEnum)1