@Override public String marshal(CorrelationKey key) throws Exception { String result = null; for (CorrelationProperty<?> p : key.getProperties()) { if (result == null) { result = (String) p.getValue(); } else { result += "," + p.getValue(); } } return result; }
@Test public void correlationKeyTest() throws Exception { Assume.assumeFalse(getType().equals(TestType.YAML)); JaxbCorrelationKey corrKey = new JaxbCorrelationKey(); corrKey.setName("anton"); List<JaxbCorrelationProperty> properties = new ArrayList<JaxbCorrelationProperty>(3); corrKey.setJaxbProperties(properties); properties.add(new JaxbCorrelationProperty("name", "value")); properties.add(new JaxbCorrelationProperty("only-a-value")); properties.add(new JaxbCorrelationProperty("ngalan", "bili")); JaxbCorrelationKey copyCorrKey = testRoundTrip(corrKey); assertEquals("name", corrKey.getName(), copyCorrKey.getName()); assertEquals( "prop list size", corrKey.getProperties().size(), copyCorrKey.getProperties().size()); List<CorrelationProperty<?>> propList = corrKey.getProperties(); List<CorrelationProperty<?>> copyPropList = copyCorrKey.getProperties(); for (int i = 0; i < propList.size(); ++i) { CorrelationProperty<?> prop = propList.get(i); CorrelationProperty<?> copyProp = copyPropList.get(i); assertEquals(i + ": name", prop.getName(), copyProp.getName()); assertEquals(i + ": type", prop.getType(), copyProp.getType()); assertEquals(i + ": value", prop.getValue(), copyProp.getValue()); } }