Search in sources :

Example 1 with UpdateProjectRQ

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

the class ProjectControllerTest method updateProjectConfigInterruptLaunchesNegativeTest.

@Test
void updateProjectConfigInterruptLaunchesNegativeTest() throws Exception {
    UpdateProjectRQ rq = new UpdateProjectRQ();
    ProjectConfigurationUpdate configuration = new ProjectConfigurationUpdate();
    HashMap<String, String> projectAttributes = new HashMap<>();
    projectAttributes.put("notifications.enabled", "false");
    projectAttributes.put("job.interruptJobTime", "incorrect");
    configuration.setProjectAttributes(projectAttributes);
    rq.setConfiguration(configuration);
    HashMap<String, String> userRoles = new HashMap<>();
    userRoles.put("test_user", "PROJECT_MANAGER");
    rq.setUserRoles(userRoles);
    mockMvc.perform(put("/v1/project/test_project").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isBadRequest());
}
Also used : ProjectConfigurationUpdate(com.epam.ta.reportportal.ws.model.project.config.ProjectConfigurationUpdate) UpdateProjectRQ(com.epam.ta.reportportal.ws.model.project.UpdateProjectRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with UpdateProjectRQ

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

the class ProjectControllerTest method updateProjectPositive.

@Test
void updateProjectPositive() throws Exception {
    final UpdateProjectRQ rq = new UpdateProjectRQ();
    ProjectConfigurationUpdate configuration = new ProjectConfigurationUpdate();
    HashMap<String, String> projectAttributes = new HashMap<>();
    projectAttributes.put("notifications.enabled", "false");
    // 2 weeks in seconds
    projectAttributes.put("job.keepLaunches", String.valueOf(3600 * 24 * 14));
    // 2 weeks in seconds
    projectAttributes.put("job.keepLogs", String.valueOf(3600 * 24 * 14));
    // 1 week in seconds
    projectAttributes.put("job.interruptJobTime", String.valueOf(3600 * 24 * 7));
    // 1 week in seconds
    projectAttributes.put("job.keepScreenshots", String.valueOf(3600 * 24 * 7));
    projectAttributes.put("analyzer.autoAnalyzerMode", "CURRENT_LAUNCH");
    projectAttributes.put("analyzer.minShouldMatch", "5");
    projectAttributes.put("analyzer.numberOfLogLines", "5");
    projectAttributes.put("analyzer.isAutoAnalyzerEnabled", "false");
    configuration.setProjectAttributes(projectAttributes);
    rq.setConfiguration(configuration);
    HashMap<String, String> userRoles = new HashMap<>();
    userRoles.put("test_user", "PROJECT_MANAGER");
    rq.setUserRoles(userRoles);
    mockMvc.perform(put("/v1/project/test_project").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isOk());
    Project project = projectRepository.findByName("test_project").get();
    projectAttributes.forEach((key, value) -> {
        Optional<ProjectAttribute> pa = project.getProjectAttributes().stream().filter(it -> it.getAttribute().getName().equalsIgnoreCase(key)).findAny();
        assertTrue(pa.isPresent());
        assertEquals(value, pa.get().getValue());
    });
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) java.util(java.util) Project(com.epam.ta.reportportal.entity.project.Project) MockMvcResultMatchers.jsonPath(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath) DeleteBulkRQ(com.epam.ta.reportportal.ws.model.DeleteBulkRQ) Autowired(org.springframework.beans.factory.annotation.Autowired) CreateProjectRQ(com.epam.ta.reportportal.ws.model.project.CreateProjectRQ) AssignUsersRQ(com.epam.ta.reportportal.ws.model.project.AssignUsersRQ) Collections.singletonList(java.util.Collections.singletonList) ItemAttributeResource(com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource) ExchangeInfo(com.rabbitmq.http.client.domain.ExchangeInfo) ResultActions(org.springframework.test.web.servlet.ResultActions) Lists(com.google.common.collect.Lists) ProjectAttribute(com.epam.ta.reportportal.entity.project.ProjectAttribute) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) Qualifier(org.springframework.beans.factory.annotation.Qualifier) Matchers.hasSize(org.hamcrest.Matchers.hasSize) APPLICATION_JSON(org.springframework.http.MediaType.APPLICATION_JSON) RabbitTemplate(org.springframework.amqp.rabbit.core.RabbitTemplate) SenderCaseDTO(com.epam.ta.reportportal.ws.model.project.email.SenderCaseDTO) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) UpdateProjectRQ(com.epam.ta.reportportal.ws.model.project.UpdateProjectRQ) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Sql(org.springframework.test.context.jdbc.Sql) MockMvcRequestBuilders(org.springframework.test.web.servlet.request.MockMvcRequestBuilders) Sets(com.google.common.collect.Sets) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) UnassignUsersRQ(com.epam.ta.reportportal.ws.model.project.UnassignUsersRQ) AfterEach(org.junit.jupiter.api.AfterEach) ProjectRepository(com.epam.ta.reportportal.dao.ProjectRepository) Assertions(org.junit.jupiter.api.Assertions) ProjectConfigurationUpdate(com.epam.ta.reportportal.ws.model.project.config.ProjectConfigurationUpdate) Client(com.rabbitmq.http.client.Client) ProjectNotificationConfigDTO(com.epam.ta.reportportal.ws.model.project.email.ProjectNotificationConfigDTO) Project(com.epam.ta.reportportal.entity.project.Project) ProjectConfigurationUpdate(com.epam.ta.reportportal.ws.model.project.config.ProjectConfigurationUpdate) UpdateProjectRQ(com.epam.ta.reportportal.ws.model.project.UpdateProjectRQ) ProjectAttribute(com.epam.ta.reportportal.entity.project.ProjectAttribute) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 3 with UpdateProjectRQ

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

the class ProjectControllerTest method updateProjectConfigurationIncorrectAttributeTest.

@Test
void updateProjectConfigurationIncorrectAttributeTest() throws Exception {
    UpdateProjectRQ rq = new UpdateProjectRQ();
    ProjectConfigurationUpdate configuration = new ProjectConfigurationUpdate();
    HashMap<String, String> projectAttributes = new HashMap<>();
    projectAttributes.put("incorrect", "false");
    projectAttributes.put("job.keepLogs", "2 weeks");
    configuration.setProjectAttributes(projectAttributes);
    rq.setConfiguration(configuration);
    HashMap<String, String> userRoles = new HashMap<>();
    userRoles.put("test_user", "PROJECT_MANAGER");
    rq.setUserRoles(userRoles);
    mockMvc.perform(put("/v1/project/test_project").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isBadRequest());
}
Also used : ProjectConfigurationUpdate(com.epam.ta.reportportal.ws.model.project.config.ProjectConfigurationUpdate) UpdateProjectRQ(com.epam.ta.reportportal.ws.model.project.UpdateProjectRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 4 with UpdateProjectRQ

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

the class ProjectControllerTest method updateProjectConfigKeepLaunchesNegativeTest.

@Test
void updateProjectConfigKeepLaunchesNegativeTest() throws Exception {
    UpdateProjectRQ rq = new UpdateProjectRQ();
    ProjectConfigurationUpdate configuration = new ProjectConfigurationUpdate();
    HashMap<String, String> projectAttributes = new HashMap<>();
    projectAttributes.put("notifications.enabled", "false");
    projectAttributes.put("job.keepLaunches", "110000f");
    configuration.setProjectAttributes(projectAttributes);
    rq.setConfiguration(configuration);
    HashMap<String, String> userRoles = new HashMap<>();
    userRoles.put("test_user", "PROJECT_MANAGER");
    rq.setUserRoles(userRoles);
    mockMvc.perform(put("/v1/project/test_project").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isBadRequest());
}
Also used : ProjectConfigurationUpdate(com.epam.ta.reportportal.ws.model.project.config.ProjectConfigurationUpdate) UpdateProjectRQ(com.epam.ta.reportportal.ws.model.project.UpdateProjectRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 5 with UpdateProjectRQ

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

the class ProjectControllerTest method updateProjectConfigurationNullValueTest.

@Test
void updateProjectConfigurationNullValueTest() throws Exception {
    UpdateProjectRQ rq = new UpdateProjectRQ();
    ProjectConfigurationUpdate configuration = new ProjectConfigurationUpdate();
    HashMap<String, String> projectAttributes = new HashMap<>();
    projectAttributes.put("job.keepLogs", null);
    configuration.setProjectAttributes(projectAttributes);
    rq.setConfiguration(configuration);
    HashMap<String, String> userRoles = new HashMap<>();
    userRoles.put("test_user", "PROJECT_MANAGER");
    rq.setUserRoles(userRoles);
    mockMvc.perform(put("/v1/project/test_project").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isBadRequest());
}
Also used : ProjectConfigurationUpdate(com.epam.ta.reportportal.ws.model.project.config.ProjectConfigurationUpdate) UpdateProjectRQ(com.epam.ta.reportportal.ws.model.project.UpdateProjectRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)8 UpdateProjectRQ (com.epam.ta.reportportal.ws.model.project.UpdateProjectRQ)8 ProjectConfigurationUpdate (com.epam.ta.reportportal.ws.model.project.config.ProjectConfigurationUpdate)8 Test (org.junit.jupiter.api.Test)8 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ProjectAttribute (com.epam.ta.reportportal.entity.project.ProjectAttribute)1 DeleteBulkRQ (com.epam.ta.reportportal.ws.model.DeleteBulkRQ)1 ItemAttributeResource (com.epam.ta.reportportal.ws.model.attribute.ItemAttributeResource)1 AssignUsersRQ (com.epam.ta.reportportal.ws.model.project.AssignUsersRQ)1 CreateProjectRQ (com.epam.ta.reportportal.ws.model.project.CreateProjectRQ)1 UnassignUsersRQ (com.epam.ta.reportportal.ws.model.project.UnassignUsersRQ)1 ProjectNotificationConfigDTO (com.epam.ta.reportportal.ws.model.project.email.ProjectNotificationConfigDTO)1 SenderCaseDTO (com.epam.ta.reportportal.ws.model.project.email.SenderCaseDTO)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 Client (com.rabbitmq.http.client.Client)1 ExchangeInfo (com.rabbitmq.http.client.domain.ExchangeInfo)1 java.util (java.util)1