+ @Test
+ public void testOneTransformationOneDestinationFilterRejectsDestinationDocType() {
+ registerDocumentType("any");
+
+ Transformation transformation = mock(Transformation.class);
+ when(transformation.getId())
+ .thenReturn(new Id<Transformation>("trans"));
+ when(transformation.getFromType()).thenReturn("any");
+ when(transformation.getToType()).thenReturn("bla");
+ when(transformation.transform(same(source1))).thenReturn(source2);
+ routerConfig.transformationConfig().add(transformation);
+
+ Filter filter = mock(Filter.class);
+ when(filter.getId()).thenReturn(new Id<Filter>("f"));
+ when(filter.isAllowed(anyString(), same(source2))).thenReturn(false);
+ when(filter.isAllowed(anyString(), same(source1))).thenReturn(true);
+ routerConfig.filterConfig().add(filter);
+
+ config.setRouterConfig(routerConfig);
+
+ Destination destination = mock(Destination.class);
+ when(
+ destination.chooseFromTargetTypes((Collection<String>) anyObject()))
+ .thenReturn(Arrays.asList("bla"));
+
+ router.registerDestination(destination);
+
+ when(destination.receive(any(DOMSource.class))).thenReturn(true);
+ router.publish("bla", source1);
+ verify(listener).notDelivered(any(EventInfo.class));
+
+ verify(transformation).transform(source1);
+ verify(destination, never()).receive(any(DOMSource.class));
+ }
+