@Test public void testGetAllUserWorkflowActionsWithAttachmentsWhenUnknownClass() { // given final String COMPOSED_TYPE_CODE = "unknownClass"; final List<WorkflowActionModel> actions = new ArrayList<WorkflowActionModel>(); actions.add(mock(WorkflowActionModel.class)); final ComposedTypeModel mockProductComposedType = mock(ComposedTypeModel.class); when(typeService.getComposedTypeForCode(COMPOSED_TYPE_CODE)) .thenThrow(new UnknownIdentifierException("")); when(typeService.getComposedTypeForClass(ProductModel.class)) .thenReturn(mockProductComposedType); when(workflowActionDao.findWorkflowActionsByStatusAndAttachmentType( Collections.singletonList(mockProductComposedType), Collections.singletonList(WorkflowActionStatus.IN_PROGRESS))) .thenReturn(actions); final List<String> attachmentTypes = new ArrayList<String>(); attachmentTypes.add(COMPOSED_TYPE_CODE); // when final List<WorkflowActionModel> endWorkflowActions = workflowActionService.getAllUserWorkflowActionsWithAttachments(attachmentTypes); // then assertThat(endWorkflowActions).isEmpty(); }
@Test public void testGetAllUserWorkflowActionsWithAttachmentForString() { // given final List<WorkflowActionModel> actions = new ArrayList<WorkflowActionModel>(); actions.add(mock(WorkflowActionModel.class)); final ComposedTypeModel mockProductComposedType = mock(ComposedTypeModel.class); when(mockProductComposedType.getJaloclass()).thenReturn(Product.class); when(typeService.getComposedTypeForCode(ProductModel._TYPECODE)) .thenReturn(mockProductComposedType); when(workflowActionDao.findWorkflowActionsByStatusAndAttachmentType( Collections.singletonList(mockProductComposedType), Collections.singletonList(WorkflowActionStatus.IN_PROGRESS))) .thenReturn(actions); // when final List<WorkflowActionModel> endWorkflowActions = workflowActionService.getAllUserWorkflowActionsWithAttachment(ProductModel._TYPECODE); // then assertThat(endWorkflowActions).isSameAs(actions); }