ProcessInstanceEventBatch implements EventBatch { protected String extractRuntimeSource(Map<String, String> metadata) { String processId = metadata.get(ProcessInstanceEventBody.PROCESS_ID_META_DATA); if(processId == null){ return null; } else { return service + "/" + (processId.contains(".") ? processId.substring(processId.lastIndexOf('.') + 1) : processId); } } ProcessInstanceEventBatch(String service, Addons addons); @Override void append(Object rawEvent); @Override Collection<DataEvent<?>> events(); static final String TRACKED; }
@Test public void testNoServiceDefined() { ProcessInstanceEventBatch batch = new ProcessInstanceEventBatch("", null); assertThat(batch.extractRuntimeSource(singletonMap(PROCESS_ID_META_DATA, "travels"))).isEqualTo("/travels"); assertThat(batch.extractRuntimeSource(singletonMap(PROCESS_ID_META_DATA, "demo.orders"))).isEqualTo("/orders"); }
@Test public void testNoProcessIdDefined() { ProcessInstanceEventBatch batch = new ProcessInstanceEventBatch("http: assertThat(batch.extractRuntimeSource(emptyMap())).isNull(); }
@Test public void testServiceDefined() { ProcessInstanceEventBatch batch = new ProcessInstanceEventBatch("http: assertThat(batch.extractRuntimeSource(singletonMap(PROCESS_ID_META_DATA, "travels"))).isEqualTo("http: assertThat(batch.extractRuntimeSource(singletonMap(PROCESS_ID_META_DATA, "demo.orders"))).isEqualTo("http: }