### Question:
SynapseImportSerializer { public static OMElement serializeImport(SynapseImport s) { if (!(s instanceof SynapseImport)) { handleException("Unsupported Synapse Import passed in for serialization"); } SynapseImport synapseImport = (SynapseImport) s; OMElement importElem = fac.createOMElement("import", synNS); if (synapseImport.getLibName() != null) { importElem.addAttribute(fac.createOMAttribute( "name", nullNS, s.getLibName())); } else { handleException("Invalid Synapse Import. Target Library name is required"); } if (synapseImport.getLibPackage() != null) { importElem.addAttribute(fac.createOMAttribute( "package", nullNS, s.getLibPackage())); } else { handleException("Invalid Synapse Import. Target Library package is required"); } if(synapseImport.isStatus()){ importElem.addAttribute(fac.createOMAttribute( "status", nullNS, "enabled")); }else{ importElem.addAttribute(fac.createOMAttribute( "status", nullNS, "disabled")); } return importElem; }  static OMElement serializeImport(SynapseImport s); static OMElement serializeImport(OMElement parent, SynapseImport synapseImport);  }### Answer:
@Test public void testSerializeImportNUll() { thrown.expect(SynapseException.class); thrown.expectMessage("Unsupported Synapse Import passed in for serialization"); SynapseImportSerializer.serializeImport(null); }
@Test public void testSerializeImportNoLibName() { SynapseImport synapseImport = new SynapseImport(); thrown.expect(SynapseException.class); thrown.expectMessage("Invalid Synapse Import. Target Library name is required"); SynapseImportSerializer.serializeImport(synapseImport); }
@Test public void testSerializeImportNoLibPackage() { SynapseImport synapseImport = new SynapseImport(); synapseImport.setLibName("testLibName"); thrown.expect(SynapseException.class); thrown.expectMessage("Invalid Synapse Import. Target Library package is required"); SynapseImportSerializer.serializeImport(synapseImport); }
@Test public void testSerializeImportDisabled() { SynapseImport synapseImport = new SynapseImport(); synapseImport.setLibName("testLibName"); synapseImport.setLibPackage("testVersion"); OMElement element = SynapseImportSerializer.serializeImport(synapseImport); Assert.assertEquals("asserting OMElement name", "import", element.getLocalName()); OMAttribute temp = element.getAttribute(new QName("name")); Assert.assertEquals("asserting name attribute", "testLibName", temp.getAttributeValue()); temp = element.getAttribute(new QName("package")); Assert.assertEquals("asserting package attribute", "testVersion", temp.getAttributeValue()); temp = element.getAttribute(new QName("status")); Assert.assertEquals("asserting status attribute", "disabled", temp.getAttributeValue()); }
@Test public void testSerializeImportEnabled() { SynapseImport synapseImport = new SynapseImport(); synapseImport.setStatus(true); synapseImport.setLibName("testLibName"); synapseImport.setLibPackage("testVersion"); OMElement element = SynapseImportSerializer.serializeImport(synapseImport); OMAttribute temp = element.getAttribute(new QName("status")); Assert.assertEquals("asserting stats attribute", "enabled", temp.getAttributeValue()); }