@Test public void transform_ShouldGuessAnEventtype() { Event e = new TestDomainStartEvent(); assertThat(transformer.transform(e).getEventType().getValue(), is(Eventtypes.START)); e = new TestDomainSuccessEvent(); assertThat(transformer.transform(e).getEventType().getValue(), is(Eventtypes.COMPLETE)); e = new TestDomainEndEvent(); assertThat(transformer.transform(e).getEventType().getValue(), is(Eventtypes.COMPLETE)); e = new TestDomainFailEvent(); assertThat(transformer.transform(e).getEventType().getValue(), is(Eventtypes.PI_ABORT)); e = new TestRandomXYZEvent(); assertThat(transformer.transform(e).getEventType().getValue(), is(Eventtypes.UNKNOWN)); assertThat(transformer.transform(e).getEventType().getUnknowntype(), is("testrandomxyzevent")); }
@Test public void transform_ShouldReturnAuditTrailEntryWithDataOfEvent() { testEvent.setStringField("foo"); testEvent.setIntField(76); testEvent.setObjectField(null); AuditTrailEntry ae = transformer.transform(testEvent); assertThat(ae.getWorkflowModelElement(), is(NAME)); List<Attribute> atts = ae.getData().getAttribute(); assertThat(atts.size(), is(5)); Matcher<Data.Attribute> stringName = hasProperty("name", is("stringField")); Matcher<Attribute> stringValue = hasProperty("value", is("foo")); @SuppressWarnings("unchecked") Matcher<Attribute> stringM = allOf(stringName, stringValue); Matcher<Attribute> intName = hasProperty("name", is("intField")); Matcher<Attribute> intValue = hasProperty("value", is("76")); @SuppressWarnings("unchecked") Matcher<Attribute> intM = allOf(intName, intValue); Matcher<Attribute> objName = hasProperty("name", is("objectField")); Matcher<Attribute> objValue = hasProperty("value", is("null")); @SuppressWarnings("unchecked") Matcher<Attribute> objM = allOf(objName, objValue); Matcher<Attribute> className = hasProperty("name", is("class")); Matcher<Attribute> classValue = hasProperty("value", is("class " + testEvent.getClass().getName())); @SuppressWarnings("unchecked") Matcher<Attribute> classM = allOf(className, classValue); @SuppressWarnings("unchecked") Matcher<Iterable<Attribute>> hasItems = Matchers.hasItems(stringM, intM, objM, classM); assertThat(atts, hasItems); }
@Test public void transform_ShouldReturnNull() { assertThat(transformer.transform(null), nullValue()); }