### Question:
BeanMediatorSerializer extends AbstractMediatorSerializer { public OMElement serializeSpecificMediator(Mediator m) { if (!(m instanceof BeanMediator)) { handleException("Unsupported mediator was passed in for serialization: " + m.getType()); return null; } BeanMediator mediator = (BeanMediator) m; OMElement mediatorElem = fac.createOMElement(BEAN, synNS); saveTracingState(mediatorElem, mediator); if (mediator.getAction() != null) { mediatorElem.addAttribute(fac.createOMAttribute( BeanConstants.ACTION, nullNS, mediator.getAction().toString())); } else { handleException(); } if (mediator.getVarName() != null) { mediatorElem.addAttribute(fac.createOMAttribute( BeanConstants.VAR, nullNS, mediator.getVarName())); } else { handleException(); } switch (mediator.getAction()) { case CREATE: serializeCreateBeanCase(mediatorElem, mediator); break; case SET_PROPERTY: serializeSetPropertyCase(mediatorElem, mediator); break; case GET_PROPERTY: serializeGetPropertyCase(mediatorElem, mediator); break; default: assert false; } serializeComments(mediatorElem, mediator.getCommentsList()); return mediatorElem; }  OMElement serializeSpecificMediator(Mediator m); String getMediatorClassName();  }### Answer:
@Test public void testSerializeSpecificMediator() { BeanMediatorSerializer beanMediatorSerializer = new BeanMediatorSerializer(); BeanMediator mediator = new BeanMediator(); mediator.setAction(BeanMediator.Action.CREATE); mediator.setVarName("loc"); mediator.setClazz(MockBean.class); OMElement element = beanMediatorSerializer.serializeSpecificMediator(mediator); Assert.assertEquals("CREATE action is not performed", "CREATE", element.getAttributeValue(new QName(BeanConstants.ACTION))); }
@Test public void testSerializeSpecificMediator2() { BeanMediatorSerializer beanMediatorSerializer = new BeanMediatorSerializer(); BeanMediator mediator = new BeanMediator(); mediator.setAction(BeanMediator.Action.SET_PROPERTY); mediator.setVarName("loc"); mediator.setPropertyName("testProperty"); mediator.setValue(new Value("testValue")); OMElement element = beanMediatorSerializer.serializeSpecificMediator(mediator); Assert.assertEquals("SET_PROPERTY action is not performed", "SET_PROPERTY", element.getAttributeValue(new QName(BeanConstants.ACTION))); }
@Test public void testSerializeSpecificMediator3() { BeanMediatorSerializer beanMediatorSerializer = new BeanMediatorSerializer(); BeanMediator mediator = new BeanMediator(); mediator.setAction(BeanMediator.Action.GET_PROPERTY); mediator.setVarName("loc"); mediator.setPropertyName("testProperty"); Target target = new Target("attr", TestUtils.createOMElement("<target attr=\"testTarget\">")); mediator.setTarget(target); OMElement element = beanMediatorSerializer.serializeSpecificMediator(mediator); Assert.assertEquals("GET_PROPERTY action is not performed", "GET_PROPERTY", element.getAttributeValue(new QName(BeanConstants.ACTION))); }
@Test(expected = SynapseException.class) public void testSerializeSpecificMediator4() { BeanMediatorSerializer beanMediatorSerializer = new BeanMediatorSerializer(); BeanMediator mediator = new BeanMediator(); beanMediatorSerializer.serializeSpecificMediator(mediator); }