@Test public void testValidate() { System.out.println("validate"); IncomingMessageFormParameter param = new IncomingMessageFormParameterImpl(); param.setValue("2010.12.10"); param.setMessageFormParamStatus(IncMessageFormParameterStatus.NEW); param.setIncomingMsgFormParamDefinition(new IncomingMessageFormParameterDefinitionImpl()); param.getIncomingMsgFormParamDefinition().setLength(8); ParamSizeValidator instance = new ParamSizeValidator(); boolean expResult = false; boolean result = instance.validate(param); assertEquals(expResult, result); assertEquals(param.getMessageFormParamStatus(), IncMessageFormParameterStatus.INVALID); assertEquals(param.getErrCode(), 2); assertEquals(param.getErrText(), "too long"); param.setMessageFormParamStatus(IncMessageFormParameterStatus.NEW); param.getIncomingMsgFormParamDefinition().setLength(10); expResult = true; result = instance.validate(param); assertEquals(expResult, result); assertEquals(param.getMessageFormParamStatus(), IncMessageFormParameterStatus.VALID); }
public boolean validate(IncomingMessageFormParameter param) { param.setMessageFormParamStatus(IncMessageFormParameterStatus.VALID); int paramLength = param.getValue().trim().length(); int maxLength = param.getIncomingMsgFormParamDefinition().getLength(); if (paramLength > maxLength) { param.setErrCode(2); param.setErrText("too long"); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); } param.setLastModified(new Date()); return param.getMessageFormParamStatus().equals(IncMessageFormParameterStatus.VALID); }
ParamSizeValidator implements IncomingMessageFormParameterValidator { public boolean validate(IncomingMessageFormParameter param) { param.setMessageFormParamStatus(IncMessageFormParameterStatus.VALID); int paramLength = param.getValue().trim().length(); int maxLength = param.getIncomingMsgFormParamDefinition().getLength(); if (paramLength > maxLength) { param.setErrCode(2); param.setErrText("too long"); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); } param.setLastModified(new Date()); return param.getMessageFormParamStatus().equals(IncMessageFormParameterStatus.VALID); } }
ParamSizeValidator implements IncomingMessageFormParameterValidator { public boolean validate(IncomingMessageFormParameter param) { param.setMessageFormParamStatus(IncMessageFormParameterStatus.VALID); int paramLength = param.getValue().trim().length(); int maxLength = param.getIncomingMsgFormParamDefinition().getLength(); if (paramLength > maxLength) { param.setErrCode(2); param.setErrText("too long"); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); } param.setLastModified(new Date()); return param.getMessageFormParamStatus().equals(IncMessageFormParameterStatus.VALID); }  }
ParamSizeValidator implements IncomingMessageFormParameterValidator { public boolean validate(IncomingMessageFormParameter param) { param.setMessageFormParamStatus(IncMessageFormParameterStatus.VALID); int paramLength = param.getValue().trim().length(); int maxLength = param.getIncomingMsgFormParamDefinition().getLength(); if (paramLength > maxLength) { param.setErrCode(2); param.setErrText("too long"); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); } param.setLastModified(new Date()); return param.getMessageFormParamStatus().equals(IncMessageFormParameterStatus.VALID); }  boolean validate(IncomingMessageFormParameter param); }
ParamSizeValidator implements IncomingMessageFormParameterValidator { public boolean validate(IncomingMessageFormParameter param) { param.setMessageFormParamStatus(IncMessageFormParameterStatus.VALID); int paramLength = param.getValue().trim().length(); int maxLength = param.getIncomingMsgFormParamDefinition().getLength(); if (paramLength > maxLength) { param.setErrCode(2); param.setErrText("too long"); param.setMessageFormParamStatus(IncMessageFormParameterStatus.INVALID); } param.setLastModified(new Date()); return param.getMessageFormParamStatus().equals(IncMessageFormParameterStatus.VALID); }  boolean validate(IncomingMessageFormParameter param);  }