### Question:
EventPublisherMediatorFactory extends AbstractMediatorFactory { public Mediator createSpecificMediator(OMElement elem, Properties properties) { EventPublisherMediator eventPublisherMediator = new EventPublisherMediator(); processAuditStatus(eventPublisherMediator, elem); OMAttribute attEventSource = elem.getAttribute(PROP_NAME); if (attEventSource != null) { eventPublisherMediator.setEventSourceName(attEventSource.getAttributeValue()); } else { handleException( "The 'eventSourceName' attribute is required for the EventPublisher mediator"); } addAllCommentChildrenToList(elem, eventPublisherMediator.getCommentsList()); return eventPublisherMediator; }  QName getTagQName(); Mediator createSpecificMediator(OMElement elem, Properties properties);  }### Answer:
@Test(expected = SynapseException.class) public void testCreateSpecificMediator() throws XMLStreamException { EventPublisherMediatorFactory mediatorFactory = new EventPublisherMediatorFactory(); String inputXML = " <eventSource name=\"SampleEventSource\" xmlns=\"http: " <subscriptionManager class=\"org.apache.synapse.eventing.managers." + "DefaultInMemorySubscriptionManager\">\n" + " <property name=\"topicHeaderName\" value=\"Topic\"/>\n" + " <property name=\"topicHeaderNS\" value=\"http: " </subscriptionManager>\n" + " <subscription id=\"mySubscription\">\n" + " <filter source =\"synapse/event/test\" dialect=\"http: "eventing/dialect/topicFilter\"/>\n" + " <endpoint><address uri=\"http: "SimpleStockQuoteService\"/></endpoint>\n" + " </subscription>\n" + " <subscription id=\"mySubscription2\">\n" + " <filter source =\"synapse/event/test\" dialect=\"http: "eventing/dialect/topicFilter\"/>\n" + " <endpoint><address uri=\"http: "SimpleStockQuoteService\"/></endpoint>\n" + " <expires>2020-06-27T21:07:00.000-08:00</expires>\n" + " </subscription>\n" + " </eventSource>\n"; OMElement element = AXIOMUtil.stringToOM(inputXML); mediatorFactory.createSpecificMediator(element, null); }
@Test public void testCreateSpecificMediator2() throws XMLStreamException { EventPublisherMediatorFactory mediatorFactory = new EventPublisherMediatorFactory(); String inputXML = "<publishEvent async=\"false\">\n" + " <eventSink>String</eventSink>\n" + " <streamName>String </streamName>\n" + " <streamVersion>String</streamVersion>\n" + " <attributes>\n" + " <meta/>\n" + " <correlation>\n" + " <attribute defaultValue=\"\" name=\"attribute1\" type=\"STRING\" value=\"string_val\"/>\n" + " </correlation>\n" + " <payload>\n" + " <attribute defaultValue=\"\" name=\"attribute2\" type=\"STRING\" value=\"attribute_val2\"/>\n" + " </payload>\n" + " <arbitrary/>\n" + " </attributes>\n" + " </publishEvent>"; OMElement element = AXIOMUtil.stringToOM(inputXML); OMFactory fac = OMAbstractFactory.getOMFactory(); element.addAttribute(fac.createOMAttribute("eventSourceName", null, "Test")); Mediator mediator = mediatorFactory.createSpecificMediator(element, null); Assert.assertNotNull("Mediator cannot be null", mediator); }