@Test public void testValidateNoFaultValid() { DefautMonitorContext context = new DefautMonitorContext(); MessageNode mesgNode = new MessageNode(); mesgNode.setOperator("buy"); Message mesg = new Message(); mesg.setOperator("buy"); Result result = context.validate(null, mesgNode, mesg); if (result != Result.VALID) { fail("Should be valid"); } }
@Test public void testValidateMessageFaultEmptyValid() { DefautMonitorContext context = new DefautMonitorContext(); MessageNode mesgNode = new MessageNode(); mesgNode.setOperator(InteractionUtil.getOperator("buy", "")); Message mesg = new Message(); mesg.setOperator("buy"); mesg.setFault(""); Result result = context.validate(null, mesgNode, mesg); if (!result.isValid()) { fail("Should be valid"); } }
@Test public void testValidateMessageFaultInvalid() { DefautMonitorContext context = new DefautMonitorContext(); MessageNode mesgNode = new MessageNode(); mesgNode.setOperator("buy"); Message mesg = new Message(); mesg.setOperator("buy"); mesg.setFault("BuyFailed"); Result result = context.validate(null, mesgNode, mesg); if (result.isValid()) { fail("Should be invalid"); } }
@Test public void testValidateNodeFaultInvalid() { DefautMonitorContext context = new DefautMonitorContext(); MessageNode mesgNode = new MessageNode(); mesgNode.setOperator(InteractionUtil.getOperator("buy", "BuyFailed")); Annotation ann = new Annotation(); mesgNode.getAnnotation().add(ann); ann.setId("Id"); ann.setValue(" Fault(name=BuyFailed) "); Message mesg = new Message(); mesg.setOperator("buy"); Result result = context.validate(null, mesgNode, mesg); if (result.isValid()) { fail("Should be invalid"); } }