Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static final EntityType WORK_FLOW_ENTITY_TYPE = //Assigned
- public WorkflowRequest getWFRequestFromHerdInput(HerdInput herdInput) throws
- NonRetriableException {
- ActionRequest request = CoralHerdUtils.getRequestData(herdInput);
- Document document = request.getHerdDocument();
- List<Entity> entityList = document.getEntitiesByType(WORK_FLOW_ENTITY_TYPE);
- Entity entity = entityList.get(0);
- WorkflowRequest workflowRequest = null;
- try {
- workflowRequest = (WorkflowRequest) entity.asCommonsObject();
- } catch (DocumentException e) {
- throw new NonRetriableException("Object cannot be converted to WorkflowRequest");
- }
- return workflowRequest;
- }
- @Test(expected = NonRetriableException.class)
- public void test_GetWFRequestFromHerdInput_fail() throws NonRetriableException, DocumentException {
- prepareForGetWFRequestFromHerdInput();
- Entity entity = Mockito.mock(Entity.class);
- Mockito.when(entity.asCodigoObject()).thenThrow(DocumentException.class);
- WorkflowRequest workflowRequestReturned = herdDocumentHelper.getWFRequestFromHerdInput(herdInput);
- Assert.assertEquals(EXPECTED_DAG_ID, workflowRequestReturned.getDagId());
- }
Add Comment
Please, Sign In to add comment