ActiveCollectionUtil { public static QuerySpec deserializeQuerySpec(byte[] qs) throws Exception { QuerySpec ret=null; java.io.ByteArrayInputStream bais=new java.io.ByteArrayInputStream(qs); ret = (QuerySpec)MAPPER.readValue(bais, QuerySpec.class); bais.close(); return (ret); } private  ActiveCollectionUtil(); static byte[] serializeACS(java.util.List<ActiveCollectionSource> acs); @SuppressWarnings("unchecked") static java.util.List<ActiveCollectionSource> deserializeACS(byte[] acs); static byte[] serializeQuerySpec(QuerySpec qs); static QuerySpec deserializeQuerySpec(byte[] qs);  }
@Test public void testDeserializeQuerySpec() { QuerySpec qs=new QuerySpec(); qs.setCollection("OrderService"); qs.setParent("ServiceResponseTime"); qs.setPredicate(new MVEL( "serviceType == \"{urn:switchyard-quickstart-demo:orders:0.1.0}OrderService\" && " +"operation == \"submitOrder\"")); qs.setMaxItems(5000); qs.setTruncate(Truncate.End); qs.setStyle(Style.Reversed); try { byte[] b=ActiveCollectionUtil.serializeQuerySpec(qs); QuerySpec result=ActiveCollectionUtil.deserializeQuerySpec(b); if (result == null) { fail("Query spec was not deserialized"); } if (!result.getCollection().equals(qs.getCollection())) { fail("Collection not the same"); } if (!result.getParent().equals(qs.getParent())) { fail("Parent not the same"); } if (!result.getPredicate().getClass().getName().equals( qs.getPredicate().getClass().getName())) { fail("Predicate classes not the same"); } if (result.getMaxItems() != qs.getMaxItems()) { fail("Max Items not the same"); } if (result.getTruncate() != qs.getTruncate()) { fail("Truncate not the same"); } if (result.getStyle() != qs.getStyle()) { fail("Style not the same"); } } catch(Exception e) { fail("Failed to deserialize: "+e); } }