use of com.epam.ta.reportportal.core.item.impl.UpdateTestItemHandlerImpl.INITIAL_STATUS_ATTRIBUTE_KEY in project service-api by reportportal.
the class UpdateTestItemHandlerImplTest method shouldNotCreateInitialStatusAttribute.
@Test
void shouldNotCreateInitialStatusAttribute() {
ReportPortalUser user = getRpUser("user", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
UpdateTestItemRQ rq = new UpdateTestItemRQ();
rq.setStatus("PASSED");
long itemId = 1L;
TestItem item = new TestItem();
item.setItemId(itemId);
item.setHasChildren(false);
item.setType(TestItemTypeEnum.STEP);
item.setAttributes(Sets.newHashSet(new ItemAttribute(INITIAL_STATUS_ATTRIBUTE_KEY, "passed", true)));
TestItemResults itemResults = new TestItemResults();
itemResults.setStatus(StatusEnum.FAILED);
item.setItemResults(itemResults);
Launch launch = new Launch();
launch.setId(2L);
item.setLaunchId(launch.getId());
when(testItemService.getEffectiveLaunch(item)).thenReturn(launch);
when(itemRepository.findById(itemId)).thenReturn(Optional.of(item));
doNothing().when(messageBus).publishActivity(any());
when(statusChangingStrategyMapping.get(StatusEnum.PASSED)).thenReturn(statusChangingStrategy);
doNothing().when(statusChangingStrategy).changeStatus(item, StatusEnum.PASSED, user);
handler.updateTestItem(extractProjectDetails(user, "test_project"), itemId, rq, user);
assertTrue(item.getAttributes().stream().anyMatch(attribute -> INITIAL_STATUS_ATTRIBUTE_KEY.equalsIgnoreCase(attribute.getKey()) && StatusEnum.PASSED.getExecutionCounterField().equalsIgnoreCase("passed")));
}
Aggregations