@Override public Collection<CommonSchemaLog> toCommonSchemaLogs(Log log) { Collection<CommonSchemaLog> commonSchemaLogs = new LinkedList<>(); for (String transmissionTarget : log.getTransmissionTargetTokens()) { /* Part A common fields. */ CommonSchemaEventLog commonSchemaEventLog = new CommonSchemaEventLog(); /* Event name goes to Part A. */ EventLog eventLog = (EventLog) log; PartAUtils.setName(commonSchemaEventLog, eventLog.getName()); /* Add common Part A fields. */ PartAUtils.addPartAFromLog(log, commonSchemaEventLog, transmissionTarget); /* Part B, C and Part A metadata. */ CommonSchemaDataUtils.addCommonSchemaData(eventLog.getTypedProperties(), commonSchemaEventLog); commonSchemaLogs.add(commonSchemaEventLog); /* Copy tag. */ commonSchemaEventLog.setTag(log.getTag()); } return commonSchemaLogs; } }
private static void testValidName(String name) { CommonSchemaLog log = new MockCommonSchemaLog(); PartAUtils.setName(log, name); assertEquals(name, log.getName()); }
private static void testInvalidName(String name) { CommonSchemaLog log = new MockCommonSchemaLog(); try { PartAUtils.setName(log, name); fail("Expected exception"); } catch (IllegalArgumentException e) { assertNull(log.getName()); } }
PartAUtils.setName(same(commonSchemaLog), eq("test"));