/** * Test getTransferData, with correct dataFlavor. * * @throws Exception if an unexpected exception occurs */ public void testGetTransferData() throws Exception { Generalization generalizationElement = new GeneralizationImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(generalizationElement); assertEquals( "Element is not correctly get.", generalizationElement, classElementsTransfer.getTransferData(ClassElementsTransfer.GENERALIZATION_FLAVOR)); }
/** Test getTransferData, with wrong dataFlavor. UnsupportedFlavorException is expected. */ public void testGetTransferDataWithWrong() { try { Generalization generalizationElement = new GeneralizationImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(generalizationElement); classElementsTransfer.getTransferData(ClassElementsTransfer.DEPENDENCY_FLAVOR); fail("UnsupportedFlavorException is expected."); } catch (UnsupportedFlavorException usfe) { // pass } }
/** * Test getTransferData, with null dataFlavor. IllegalArgumentException is expected. * * @throws Exception if an unexpected exception occurs */ public void testGetTransferDataWithNull() throws Exception { try { Generalization generalizationElement = new GeneralizationImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(generalizationElement); classElementsTransfer.getTransferData(null); fail("IllegalArgumentException is expected."); } catch (IllegalArgumentException iae) { // pass } }
/** * Test constructor ClassElementsTransfer(Generalization), with correct Generalization instance. * * @throws Exception if an unexpected exception occurs */ public void testCtorGeneralization() throws Exception { Generalization generalizationElement = new GeneralizationImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(generalizationElement); assertEquals( "Constructor failed, supportedFlavor is not correctly set.", ClassElementsTransfer.GENERALIZATION_FLAVOR, classElementsTransfer.getTransferDataFlavors()[0]); assertEquals( "Constructor failed, element is not correctly set.", generalizationElement, classElementsTransfer.getTransferData(ClassElementsTransfer.GENERALIZATION_FLAVOR)); }
/** * Test constructor ClassElementsTransfer(Association), with correct Association instance. * * @throws Exception if an unexpected exception occurs */ public void testCtorAssociation() throws Exception { Association associationElement = new AssociationImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(associationElement); assertEquals( "Constructor failed, supportedFlavor is not correctly set.", ClassElementsTransfer.ASSOCIATION_FLAVOR, classElementsTransfer.getTransferDataFlavors()[0]); assertEquals( "Constructor failed, element is not correctly set.", associationElement, classElementsTransfer.getTransferData(ClassElementsTransfer.ASSOCIATION_FLAVOR)); }
/** * Test constructor ClassElementsTransfer(Dependency), with correct Dependency instance. * * @throws Exception if an unexpected exception occurs */ public void testCtorDependency() throws Exception { Dependency dependencyElement = new DependencyImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(dependencyElement); assertEquals( "Constructor failed, supportedFlavor is not correctly set.", ClassElementsTransfer.DEPENDENCY_FLAVOR, classElementsTransfer.getTransferDataFlavors()[0]); assertEquals( "Constructor failed, element is not correctly set.", dependencyElement, classElementsTransfer.getTransferData(ClassElementsTransfer.DEPENDENCY_FLAVOR)); }
/** * Test constructor ClassElementsTransfer(Package), with correct Package instance. * * @throws Exception if an unexpected exception occurs */ public void testCtorPackage() throws Exception { com.topcoder.uml.model.modelmanagement.Package packageElement = new PackageImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(packageElement); assertEquals( "Constructor failed, supportedFlavor is not correctly set.", ClassElementsTransfer.PACKAGE_FLAVOR, classElementsTransfer.getTransferDataFlavors()[0]); assertEquals( "Constructor failed, element is not correctly set.", packageElement, classElementsTransfer.getTransferData(ClassElementsTransfer.PACKAGE_FLAVOR)); }
/** * Test constructor ClassElementsTransfer(Enumeration), with correct Enumeration instance. * * @throws Exception if an unexpected exception occurs */ public void testCtorEnumeration() throws Exception { Enumeration enumerationElement = new EnumerationImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(enumerationElement); assertEquals( "Constructor failed, supportedFlavor is not correctly set.", ClassElementsTransfer.ENUMERATION_FLAVOR, classElementsTransfer.getTransferDataFlavors()[0]); assertEquals( "Constructor failed, element is not correctly set.", enumerationElement, classElementsTransfer.getTransferData(ClassElementsTransfer.ENUMERATION_FLAVOR)); }
/** * Test constructor ClassElementsTransfer(Interface), with correct Interface instance. * * @throws Exception if an unexpected exception occurs */ public void testCtorInterface() throws Exception { Interface interfaceElement = new InterfaceImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(interfaceElement); assertEquals( "Constructor failed, supportedFlavor is not correctly set.", ClassElementsTransfer.INTERFACE_FLAVOR, classElementsTransfer.getTransferDataFlavors()[0]); assertEquals( "Constructor failed, element is not correctly set.", interfaceElement, classElementsTransfer.getTransferData(ClassElementsTransfer.INTERFACE_FLAVOR)); }
/** * Test constructor ClassElementsTransfer(Class), with correct Class instance. * * @throws Exception if an unexpected exception occurs */ public void testCtorClass() throws Exception { com.topcoder.uml.model.core.classifiers.Class classElement = new ClassImpl(); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(classElement); assertEquals( "Constructor failed, supportedFlavor is not correctly set.", ClassElementsTransfer.CLASS_FLAVOR, classElementsTransfer.getTransferDataFlavors()[0]); assertEquals( "Constructor failed, element is not correctly set.", classElement, classElementsTransfer.getTransferData(ClassElementsTransfer.CLASS_FLAVOR)); }
/** * Test constructor ClassElementsTransfer(Class), with correct Excpetion instance. * * @throws Exception if an unexpected exception occurs */ public void testCtorException() throws Exception { // create a Exception com.topcoder.uml.model.core.classifiers.Class classElement = new ClassImpl(); Stereotype stereoType = new StereotypeImpl(); stereoType.setName("Exception"); classElement.addStereotype(stereoType); ClassElementsTransfer classElementsTransfer = new ClassElementsTransfer(classElement); assertEquals( "Constructor failed, supportedFlavor is not correctly set.", ClassElementsTransfer.EXCEPTION_FLAVOR, classElementsTransfer.getTransferDataFlavors()[0]); assertEquals( "Constructor failed, element is not correctly set.", classElement, classElementsTransfer.getTransferData(ClassElementsTransfer.EXCEPTION_FLAVOR)); }