ServiceDefinitionUtil { public static byte[] serializeServiceDefinition(ServiceDefinition sdef) throws Exception { byte[] ret=null; java.io.ByteArrayOutputStream baos=new java.io.ByteArrayOutputStream(); MAPPER.writeValue(baos, sdef); ret = baos.toByteArray(); baos.close(); return (ret); } private  ServiceDefinitionUtil(); static byte[] serializeServiceDefinition(ServiceDefinition sdef); static ServiceDefinition deserializeServiceDefinition(byte[] sdef); static java.util.Collection<ServiceDefinition> derive(ActivityUnit actUnit); static java.util.Map<String,ServiceDefinition> mergeSnapshots(
                    java.util.List<java.util.Map<String,ServiceDefinition>> snapshots); static java.util.Map<String,ServiceDefinition> mergeSnapshots(
                    java.util.List<java.util.Map<String,ServiceDefinition>> snapshots,
                    boolean retainContexts);  }
@Test public void testSerializeServiceDefiniton() { ServiceDefinition st1=new ServiceDefinition(); st1.setServiceType(SERVICE_TYPE_1); InterfaceDefinition intf1=new InterfaceDefinition(); intf1.setInterface(INTERFACE_1); st1.getInterfaces().add(intf1); OperationDefinition op1=new OperationDefinition(); intf1.getOperations().add(op1); op1.setName(OPERATION_1); RequestResponseDefinition nrd1=new RequestResponseDefinition(); nrd1.getMetrics().setCount(10); nrd1.getMetrics().setAverage(1000); nrd1.getMetrics().setMin(500); nrd1.getMetrics().setMax(1500); nrd1.getMetrics().setCountChange(+5); nrd1.getMetrics().setAverageChange(+2); nrd1.getMetrics().setMinChange(-5); nrd1.getMetrics().setMaxChange(+20); op1.setRequestResponse(nrd1); InvocationDefinition id1=new InvocationDefinition(); id1.setInterface(INTERFACE_2); id1.setOperation(OPERATION_2); id1.getMetrics().setCount(10); id1.getMetrics().setAverage(500); id1.getMetrics().setMin(250); id1.getMetrics().setMax(750); nrd1.getInvocations().add(id1); RequestFaultDefinition frd1=new RequestFaultDefinition(); frd1.setFault("fault1"); frd1.getMetrics().setCount(20); frd1.getMetrics().setFaults(20); frd1.getMetrics().setAverage(2000); frd1.getMetrics().setMin(1500); frd1.getMetrics().setMax(2500); frd1.getMetrics().setCountChange(-10); frd1.getMetrics().setAverageChange(+6); frd1.getMetrics().setMinChange(0); frd1.getMetrics().setMaxChange(+10); op1.getRequestFaults().add(frd1); try { byte[] b = ServiceDefinitionUtil.serializeServiceDefinition(st1); System.out.println("SERVICE DEFINITION: "+new String(b)); } catch (Exception e) { e.printStackTrace(); fail("Failed to serialize"); } }