@Test public void testMatch() throws Exception { FieldSet fieldSet = Mockito.mock(FieldSet.class); Mockito.when(fieldSet.readString(org.mockito.Matchers.argThat(Matchers.is("name")))).thenReturn(null); orgData.setFieldSet(fieldSet); Org match = new Org(); String name = "this was not in the fieldset"; match.setName(name); match.setParentOrgLocalCode("parentLocalCode"); Mockito.when( organizationService.getMatch(org.mockito.Matchers.any(ServiceContext.class), org.mockito.Matchers.any(Org.class))).thenReturn(match); OrgData matchedData = processor.process(orgData); Assert.assertNull(matchedData.getOrg().getName()); }
@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);  }