use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project service-api by reportportal.
the class LaunchControllerValidationTest method createLaunchShouldReturnErrorWhenNameIsEmpty.
@Test
public void createLaunchShouldReturnErrorWhenNameIsEmpty() throws Exception {
// GIVEN
StartLaunchRQ startLaunchRQ = prepareLaunch();
startLaunchRQ.setName(EMPTY);
// WHEN
MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + LAUNCH_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(startLaunchRQ)).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());
}
use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project service-api by reportportal.
the class LaunchControllerValidationTest method createLaunchShouldReturnErrorWhenNameIsGreaterThanTwoHundredAndFiftySixCharacters.
@Test
public void createLaunchShouldReturnErrorWhenNameIsGreaterThanTwoHundredAndFiftySixCharacters() throws Exception {
// GIVEN
StartLaunchRQ startLaunchRQ = prepareLaunch();
startLaunchRQ.setName(LONG_NAME_VALUE);
// WHEN
MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + LAUNCH_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(startLaunchRQ)).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());
}
use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project service-api by reportportal.
the class StartLaunchHandlerAsyncImplTest method starLaunch.
@Test
void starLaunch() {
StartLaunchRQ request = new StartLaunchRQ();
ReportPortalUser user = getRpUser("test", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
startLaunchHandlerAsync.startLaunch(user, user.getProjectDetails().get("test_project"), request);
verify(amqpTemplate).convertAndSend(any(), any(), any(), any());
verify(reportingQueueService).getReportingQueueKey(any());
}
use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project service-api by reportportal.
the class RerunHandlerImplTest method exceptionWhenLaunchIsNotStoredInDbByUuid.
@Test
void exceptionWhenLaunchIsNotStoredInDbByUuid() {
StartLaunchRQ request = new StartLaunchRQ();
String launchName = "launch";
String uuid = "uuid";
long projectId = 1L;
request.setRerun(true);
request.setRerunOf(uuid);
request.setName(launchName);
ReportPortalUser rpUser = getRpUser("test", UserRole.USER, ProjectRole.PROJECT_MANAGER, projectId);
when(launchRepository.findByUuid(uuid)).thenReturn(Optional.empty());
ReportPortalException exception = assertThrows(ReportPortalException.class, () -> rerunHandler.handleLaunch(request, projectId, rpUser));
assertEquals("Launch 'uuid' not found. Did you use correct Launch ID?", exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project service-api by reportportal.
the class DemoDataLaunchService method startLaunch.
@Transactional
public Launch startLaunch(String name, User user, ReportPortalUser.ProjectDetails projectDetails) {
StartLaunchRQ rq = new StartLaunchRQ();
rq.setMode(Mode.DEFAULT);
rq.setDescription(ContentUtils.getLaunchDescription());
LocalDateTime now = LocalDateTime.now();
rq.setName(name);
rq.setStartTime(Date.from(now.atZone(ZoneId.systemDefault()).toInstant()));
rq.setUuid(UUID.randomUUID().toString());
Set<ItemAttributesRQ> attributes = Sets.newHashSet(new ItemAttributesRQ("platform", platformValues[new Random().nextInt(platformValues.length)]), new ItemAttributesRQ(null, "demo"), new ItemAttributesRQ("build", "3." + now.getDayOfMonth() + "." + now.getHour() + "." + now.getMinute() + "." + now.getSecond()));
Launch launch = new LaunchBuilder().addStartRQ(rq).addAttributes(attributes).addProject(projectDetails.getProjectId()).get();
launch.setUserId(user.getId());
launchRepository.save(launch);
launchRepository.refresh(launch);
return launch;
}
Aggregations