@Test public void testValidate() { System.out.println("validate"); IncomingMessageFormParameter param1 = new IncomingMessageFormParameterImpl(); param1.setDateCreated(new Date()); param1.setName("parent"); param1.setValue("value"); IncomingMessageForm form = new IncomingMessageFormImpl(); form.setIncomingMsgFormParameters(new HashMap<String, IncomingMessageFormParameter>()); SubField sf = new SubField(); sf.setFieldName("subfield"); sf.setParentField("parent"); sf.setReplaceOn("require"); List<SubField> subFields = new ArrayList(); subFields.add(sf); boolean expResult = true; boolean result = instance.validate(form, subFields, mockCore); assertEquals(expResult, result); form.getIncomingMsgFormParameters().put(param1.getName(), param1); expResult = true; result = instance.validate(form, subFields, mockCore); assertEquals(expResult, result); param1.setValue("require"); expResult = false; expect( mockCore.createIncomingMessageFormParameter() ).andReturn(new IncomingMessageFormParameterImpl()); replay(mockCore); result = instance.validate(form, subFields, mockCore); verify(mockCore); assertEquals(result, expResult); assertEquals(form.getMessageFormStatus(), IncMessageFormStatus.INVALID); }
public boolean validate(IncomingMessageForm form, List<SubField> subFields, CoreManager coreManager) { boolean valid = true; for(SubField sf : subFields) { if(!form.getIncomingMsgFormParameters().containsKey(sf.getParentField().toLowerCase())) continue; IncomingMessageFormParameter parent = form.getIncomingMsgFormParameters().get(sf.getParentField().toLowerCase()); if (sf.getReplaceOn().equals("*") || parent.getValue().equalsIgnoreCase(sf.getReplaceOn())) { if (!form.getIncomingMsgFormParameters().containsKey(sf.getFieldName().toLowerCase())) { valid = false; IncomingMessageFormParameter param = coreManager.createIncomingMessageFormParameter(); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); param.setName(sf.getFieldName().toLowerCase()); param.setErrText("missing"); param.setValue(""); param.setErrCode(0); form.getIncomingMsgFormParameters().put(sf.getFieldName().toLowerCase(), param); form.setMessageFormStatus(IncMessageFormStatus.INVALID); form.setLastModified(new Date()); } } } return valid; }
ConditionalRequirementValidator { public boolean validate(IncomingMessageForm form, List<SubField> subFields, CoreManager coreManager) { boolean valid = true; for(SubField sf : subFields) { if(!form.getIncomingMsgFormParameters().containsKey(sf.getParentField().toLowerCase())) continue; IncomingMessageFormParameter parent = form.getIncomingMsgFormParameters().get(sf.getParentField().toLowerCase()); if (sf.getReplaceOn().equals("*") || parent.getValue().equalsIgnoreCase(sf.getReplaceOn())) { if (!form.getIncomingMsgFormParameters().containsKey(sf.getFieldName().toLowerCase())) { valid = false; IncomingMessageFormParameter param = coreManager.createIncomingMessageFormParameter(); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); param.setName(sf.getFieldName().toLowerCase()); param.setErrText("missing"); param.setValue(""); param.setErrCode(0); form.getIncomingMsgFormParameters().put(sf.getFieldName().toLowerCase(), param); form.setMessageFormStatus(IncMessageFormStatus.INVALID); form.setLastModified(new Date()); } } } return valid; } }
ConditionalRequirementValidator { public boolean validate(IncomingMessageForm form, List<SubField> subFields, CoreManager coreManager) { boolean valid = true; for(SubField sf : subFields) { if(!form.getIncomingMsgFormParameters().containsKey(sf.getParentField().toLowerCase())) continue; IncomingMessageFormParameter parent = form.getIncomingMsgFormParameters().get(sf.getParentField().toLowerCase()); if (sf.getReplaceOn().equals("*") || parent.getValue().equalsIgnoreCase(sf.getReplaceOn())) { if (!form.getIncomingMsgFormParameters().containsKey(sf.getFieldName().toLowerCase())) { valid = false; IncomingMessageFormParameter param = coreManager.createIncomingMessageFormParameter(); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); param.setName(sf.getFieldName().toLowerCase()); param.setErrText("missing"); param.setValue(""); param.setErrCode(0); form.getIncomingMsgFormParameters().put(sf.getFieldName().toLowerCase(), param); form.setMessageFormStatus(IncMessageFormStatus.INVALID); form.setLastModified(new Date()); } } } return valid; }  }
ConditionalRequirementValidator { public boolean validate(IncomingMessageForm form, List<SubField> subFields, CoreManager coreManager) { boolean valid = true; for(SubField sf : subFields) { if(!form.getIncomingMsgFormParameters().containsKey(sf.getParentField().toLowerCase())) continue; IncomingMessageFormParameter parent = form.getIncomingMsgFormParameters().get(sf.getParentField().toLowerCase()); if (sf.getReplaceOn().equals("*") || parent.getValue().equalsIgnoreCase(sf.getReplaceOn())) { if (!form.getIncomingMsgFormParameters().containsKey(sf.getFieldName().toLowerCase())) { valid = false; IncomingMessageFormParameter param = coreManager.createIncomingMessageFormParameter(); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); param.setName(sf.getFieldName().toLowerCase()); param.setErrText("missing"); param.setValue(""); param.setErrCode(0); form.getIncomingMsgFormParameters().put(sf.getFieldName().toLowerCase(), param); form.setMessageFormStatus(IncMessageFormStatus.INVALID); form.setLastModified(new Date()); } } } return valid; }  boolean validate(IncomingMessageForm form, List<SubField> subFields, CoreManager coreManager); }
ConditionalRequirementValidator { public boolean validate(IncomingMessageForm form, List<SubField> subFields, CoreManager coreManager) { boolean valid = true; for(SubField sf : subFields) { if(!form.getIncomingMsgFormParameters().containsKey(sf.getParentField().toLowerCase())) continue; IncomingMessageFormParameter parent = form.getIncomingMsgFormParameters().get(sf.getParentField().toLowerCase()); if (sf.getReplaceOn().equals("*") || parent.getValue().equalsIgnoreCase(sf.getReplaceOn())) { if (!form.getIncomingMsgFormParameters().containsKey(sf.getFieldName().toLowerCase())) { valid = false; IncomingMessageFormParameter param = coreManager.createIncomingMessageFormParameter(); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); param.setName(sf.getFieldName().toLowerCase()); param.setErrText("missing"); param.setValue(""); param.setErrCode(0); form.getIncomingMsgFormParameters().put(sf.getFieldName().toLowerCase(), param); form.setMessageFormStatus(IncMessageFormStatus.INVALID); form.setLastModified(new Date()); } } } return valid; }  boolean validate(IncomingMessageForm form, List<SubField> subFields, CoreManager coreManager);  }