Search in sources :

Example 1 with CreateDashboardRQ

use of com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ in project service-api by reportportal.

the class CreateDashboardHandlerImplTest method createAlreadyExistDashboard.

@Test
void createAlreadyExistDashboard() {
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    createDashboardRQ.setName("exist");
    final ReportPortalUser rpUser = getRpUser("owner", UserRole.USER, ProjectRole.MEMBER, 1L);
    when(dashboardRepository.existsByNameAndOwnerAndProjectId("exist", "owner", 1L)).thenReturn(true);
    final ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.createDashboard(extractProjectDetails(rpUser, "test_project"), createDashboardRQ, rpUser));
    assertEquals("Resource 'exist' already exists. You couldn't create the duplicate.", exception.getMessage());
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) CreateDashboardRQ(com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 2 with CreateDashboardRQ

use of com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ in project service-api by reportportal.

the class DashboardControllerValidationTest method createDashboardShouldReturnErrorWhenNameIsLessThanThreeCharacters.

@Test
public void createDashboardShouldReturnErrorWhenNameIsLessThanThreeCharacters() throws Exception {
    // GIVEN
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    createDashboardRQ.setName(SHORT_NAME_VALUE);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + DASHBOARD_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(createDashboardRQ)).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_SIZE_MESSAGE + "] ", error.getMessage());
}
Also used : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) CreateDashboardRQ(com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 3 with CreateDashboardRQ

use of com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ in project service-api by reportportal.

the class DashboardControllerValidationTest method updateDashboardShouldReturnErrorWhenNameIsLessThanThreeCharacters.

@Test
public void updateDashboardShouldReturnErrorWhenNameIsLessThanThreeCharacters() throws Exception {
    // GIVEN
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    createDashboardRQ.setName(SHORT_NAME_VALUE);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + DASHBOARD_PATH + ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(createDashboardRQ)).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_SIZE_MESSAGE + "] ", error.getMessage());
}
Also used : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) CreateDashboardRQ(com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 4 with CreateDashboardRQ

use of com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ in project service-api by reportportal.

the class DashboardControllerValidationTest method updateDashboardShouldReturnErrorWhenNameIsEmpty.

@Test
public void updateDashboardShouldReturnErrorWhenNameIsEmpty() throws Exception {
    // GIVEN
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    createDashboardRQ.setName(EMPTY);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + DASHBOARD_PATH + ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(createDashboardRQ)).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_BLANK_MESSAGE + " " + FIELD_NAME_SIZE_MESSAGE + "] ", error.getMessage());
}
Also used : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) CreateDashboardRQ(com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 5 with CreateDashboardRQ

use of com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ in project service-api by reportportal.

the class DashboardControllerValidationTest method updateDashboardShouldReturnErrorWhenNameIsNull.

@Test
public void updateDashboardShouldReturnErrorWhenNameIsNull() throws Exception {
    // GIVEN
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    // WHEN
    MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + DASHBOARD_PATH + ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(createDashboardRQ)).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 : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) CreateDashboardRQ(com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

CreateDashboardRQ (com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ)13 Test (org.junit.jupiter.api.Test)13 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)11 MvcResult (org.springframework.test.web.servlet.MvcResult)11 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)10 Dashboard (com.epam.ta.reportportal.entity.dashboard.Dashboard)2 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1