Search in sources :

Example 26 with StartLaunchRQ

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

the class LaunchControllerValidationTest method createLaunchShouldReturnErrorWhenNameConsistsOfWhitespaces.

@Test
public void createLaunchShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
    // GIVEN
    StartLaunchRQ startLaunchRQ = prepareLaunch();
    startLaunchRQ.setName(WHITESPACES_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_IS_BLANK_MESSAGE + " " + FIELD_NAME_SIZE_MESSAGE + "] ", error.getMessage());
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) 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 27 with StartLaunchRQ

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

the class LaunchBuilderTest method addStartRqTest.

@Test
void addStartRqTest() {
    final StartLaunchRQ request = new StartLaunchRQ();
    final String uuid = "uuid";
    request.setUuid(uuid);
    request.setMode(Mode.DEFAULT);
    final String description = "description";
    request.setDescription(description);
    final String name = "name";
    request.setName(name);
    final LocalDateTime now = LocalDateTime.now().truncatedTo(ChronoUnit.MILLIS);
    request.setStartTime(TO_DATE.apply(now));
    request.setAttributes(Sets.newHashSet(new ItemAttributesRQ("key", "value")));
    final Launch launch = new LaunchBuilder().addStartRQ(request).addAttributes(request.getAttributes()).get();
    assertEquals(name, launch.getName());
    assertEquals(uuid, launch.getUuid());
    assertEquals(description, launch.getDescription());
    assertEquals(now, launch.getStartTime());
    assertTrue(launch.getAttributes().contains(new ItemAttribute("key", "value", false)));
    assertEquals(LaunchModeEnum.DEFAULT, launch.getMode());
}
Also used : LocalDateTime(java.time.LocalDateTime) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ItemAttributesRQ(com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ) ItemAttribute(com.epam.ta.reportportal.entity.ItemAttribute) Launch(com.epam.ta.reportportal.entity.launch.Launch) Test(org.junit.jupiter.api.Test)

Example 28 with StartLaunchRQ

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

the class JaskonRequiredPropertiesValidatorTest method testRequiredFields.

@Test
public void testRequiredFields() {
    StartLaunchRQ startLaunchRQ = new StartLaunchRQ();
    startLaunchRQ.setDescription("some description");
    startLaunchRQ.setName("some launch name");
    startLaunchRQ.setAttributes(Collections.emptySet());
    JaskonRequiredPropertiesValidator validator = new JaskonRequiredPropertiesValidator();
    Errors errors = new BeanPropertyBindingResult(startLaunchRQ, "startLaunchRq");
    validator.validate(startLaunchRQ, errors);
    assertThat(errors.getAllErrors(), not(empty()));
    assertThat(errors.getFieldError("startTime"), not(nullValue()));
}
Also used : Errors(org.springframework.validation.Errors) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) Test(org.junit.jupiter.api.Test)

Example 29 with StartLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project agent-java-testNG by reportportal.

the class BuildTestTest method testStartLaunchRq_EmptyDescription.

@Test
public void testStartLaunchRq_EmptyDescription() {
    ListenerParameters parameters = new ListenerParameters();
    parameters.setDescription("");
    StartLaunchRQ startLaunchRQ = testNGService.buildStartLaunchRq(parameters);
    assertThat("Description should be null", startLaunchRQ.getDescription(), nullValue());
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Test(org.junit.jupiter.api.Test)

Example 30 with StartLaunchRQ

use of com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ in project agent-java-testNG by reportportal.

the class BuildTestTest method testStartLaunchRq.

@Test
public void testStartLaunchRq() {
    ListenerParameters listenerParameters = defaultListenerParameters();
    StartLaunchRQ startLaunchRQ = testNGService.buildStartLaunchRq(listenerParameters);
    assertThat("Incorrect launch name", startLaunchRQ.getName(), is(DEFAULT_NAME));
    assertThat("Incorrect start time", startLaunchRQ.getStartTime(), notNullValue());
    assertThat("Incorrect launch tags", startLaunchRQ.getAttributes(), hasItem(ATTRIBUTE));
    assertThat("Incorrect launch mode", startLaunchRQ.getMode(), is(MODE));
    assertThat("Incorrect description", startLaunchRQ.getDescription(), is(DEFAULT_DESCRIPTION));
}
Also used : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) ListenerParameters(com.epam.reportportal.listeners.ListenerParameters) Test(org.junit.jupiter.api.Test)

Aggregations

StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)35 Test (org.junit.jupiter.api.Test)20 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)10 ItemAttributesRQ (com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ)9 ListenerParameters (com.epam.reportportal.listeners.ListenerParameters)7 Launch (com.epam.ta.reportportal.entity.launch.Launch)7 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)6 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)5 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)4 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)4 MvcResult (org.springframework.test.web.servlet.MvcResult)4 LaunchBuilder (com.epam.ta.reportportal.ws.converter.builders.LaunchBuilder)3 Date (java.util.Date)3 ApplicationEventPublisher (org.springframework.context.ApplicationEventPublisher)3 ReportPortal (com.epam.reportportal.service.ReportPortal)2 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)2 IdentityUtil (com.epam.ta.reportportal.core.item.identity.IdentityUtil)2 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)2 TestItem (com.epam.ta.reportportal.entity.item.TestItem)2 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)2