Search in sources :

Example 6 with CreateDashboardRQ

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

the class DashboardControllerValidationTest method createDashboardShouldReturnErrorWhenNameIsNull.

@Test
public void createDashboardShouldReturnErrorWhenNameIsNull() throws Exception {
    // GIVEN
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    // 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_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)

Example 7 with CreateDashboardRQ

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

the class DashboardControllerValidationTest method createDashboardShouldReturnErrorWhenNameConsistsOfWhitespaces.

@Test
public void createDashboardShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
    // GIVEN
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    createDashboardRQ.setName(WHITESPACES_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_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 8 with CreateDashboardRQ

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

the class DashboardBuilderTest method createDashboard.

@Test
void createDashboard() {
    final String name = "name";
    final String description = "description";
    final boolean share = true;
    final String owner = "owner";
    final Long projectId = 1L;
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    createDashboardRQ.setName(name);
    createDashboardRQ.setDescription(description);
    createDashboardRQ.setShare(share);
    final Dashboard dashboard = new DashboardBuilder().addDashboardRq(createDashboardRQ).addOwner(owner).addProject(projectId).get();
    assertEquals(name, dashboard.getName());
    assertEquals(description, dashboard.getDescription());
    assertEquals(share, dashboard.isShared());
    assertEquals(owner, dashboard.getOwner());
    assertEquals(projectId, dashboard.getProject().getId());
}
Also used : Dashboard(com.epam.ta.reportportal.entity.dashboard.Dashboard) CreateDashboardRQ(com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ) Test(org.junit.jupiter.api.Test)

Example 9 with CreateDashboardRQ

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

the class DashboardControllerTest method createDashboardPositive.

@Test
void createDashboardPositive() throws Exception {
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    createDashboardRQ.setName("dashboard");
    createDashboardRQ.setDescription("description");
    final MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/dashboard").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(createDashboardRQ)).contentType(APPLICATION_JSON)).andExpect(status().isCreated()).andReturn();
    final EntryCreatedRS entryCreatedRS = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), EntryCreatedRS.class);
    final Optional<Dashboard> dashboardOptional = dashboardRepository.findById(entryCreatedRS.getId());
    assertTrue(dashboardOptional.isPresent());
    assertEquals("dashboard", dashboardOptional.get().getName());
    assertEquals("description", dashboardOptional.get().getDescription());
}
Also used : Dashboard(com.epam.ta.reportportal.entity.dashboard.Dashboard) CreateDashboardRQ(com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ) EntryCreatedRS(com.epam.ta.reportportal.ws.model.EntryCreatedRS) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 10 with CreateDashboardRQ

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

the class DashboardControllerValidationTest method createDashboardShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters.

@Test
public void createDashboardShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters() throws Exception {
    // GIVEN
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    createDashboardRQ.setName(LONG_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)

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