Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.34 KB | None | 0 0
  1. package hr.inceptum.fsm.rest;
  2.  
  3. import static org.junit.jupiter.api.Assertions.assertEquals;
  4. import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
  5. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
  6.  
  7. import java.sql.SQLException;
  8. import java.time.Duration;
  9. import java.time.Instant;
  10. import java.util.List;
  11. import java.util.Map;
  12. import java.util.Set;
  13. import java.util.UUID;
  14.  
  15. import javax.transaction.Transactional;
  16.  
  17. import org.junit.jupiter.api.BeforeEach;
  18. import org.junit.jupiter.api.DisplayName;
  19. import org.junit.jupiter.api.Test;
  20. import org.mockito.MockitoAnnotations;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.boot.test.context.SpringBootTest;
  23. import org.springframework.boot.test.mock.mockito.MockBean;
  24. import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
  25. import org.springframework.test.util.ReflectionTestUtils;
  26. import org.springframework.test.web.servlet.MockMvc;
  27. import org.springframework.test.web.servlet.MvcResult;
  28. import org.springframework.test.web.servlet.setup.MockMvcBuilders;
  29.  
  30. import com.fasterxml.jackson.core.type.TypeReference;
  31.  
  32. import hr.inceptum.addressbook.AddressBookRestServices;
  33. import hr.inceptum.addressbook.customer.Customer;
  34. import hr.inceptum.addressbook.location.Location;
  35. import hr.inceptum.fsm.dto.workorder.WorkOrderListItemDto;
  36. import hr.inceptum.fsm.entity.workorder.PreferredTime;
  37. import hr.inceptum.fsm.entity.workorder.Priority;
  38. import hr.inceptum.fsm.entity.workorder.WorkOrder;
  39. import hr.inceptum.fsm.entity.workorder.WorkOrderStatus;
  40. import hr.inceptum.fsm.entity.workorder.WorkOrderType;
  41. import hr.inceptum.fsm.service.workorder.WorkOrderService;
  42. import hr.inceptum.hive.commons.dao.EntityDao;
  43. import hr.inceptum.hive.commons.entity.AbstractPersistable;
  44. import hr.inceptum.hive.commons.entity.Tenant;
  45. import hr.inceptum.hive.commons.rest.RestExceptionsAdvice;
  46. import hr.inceptum.hive.commons.search.model.CompositeCriterion;
  47. import hr.inceptum.hive.commons.search.model.CompositionType;
  48. import hr.inceptum.hive.commons.search.model.Criterion;
  49. import hr.inceptum.hive.commons.search.model.CriterionType;
  50. import hr.inceptum.hive.commons.search.model.SearchCriteria;
  51. import hr.inceptum.hive.commons.search.model.SearchResult;
  52. import hr.inceptum.hive.commons.search.model.SimpleCriterion;
  53. import hr.inceptum.hive.commons.search.model.SortType;
  54. import hr.inceptum.hive.commons.search.model.Window;
  55. import hr.inceptum.hive.commons.service.EntityService;
  56. import hr.inceptum.hive.commons.support.WithMockHiveUser;
  57. import hr.inceptum.hive.commons.tenant.TenantStorage;
  58. import hr.inceptum.hive.commons.util.JsonParserUtil;
  59.  
  60. @SpringBootTest
  61. @Transactional
  62. @SuppressWarnings({ "PMD.TooManyFields", "PMD.AvoidDuplicateLiterals", "PMD.UnusedPrivateField" })
  63. class WorkOrderGetAllControllerTest {
  64.  
  65. private static final String BASE_URL = WorkOrderController.URL + "/list";
  66. // private static final String BASE_URL_SCHEDULER = SchedulerTimelineController.URL + "/";
  67.  
  68. private static final String TIME_FIELD = "time";
  69. private static final String STATUS_FIELD = "status";
  70. private static final Instant WINDOW_FROM = Instant.parse("2019-05-02T00:00:00.00Z");
  71. private static final Instant WINDOW_TO = Instant.parse("2019-05-03T00:00:00.00Z");
  72. private static final Instant BEFORE = Instant.parse("2019-05-01T00:00:00.00Z");
  73. private static final Instant INSIDE = Instant.parse("2019-05-02T12:00:00.00Z");
  74. private static final Instant AFTER = Instant.parse("2019-05-04T00:00:00.00Z");
  75.  
  76. @MockBean
  77. private AddressBookRestServices addressBookRestServices;
  78.  
  79. @Autowired
  80. private WorkOrderController workOrderController;
  81.  
  82. @Autowired
  83. private EntityService<Tenant> tenantService;
  84.  
  85. @Autowired
  86. private EntityService<WorkOrderType> workOrderTypeService;
  87.  
  88. @Autowired
  89. private EntityService<Customer> customerService;
  90.  
  91. @Autowired
  92. private EntityService<Location> locationService;
  93.  
  94. @Autowired
  95. private EntityDao<AbstractPersistable> entityDao;
  96.  
  97. @Autowired
  98. private WorkOrderService workOrderService;
  99.  
  100. @Autowired
  101. private MappingJackson2HttpMessageConverter messageConverter;
  102.  
  103. @Autowired
  104. private RestExceptionsAdvice exceptionsAdvice;
  105.  
  106. private WorkOrderType createdWorkOrderType;
  107. private Customer createdCustomer;
  108. private Location createdLocation;
  109.  
  110. private WorkOrder unassignedEmpty;
  111. private WorkOrder unassignedInside;
  112. private WorkOrder unassignedInsideMulti;
  113. private WorkOrder unassignedBefore;
  114. private WorkOrder unassignedAfter;
  115. private WorkOrder assignedBefore;
  116. private WorkOrder assignedBeforePreferred;
  117. private WorkOrder assignedInsideMulti;
  118. private WorkOrder assignedInsidePreferred;
  119. private WorkOrder assignedAfterPreferred;
  120. private WorkOrder canceledEmpty;
  121.  
  122. private MockMvc mockMvc;
  123.  
  124. @SuppressWarnings("CPD-START")
  125. @BeforeEach
  126. public void setUp() throws SQLException {
  127.  
  128. // WorkOrder assignedBefore;
  129. // WorkOrder assignedBeforePreferred;
  130. // WorkOrder assignedAfterPreferred;
  131.  
  132. MockitoAnnotations.initMocks(this);
  133. // @formatter:off
  134. mockMvc = MockMvcBuilders.standaloneSetup(workOrderController)
  135. .setControllerAdvice(exceptionsAdvice)
  136. .setMessageConverters(messageConverter).build();
  137. // @formatter:on
  138.  
  139. createTenant();
  140. createdWorkOrderType = createWorkOrderType();
  141. createdCustomer = createCutomer();
  142. createdLocation = createLocation();
  143.  
  144. entityDao.flush();
  145.  
  146. unassignedEmpty = createWorkOrder("12341243", WorkOrderStatus.UNASSIGNED, null, Set.of());
  147. unassignedInside = createWorkOrder("12341244", WorkOrderStatus.UNASSIGNED, null, Set.of(new PreferredTime(INSIDE, AFTER)));
  148. unassignedInsideMulti = createWorkOrder("12341245", WorkOrderStatus.UNASSIGNED, null,
  149. Set.of(new PreferredTime(BEFORE, INSIDE), new PreferredTime(INSIDE, WINDOW_TO), new PreferredTime(AFTER, AFTER)));
  150. unassignedBefore = createWorkOrder("12341246", WorkOrderStatus.UNASSIGNED, null, Set.of(new PreferredTime(BEFORE, BEFORE)));
  151. unassignedAfter = createWorkOrder("12341247", WorkOrderStatus.UNASSIGNED, null, Set.of(new PreferredTime(AFTER, AFTER)));
  152.  
  153. assignedBefore = createWorkOrder("12341248", WorkOrderStatus.ASSIGNED, BEFORE, Set.of());
  154. assignedBeforePreferred = createWorkOrder("12341249", WorkOrderStatus.ASSIGNED, BEFORE, Set.of(new PreferredTime(INSIDE, AFTER)));
  155. assignedInsideMulti = createWorkOrder("12341250", WorkOrderStatus.ASSIGNED, INSIDE,
  156. Set.of(new PreferredTime(BEFORE, INSIDE), new PreferredTime(INSIDE, WINDOW_TO), new PreferredTime(AFTER, AFTER)));
  157. assignedInsidePreferred = createWorkOrder("12341251", WorkOrderStatus.ASSIGNED, INSIDE, Set.of(new PreferredTime(BEFORE, BEFORE)));
  158. assignedAfterPreferred = createWorkOrder("12341252", WorkOrderStatus.ASSIGNED, AFTER, Set.of(new PreferredTime(INSIDE, AFTER)));
  159.  
  160. canceledEmpty = createWorkOrder("12341253", WorkOrderStatus.CANCELED, null, Set.of());
  161.  
  162. entityDao.flush();
  163. }
  164.  
  165. private void createTenant() {
  166. Tenant tenant = new Tenant();
  167. ReflectionTestUtils.setField(tenant, "id", UUID.randomUUID());
  168. tenant.setName("Inceptum");
  169. tenant = tenantService.create(tenant);
  170. TenantStorage.setTenant(tenant);
  171. }
  172.  
  173. private WorkOrderType createWorkOrderType() {
  174. final WorkOrderType workOrderType = new WorkOrderType();
  175. workOrderType.setName("WorkOrderTestType");
  176. workOrderType.setEstimatedDuration(Duration.ofHours(2L));
  177. return workOrderTypeService.create(workOrderType);
  178. }
  179.  
  180. private Customer createCutomer() {
  181. final Customer customer = new Customer();
  182. customer.setId(UUID.randomUUID());
  183. return customerService.create(customer);
  184. }
  185.  
  186. private Location createLocation() {
  187. final Location location = new Location();
  188. location.setId(UUID.randomUUID());
  189. return locationService.create(location);
  190. }
  191.  
  192. private WorkOrder createWorkOrder(final String referenceId, final WorkOrderStatus status, final Instant scheduled, final Set<PreferredTime> preferredTimes) {
  193.  
  194. final WorkOrder workOrder = new WorkOrder();
  195. workOrder.setReferenceId(referenceId);
  196. workOrder.setCardinalNumber(workOrderService.getCount(WorkOrder.class) + 1);
  197. workOrder.setCustomer(createdCustomer);
  198. workOrder.setLocation(createdLocation);
  199. workOrder.setPriority(Priority.NORMAL);
  200. workOrder.setStatus(WorkOrderStatus.ASSIGNED);
  201. workOrder.setWorkOrderType(createdWorkOrderType);
  202. workOrder.setScheduled(scheduled);
  203. workOrder.setDuration(Duration.ofHours(2L));
  204. // workOrder.setWorkers(workers);
  205. workOrder.setPreferredTimes(preferredTimes);
  206. workOrder.setStatus(status);
  207.  
  208. // final WorkOrder created = workOrderService.create(workOrder);
  209.  
  210. // workOrderStatusHistoryService.create(new WorkOrderStatusHistory(created, WorkOrderAction.CREATE,
  211. // null, workers.iterator().next()));
  212.  
  213. return workOrderService.create(workOrder);
  214. // return created;
  215. }
  216.  
  217. @Test
  218. @WithMockHiveUser(authorities = { "WORK_ORDER_EDIT" })
  219. @DisplayName("Test for getting full list")
  220.  
  221. public void testGetAll() throws Exception {
  222.  
  223. final SearchCriteria searchCriteria = new SearchCriteria();
  224. // final SearchResult<WorkOrder> result = workOrderDao.getList(searchCriteria);
  225.  
  226. // @formatter:off
  227. final MvcResult result = mockMvc.perform(post(BASE_URL)
  228. .contentType(SearchCriteria.CONTENT_TYPE)
  229. .content(JsonParserUtil.asJsonString(searchCriteria))
  230. .accept(WorkOrderListItemDto.CONTENT_TYPE))
  231. .andExpect(status().isOk())
  232. .andReturn();
  233. // @formatter:on
  234.  
  235. final SearchResult<WorkOrderListItemDto> received = JsonParserUtil.readFromJson(result.getResponse().getContentAsString(), new TypeReference<SearchResult<WorkOrderListItemDto>>() {
  236. });
  237.  
  238. // final WorkOrder entity = workOrderMapper.newEntity(received);
  239. // final WorkOrder entity = workOrderListItemMapper.newEntity(received.getResults().get(0));
  240.  
  241. assertEquals(11, received.getTotalResults().longValue(), "Should have all 11 created work orders");
  242. assertEquals(11, received.getResults().size(), "Should contain all 11 results");
  243.  
  244. // all unassigned work orders in front, ordered by min preferred time, with null last.
  245. // same times are ordered by creation order
  246. assertEquals(unassignedInsideMulti.getId(), received.getResults().get(0).getId(), "1st result should be unassignedInsideMulti work order");
  247. assertEquals(unassignedBefore.getId(), received.getResults().get(1).getId(), "2nd result should beunassignedBefore work order");
  248. assertEquals(unassignedInside.getId(), received.getResults().get(2).getId(), "3rd result should beunassignedInside work order");
  249. assertEquals(unassignedAfter.getId(), received.getResults().get(3).getId(), "4th result should beunassignedAfter work order");
  250. assertEquals(unassignedEmpty.getId(), received.getResults().get(4).getId(), "5th result should beunassignedEmpty work order");
  251.  
  252. // then all other statuses ordered by min preferred time, with null last.
  253. // same times are ordered by creation order
  254. assertEquals(assignedBefore.getId(), received.getResults().get(5).getId(), "6th result should be assignedBefore work order");
  255. assertEquals(assignedBeforePreferred.getId(), received.getResults().get(6).getId(), "7th result should be assignedBeforePreferred work order");
  256. assertEquals(assignedInsideMulti.getId(), received.getResults().get(7).getId(), "8th result should be assignedInsideMulti work order");
  257. assertEquals(assignedInsidePreferred.getId(), received.getResults().get(8).getId(), "9th result should be assignedInsidePreferred work order");
  258. assertEquals(assignedAfterPreferred.getId(), received.getResults().get(9).getId(), "10th result should be assignedAfterPreferred work order");
  259. assertEquals(canceledEmpty.getId(), received.getResults().get(10).getId(), "11th result should be canceledEmpty work order");
  260. }
  261.  
  262. @Test
  263. @WithMockHiveUser(authorities = { "WORK_ORDER_EDIT" })
  264. @DisplayName("Test for getting Windowed list")
  265. public void testWindowedList() throws Exception {
  266.  
  267. final SearchCriteria searchCriteria = new SearchCriteria();
  268. searchCriteria.setWindow(new Window(0, 5));
  269.  
  270. // final SearchResult<WorkOrder> result = workOrderDao.getList(searchCriteria);
  271.  
  272. // @formatter:off
  273. final MvcResult result = mockMvc.perform(post(BASE_URL)
  274. .contentType(SearchCriteria.CONTENT_TYPE)
  275. .content(JsonParserUtil.asJsonString(searchCriteria))
  276. .accept(WorkOrderListItemDto.CONTENT_TYPE))
  277. .andExpect(status().isOk())
  278. .andReturn();
  279. // @formatter:on
  280.  
  281. final SearchResult<WorkOrderListItemDto> received = JsonParserUtil.readFromJson(result.getResponse().getContentAsString(), new TypeReference<SearchResult<WorkOrderListItemDto>>() {
  282. });
  283.  
  284. assertEquals(11, received.getTotalResults().longValue(), "Should have all 11 created work orders");
  285. assertEquals(5, received.getResults().size(), "Should be limited to 5 work orders");
  286.  
  287. assertEquals(unassignedInsideMulti.getId(), received.getResults().get(0).getId(), "1st result should be unassignedInsideMulti work order");
  288. assertEquals(unassignedBefore.getId(), received.getResults().get(1).getId(), "2nd result should be unassignedBefore work order");
  289. assertEquals(unassignedInside.getId(), received.getResults().get(2).getId(), "3rd result should be unassignedInside work order");
  290. assertEquals(unassignedAfter.getId(), received.getResults().get(3).getId(), "4th result should be unassignedAfter work order");
  291. assertEquals(unassignedEmpty.getId(), received.getResults().get(4).getId(), "5th result should be unassignedEmpty work order");
  292.  
  293. }
  294.  
  295. @Test
  296. @WithMockHiveUser(authorities = { "WORK_ORDER_EDIT" })
  297. @DisplayName("Test for getting filtered list")
  298. public void testFilteredList() throws Exception {
  299. final SearchCriteria searchCriteria = new SearchCriteria();
  300. searchCriteria.setCriterion(new SimpleCriterion(STATUS_FIELD, WorkOrderStatus.CANCELED, CriterionType.EQUAL));
  301.  
  302. // @formatter:off
  303. final MvcResult result = mockMvc.perform(post(BASE_URL)
  304. .contentType(SearchCriteria.CONTENT_TYPE)
  305. .content(JsonParserUtil.asJsonString(searchCriteria))
  306. .accept(WorkOrderListItemDto.CONTENT_TYPE))
  307. .andExpect(status().isOk())
  308. .andReturn();
  309. // @formatter:on
  310.  
  311. final SearchResult<WorkOrderListItemDto> received = JsonParserUtil.readFromJson(result.getResponse().getContentAsString(), new TypeReference<SearchResult<WorkOrderListItemDto>>() {
  312. });
  313.  
  314. // final SearchResult<WorkOrder> result = workOrderDao.getList(searchCriteria);
  315. assertEquals(1, received.getTotalResults().longValue(), "Should have only one canceled work order");
  316. assertEquals(1, received.getResults().size(), "Should have only one canceled work order");
  317. assertEquals(canceledEmpty.getId(), received.getResults().get(0).getId(), "Only result should be canceled work order");
  318. }
  319.  
  320. @Test
  321. @WithMockHiveUser(authorities = { "WORK_ORDER_EDIT" })
  322. @DisplayName("Test for getting full scheduler")
  323. public void testFullScheduler() throws Exception {
  324. final SearchCriteria searchCriteria = new SearchCriteria();
  325.  
  326. final Criterion timeGreater = new SimpleCriterion(TIME_FIELD, WINDOW_FROM, CriterionType.GREATER_EQUAL);
  327. final Criterion timeLess = new SimpleCriterion(TIME_FIELD, WINDOW_TO, CriterionType.LESS);
  328. final Criterion status = new SimpleCriterion(STATUS_FIELD, WorkOrderStatus.CANCELED, CriterionType.NOT_EQUAL);
  329.  
  330. searchCriteria.setCriterion(new CompositeCriterion(CompositionType.AND, List.of(timeGreater, timeLess, status)));
  331.  
  332. // final SearchResult<WorkOrder> result = workOrderDao.getList(searchCriteria);
  333.  
  334. // @formatter:off
  335. final MvcResult result = mockMvc.perform(post(BASE_URL)
  336. .contentType(SearchCriteria.CONTENT_TYPE)
  337. .content(JsonParserUtil.asJsonString(searchCriteria))
  338. .accept(WorkOrderListItemDto.CONTENT_TYPE))
  339. .andExpect(status().isOk())
  340. .andReturn();
  341. // @formatter:on
  342.  
  343. final SearchResult<WorkOrderListItemDto> received = JsonParserUtil.readFromJson(result.getResponse().getContentAsString(), new TypeReference<SearchResult<WorkOrderListItemDto>>() {
  344. });
  345.  
  346. assertEquals(5, received.getTotalResults().longValue(), "Should have 5 of created work orders in window");
  347. assertEquals(5, received.getResults().size(), "Should have 5 of created work orders in window");
  348.  
  349. // all unassigned work orders in front, ordered by min preferred time, with null last.
  350. // same times are ordered by creation order
  351. assertEquals(unassignedInsideMulti.getId(), received.getResults().get(0).getId(), "1st result should be unassignedInsideMulti work order");
  352. assertEquals(unassignedInside.getId(), received.getResults().get(1).getId(), "2nd result should be unassignedInside work order");
  353. assertEquals(unassignedEmpty.getId(), received.getResults().get(2).getId(), "3rd result should be unassignedEmpty work order");
  354.  
  355. // then all other statuses ordered by min preferred time, with null last.
  356. // same times are ordered by creation order
  357. assertEquals(assignedInsideMulti.getId(), received.getResults().get(3).getId(), "4th result should be assignedInsideMulti work order");
  358. assertEquals(assignedInsidePreferred.getId(), received.getResults().get(4).getId(), "5th result should be assignedInsidePreferred work order");
  359.  
  360. }
  361.  
  362. @Test
  363. @WithMockHiveUser(authorities = { "WORK_ORDER_EDIT" })
  364. @DisplayName("Test for getting filtered scheduler")
  365. public void testFilteredScheduler() throws Exception {
  366. final SearchCriteria searchCriteria = new SearchCriteria();
  367.  
  368. final Criterion timeGreater = new SimpleCriterion(TIME_FIELD, WINDOW_FROM, CriterionType.GREATER_EQUAL);
  369. final Criterion timeLess = new SimpleCriterion(TIME_FIELD, WINDOW_TO, CriterionType.LESS);
  370. final Criterion status = new SimpleCriterion(STATUS_FIELD, WorkOrderStatus.CANCELED, CriterionType.NOT_EQUAL);
  371.  
  372. final Criterion schedulerCriterion = new CompositeCriterion(CompositionType.AND, List.of(timeGreater, timeLess, status));
  373.  
  374. final Criterion custom = new SimpleCriterion(STATUS_FIELD, WorkOrderStatus.ASSIGNED, CriterionType.EQUAL);
  375. searchCriteria.setCriterion(new CompositeCriterion(CompositionType.AND, List.of(schedulerCriterion, custom)));
  376.  
  377. // final SearchResult<WorkOrder> result = workOrderDao.getList(searchCriteria);
  378.  
  379. // @formatter:off
  380. final MvcResult result = mockMvc.perform(post(BASE_URL)
  381. .contentType(SearchCriteria.CONTENT_TYPE)
  382. .content(JsonParserUtil.asJsonString(searchCriteria))
  383. .accept(WorkOrderListItemDto.CONTENT_TYPE))
  384. .andExpect(status().isOk())
  385. .andReturn();
  386. // @formatter:on
  387.  
  388. final SearchResult<WorkOrderListItemDto> received = JsonParserUtil.readFromJson(result.getResponse().getContentAsString(), new TypeReference<SearchResult<WorkOrderListItemDto>>() {
  389. });
  390. assertEquals(2, received.getTotalResults().longValue(), "Should have 2 of created work orders in window");
  391. assertEquals(2, received.getResults().size(), "Should have 2 of created work orders in window");
  392.  
  393. // then all other statuses ordered by min preferred time, with null last.
  394. // same times are ordered by creation order
  395. assertEquals(assignedInsideMulti.getId(), received.getResults().get(0).getId(), "1st result should be assignedInsideMulti work order");
  396. assertEquals(assignedInsidePreferred.getId(), received.getResults().get(1).getId(), "2nd result should be assignedInsidePreferred work order");
  397.  
  398. }
  399.  
  400. @Test
  401. @WithMockHiveUser(authorities = { "WORK_ORDER_EDIT" })
  402. @SuppressWarnings("CPD-END")
  403. @DisplayName("Test for getting sorted scheduler")
  404. public void testSortedScheduler() throws Exception {
  405. final SearchCriteria searchCriteria = new SearchCriteria();
  406.  
  407. final Criterion timeGreater = new SimpleCriterion(TIME_FIELD, WINDOW_FROM, CriterionType.GREATER_EQUAL);
  408. final Criterion timeLess = new SimpleCriterion(TIME_FIELD, WINDOW_TO, CriterionType.LESS);
  409. final Criterion status = new SimpleCriterion(STATUS_FIELD, WorkOrderStatus.CANCELED, CriterionType.NOT_EQUAL);
  410.  
  411. searchCriteria.setCriterion(new CompositeCriterion(CompositionType.AND, List.of(timeGreater, timeLess, status)));
  412.  
  413. searchCriteria.setSortProperties(Map.of(TIME_FIELD, SortType.DESC));
  414.  
  415. // final SearchResult<WorkOrder> result = workOrderDao.getList(searchCriteria);
  416.  
  417. // @formatter:off
  418. final MvcResult result = mockMvc.perform(post(BASE_URL )
  419. .contentType(SearchCriteria.CONTENT_TYPE)
  420. .content(JsonParserUtil.asJsonString(searchCriteria))
  421. .accept(WorkOrderListItemDto.CONTENT_TYPE))
  422. .andExpect(status().isOk())
  423. .andReturn();
  424. // @formatter:on
  425.  
  426. final SearchResult<WorkOrderListItemDto> received = JsonParserUtil.readFromJson(result.getResponse().getContentAsString(), new TypeReference<SearchResult<WorkOrderListItemDto>>() {
  427. });
  428.  
  429. assertEquals(5, received.getTotalResults().longValue(), "Should have 5 of created work orders in scheduler");
  430. assertEquals(5, received.getResults().size(), "Should have 5 of created work orders in scheduler");
  431.  
  432. // first ordered by time desc and then by other default filters. with null values on end.
  433. assertEquals(unassignedInside.getId(), received.getResults().get(0).getId(), "1st result should be unassignedInside work order");
  434. assertEquals(assignedInsideMulti.getId(), received.getResults().get(1).getId(), "2nd result should be assignedInsideMulti work order");
  435. assertEquals(assignedInsidePreferred.getId(), received.getResults().get(2).getId(), "3rd result should be assignedInsidePreferred work order");
  436. assertEquals(unassignedInsideMulti.getId(), received.getResults().get(3).getId(), "4th result should be unassignedInsideMulti work order");
  437. assertEquals(unassignedEmpty.getId(), received.getResults().get(4).getId(), "5th result should be unassignedEmpty work order");
  438.  
  439. }
  440.  
  441. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement