@Test public void testNoMatch() throws Exception { FieldSet fieldSet = new DefaultFieldSet(OrgLineTokenizer.COL_NAMES, OrgLineTokenizer.COL_NAMES); orgData.setFieldSet(fieldSet); Mockito.when( organizationService.getMatch(org.mockito.Matchers.any(ServiceContext.class), org.mockito.Matchers.any(Org.class))).thenReturn(null); Map<String, String> asMap = orgData.getOrg().getAsMap(); OrgData matchedData = processor.process(orgData); Assert.assertTrue(matchedData.getOrg().getAsMap().equals(asMap)); }
@Override public OrgData process(OrgData input) throws Exception { ServiceContext context = getServiceContext(); List<ValidationError> errors = Lists.newArrayList(); if (StringUtils.isBlank(input.getOrg().getOrgTypeCode())) { ValidationError error = new ValidationError("orgTypeCode", "Organization Type", "The organization type is required."); errors.add(error); } if (StringUtils.isBlank(input.getOrg().getParentOrgCode())) { ValidationError error = new ValidationError("parentOrgCode", "Parent Organization", "The parent organization is required."); errors.add(error); } if (!errors.isEmpty()) { ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } Org match = organizationService.getMatch(context, input.getOrg()); if (match != null) { if (!match.getParentOrgLocalCode().equals(input.getOrg().getParentOrgLocalCode())) { String msg = messageSource.getMessage("validation.org.parent.not.same", new Object[] { input.getOrg().getParentOrgLocalCode(), match.getParentOrgLocalCode() }, Locale.getDefault()); errors.add(new ValidationError("parentOrgCode", "Parent Organization", msg)); ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } input.setOrg(match); return binder.bind(input, input.getFieldSet()); } return input; }
OrgMatchingItemProcessor extends BaseItemProcessor implements ItemProcessor<OrgData, OrgData> { @Override public OrgData process(OrgData input) throws Exception { ServiceContext context = getServiceContext(); List<ValidationError> errors = Lists.newArrayList(); if (StringUtils.isBlank(input.getOrg().getOrgTypeCode())) { ValidationError error = new ValidationError("orgTypeCode", "Organization Type", "The organization type is required."); errors.add(error); } if (StringUtils.isBlank(input.getOrg().getParentOrgCode())) { ValidationError error = new ValidationError("parentOrgCode", "Parent Organization", "The parent organization is required."); errors.add(error); } if (!errors.isEmpty()) { ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } Org match = organizationService.getMatch(context, input.getOrg()); if (match != null) { if (!match.getParentOrgLocalCode().equals(input.getOrg().getParentOrgLocalCode())) { String msg = messageSource.getMessage("validation.org.parent.not.same", new Object[] { input.getOrg().getParentOrgLocalCode(), match.getParentOrgLocalCode() }, Locale.getDefault()); errors.add(new ValidationError("parentOrgCode", "Parent Organization", msg)); ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } input.setOrg(match); return binder.bind(input, input.getFieldSet()); } return input; } }
OrgMatchingItemProcessor extends BaseItemProcessor implements ItemProcessor<OrgData, OrgData> { @Override public OrgData process(OrgData input) throws Exception { ServiceContext context = getServiceContext(); List<ValidationError> errors = Lists.newArrayList(); if (StringUtils.isBlank(input.getOrg().getOrgTypeCode())) { ValidationError error = new ValidationError("orgTypeCode", "Organization Type", "The organization type is required."); errors.add(error); } if (StringUtils.isBlank(input.getOrg().getParentOrgCode())) { ValidationError error = new ValidationError("parentOrgCode", "Parent Organization", "The parent organization is required."); errors.add(error); } if (!errors.isEmpty()) { ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } Org match = organizationService.getMatch(context, input.getOrg()); if (match != null) { if (!match.getParentOrgLocalCode().equals(input.getOrg().getParentOrgLocalCode())) { String msg = messageSource.getMessage("validation.org.parent.not.same", new Object[] { input.getOrg().getParentOrgLocalCode(), match.getParentOrgLocalCode() }, Locale.getDefault()); errors.add(new ValidationError("parentOrgCode", "Parent Organization", msg)); ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } input.setOrg(match); return binder.bind(input, input.getFieldSet()); } return input; }  }
OrgMatchingItemProcessor extends BaseItemProcessor implements ItemProcessor<OrgData, OrgData> { @Override public OrgData process(OrgData input) throws Exception { ServiceContext context = getServiceContext(); List<ValidationError> errors = Lists.newArrayList(); if (StringUtils.isBlank(input.getOrg().getOrgTypeCode())) { ValidationError error = new ValidationError("orgTypeCode", "Organization Type", "The organization type is required."); errors.add(error); } if (StringUtils.isBlank(input.getOrg().getParentOrgCode())) { ValidationError error = new ValidationError("parentOrgCode", "Parent Organization", "The parent organization is required."); errors.add(error); } if (!errors.isEmpty()) { ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } Org match = organizationService.getMatch(context, input.getOrg()); if (match != null) { if (!match.getParentOrgLocalCode().equals(input.getOrg().getParentOrgLocalCode())) { String msg = messageSource.getMessage("validation.org.parent.not.same", new Object[] { input.getOrg().getParentOrgLocalCode(), match.getParentOrgLocalCode() }, Locale.getDefault()); errors.add(new ValidationError("parentOrgCode", "Parent Organization", msg)); ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } input.setOrg(match); return binder.bind(input, input.getFieldSet()); } return input; }  @Override OrgData process(OrgData input); void setOrganizationService(OrganizationService organizationService); void setBinder(Binder<OrgData> binder); void setMessageSource(MessageSource messageSource); }
OrgMatchingItemProcessor extends BaseItemProcessor implements ItemProcessor<OrgData, OrgData> { @Override public OrgData process(OrgData input) throws Exception { ServiceContext context = getServiceContext(); List<ValidationError> errors = Lists.newArrayList(); if (StringUtils.isBlank(input.getOrg().getOrgTypeCode())) { ValidationError error = new ValidationError("orgTypeCode", "Organization Type", "The organization type is required."); errors.add(error); } if (StringUtils.isBlank(input.getOrg().getParentOrgCode())) { ValidationError error = new ValidationError("parentOrgCode", "Parent Organization", "The parent organization is required."); errors.add(error); } if (!errors.isEmpty()) { ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } Org match = organizationService.getMatch(context, input.getOrg()); if (match != null) { if (!match.getParentOrgLocalCode().equals(input.getOrg().getParentOrgLocalCode())) { String msg = messageSource.getMessage("validation.org.parent.not.same", new Object[] { input.getOrg().getParentOrgLocalCode(), match.getParentOrgLocalCode() }, Locale.getDefault()); errors.add(new ValidationError("parentOrgCode", "Parent Organization", msg)); ValidationServiceException e = new ValidationServiceException(new FaultInfo()); e.getFaultInfo().getAttributeErrors().addAll(errors); throw e; } input.setOrg(match); return binder.bind(input, input.getFieldSet()); } return input; }  @Override OrgData process(OrgData input); void setOrganizationService(OrganizationService organizationService); void setBinder(Binder<OrgData> binder); void setMessageSource(MessageSource messageSource);  }