@Test public void testValidateAttributes() { PeopleFlowActionTypeService peopleFlowActionTypeService = PeopleFlowActionTypeService.getInstance(PeopleFlowActionTypeService.Type.NOTIFICATION); peopleFlowActionTypeService.setConfigurationService(configurationService); ((PeopleFlowActionTypeService)peopleFlowActionTypeService).setPeopleFlowService(mockPeopleFlowService); Map<String, String> attributes = new HashMap<String, String>(); attributes.put(PeopleFlowActionTypeService.ATTRIBUTE_FIELD_NAME, INVALID_PEOPLEFLOW_ID); try { peopleFlowActionTypeService.validateAttributes(null, attributes); fail("null type id should throw an exception"); } catch (RiceIllegalArgumentException e) { } try { peopleFlowActionTypeService.validateAttributes("bogusTypeId", null); fail("null type id should throw an exception"); } catch (RiceIllegalArgumentException e) { } List<RemotableAttributeError> errors = peopleFlowActionTypeService.validateAttributes("bogusTypeId", attributes); assertFalse(CollectionUtils.isEmpty(errors)); errors = peopleFlowActionTypeService.validateAttributesAgainstExisting("bogusTypeId", attributes, Collections.<String, String>emptyMap()); assertFalse(CollectionUtils.isEmpty(errors)); attributes.clear(); attributes.put(PeopleFlowActionTypeService.ATTRIBUTE_FIELD_NAME, VALID_PEOPLEFLOW_ID_1); errors = peopleFlowActionTypeService.validateAttributes("bogusTypeId", attributes); assertTrue(CollectionUtils.isEmpty(errors)); errors = peopleFlowActionTypeService.validateAttributesAgainstExisting("bogusTypeId", attributes, Collections.<String, String>emptyMap()); assertTrue(CollectionUtils.isEmpty(errors)); }
@Override public List<RemotableAttributeError> validateAttributes( @WebParam(name = "krmsTypeId") String krmsTypeId, @WebParam(name = "attributes") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> attributes ) throws RiceIllegalArgumentException { List<RemotableAttributeError> results = null; validateNonBlankKrmsTypeId(krmsTypeId); if (attributes == null) { throw new RiceIllegalArgumentException("attributes must not be null"); } RemotableAttributeError.Builder errorBuilder = RemotableAttributeError.Builder.create(ATTRIBUTE_FIELD_NAME); if (attributes != null && attributes.containsKey(ATTRIBUTE_FIELD_NAME) && StringUtils.isNotBlank(attributes.get(ATTRIBUTE_FIELD_NAME))) { PeopleFlowDefinition peopleFlowDefinition = null; try { peopleFlowDefinition = getPeopleFlowService().getPeopleFlow(attributes.get(ATTRIBUTE_FIELD_NAME)); } catch (ObjectRetrievalFailureException e) { } catch (IllegalArgumentException e) { } if (peopleFlowDefinition == null) { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.invalid"), ATTRIBUTE_FIELD_NAME)); } } else { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.required"), ATTRIBUTE_FIELD_NAME)); } if (errorBuilder.getErrors().size() > 0) { results = Collections.singletonList(errorBuilder.build()); } else { results = Collections.emptyList(); } return results; }
PeopleFlowActionTypeService extends KrmsTypeServiceBase implements ActionTypeService { @Override public List<RemotableAttributeError> validateAttributes( @WebParam(name = "krmsTypeId") String krmsTypeId, @WebParam(name = "attributes") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> attributes ) throws RiceIllegalArgumentException { List<RemotableAttributeError> results = null; validateNonBlankKrmsTypeId(krmsTypeId); if (attributes == null) { throw new RiceIllegalArgumentException("attributes must not be null"); } RemotableAttributeError.Builder errorBuilder = RemotableAttributeError.Builder.create(ATTRIBUTE_FIELD_NAME); if (attributes != null && attributes.containsKey(ATTRIBUTE_FIELD_NAME) && StringUtils.isNotBlank(attributes.get(ATTRIBUTE_FIELD_NAME))) { PeopleFlowDefinition peopleFlowDefinition = null; try { peopleFlowDefinition = getPeopleFlowService().getPeopleFlow(attributes.get(ATTRIBUTE_FIELD_NAME)); } catch (ObjectRetrievalFailureException e) { } catch (IllegalArgumentException e) { } if (peopleFlowDefinition == null) { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.invalid"), ATTRIBUTE_FIELD_NAME)); } } else { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.required"), ATTRIBUTE_FIELD_NAME)); } if (errorBuilder.getErrors().size() > 0) { results = Collections.singletonList(errorBuilder.build()); } else { results = Collections.emptyList(); } return results; } }
PeopleFlowActionTypeService extends KrmsTypeServiceBase implements ActionTypeService { @Override public List<RemotableAttributeError> validateAttributes( @WebParam(name = "krmsTypeId") String krmsTypeId, @WebParam(name = "attributes") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> attributes ) throws RiceIllegalArgumentException { List<RemotableAttributeError> results = null; validateNonBlankKrmsTypeId(krmsTypeId); if (attributes == null) { throw new RiceIllegalArgumentException("attributes must not be null"); } RemotableAttributeError.Builder errorBuilder = RemotableAttributeError.Builder.create(ATTRIBUTE_FIELD_NAME); if (attributes != null && attributes.containsKey(ATTRIBUTE_FIELD_NAME) && StringUtils.isNotBlank(attributes.get(ATTRIBUTE_FIELD_NAME))) { PeopleFlowDefinition peopleFlowDefinition = null; try { peopleFlowDefinition = getPeopleFlowService().getPeopleFlow(attributes.get(ATTRIBUTE_FIELD_NAME)); } catch (ObjectRetrievalFailureException e) { } catch (IllegalArgumentException e) { } if (peopleFlowDefinition == null) { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.invalid"), ATTRIBUTE_FIELD_NAME)); } } else { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.required"), ATTRIBUTE_FIELD_NAME)); } if (errorBuilder.getErrors().size() > 0) { results = Collections.singletonList(errorBuilder.build()); } else { results = Collections.emptyList(); } return results; } PeopleFlowActionTypeService(Type type); }
PeopleFlowActionTypeService extends KrmsTypeServiceBase implements ActionTypeService { @Override public List<RemotableAttributeError> validateAttributes( @WebParam(name = "krmsTypeId") String krmsTypeId, @WebParam(name = "attributes") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> attributes ) throws RiceIllegalArgumentException { List<RemotableAttributeError> results = null; validateNonBlankKrmsTypeId(krmsTypeId); if (attributes == null) { throw new RiceIllegalArgumentException("attributes must not be null"); } RemotableAttributeError.Builder errorBuilder = RemotableAttributeError.Builder.create(ATTRIBUTE_FIELD_NAME); if (attributes != null && attributes.containsKey(ATTRIBUTE_FIELD_NAME) && StringUtils.isNotBlank(attributes.get(ATTRIBUTE_FIELD_NAME))) { PeopleFlowDefinition peopleFlowDefinition = null; try { peopleFlowDefinition = getPeopleFlowService().getPeopleFlow(attributes.get(ATTRIBUTE_FIELD_NAME)); } catch (ObjectRetrievalFailureException e) { } catch (IllegalArgumentException e) { } if (peopleFlowDefinition == null) { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.invalid"), ATTRIBUTE_FIELD_NAME)); } } else { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.required"), ATTRIBUTE_FIELD_NAME)); } if (errorBuilder.getErrors().size() > 0) { results = Collections.singletonList(errorBuilder.build()); } else { results = Collections.emptyList(); } return results; } PeopleFlowActionTypeService(Type type); static PeopleFlowActionTypeService getInstance(Type type); void setConfigurationService(ConfigurationService configurationService); @Override Action loadAction(ActionDefinition actionDefinition); @Override RemotableAttributeField translateTypeAttribute(KrmsTypeAttribute inputAttribute,
            KrmsAttributeDefinition attributeDefinition); @Override List<RemotableAttributeError> validateAttributes(

            @WebParam(name = "krmsTypeId") String krmsTypeId,

            @WebParam(name = "attributes")
            @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
            Map<String, String> attributes

    ); @Override List<RemotableAttributeError> validateAttributesAgainstExisting(
            @WebParam(name = "krmsTypeId") String krmsTypeId, @WebParam(name = "newAttributes") @XmlJavaTypeAdapter(
            value = MapStringStringAdapter.class) Map<String, String> newAttributes,
            @WebParam(name = "oldAttributes") @XmlJavaTypeAdapter(
                    value = MapStringStringAdapter.class) Map<String, String> oldAttributes); PeopleFlowService getPeopleFlowService(); void setPeopleFlowService(PeopleFlowService peopleFlowService); }
PeopleFlowActionTypeService extends KrmsTypeServiceBase implements ActionTypeService { @Override public List<RemotableAttributeError> validateAttributes( @WebParam(name = "krmsTypeId") String krmsTypeId, @WebParam(name = "attributes") @XmlJavaTypeAdapter(value = MapStringStringAdapter.class) Map<String, String> attributes ) throws RiceIllegalArgumentException { List<RemotableAttributeError> results = null; validateNonBlankKrmsTypeId(krmsTypeId); if (attributes == null) { throw new RiceIllegalArgumentException("attributes must not be null"); } RemotableAttributeError.Builder errorBuilder = RemotableAttributeError.Builder.create(ATTRIBUTE_FIELD_NAME); if (attributes != null && attributes.containsKey(ATTRIBUTE_FIELD_NAME) && StringUtils.isNotBlank(attributes.get(ATTRIBUTE_FIELD_NAME))) { PeopleFlowDefinition peopleFlowDefinition = null; try { peopleFlowDefinition = getPeopleFlowService().getPeopleFlow(attributes.get(ATTRIBUTE_FIELD_NAME)); } catch (ObjectRetrievalFailureException e) { } catch (IllegalArgumentException e) { } if (peopleFlowDefinition == null) { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.invalid"), ATTRIBUTE_FIELD_NAME)); } } else { errorBuilder.addErrors(MessageFormat.format(configurationService.getPropertyValueAsString("peopleFlow.peopleFlowId.required"), ATTRIBUTE_FIELD_NAME)); } if (errorBuilder.getErrors().size() > 0) { results = Collections.singletonList(errorBuilder.build()); } else { results = Collections.emptyList(); } return results; } PeopleFlowActionTypeService(Type type); static PeopleFlowActionTypeService getInstance(Type type); void setConfigurationService(ConfigurationService configurationService); @Override Action loadAction(ActionDefinition actionDefinition); @Override RemotableAttributeField translateTypeAttribute(KrmsTypeAttribute inputAttribute,
            KrmsAttributeDefinition attributeDefinition); @Override List<RemotableAttributeError> validateAttributes(

            @WebParam(name = "krmsTypeId") String krmsTypeId,

            @WebParam(name = "attributes")
            @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
            Map<String, String> attributes

    ); @Override List<RemotableAttributeError> validateAttributesAgainstExisting(
            @WebParam(name = "krmsTypeId") String krmsTypeId, @WebParam(name = "newAttributes") @XmlJavaTypeAdapter(
            value = MapStringStringAdapter.class) Map<String, String> newAttributes,
            @WebParam(name = "oldAttributes") @XmlJavaTypeAdapter(
                    value = MapStringStringAdapter.class) Map<String, String> oldAttributes); PeopleFlowService getPeopleFlowService(); void setPeopleFlowService(PeopleFlowService peopleFlowService); static final String ATTRIBUTE_FIELD_NAME; static final String NAME_ATTRIBUTE_FIELD; }