def getOglInterfaces(self, xmlOglInterfaces: NodeList) -> OglInterfaces: oglInterfaces: OglInterfaces = cast(OglInterfaces, []) for xmlOglInterface in xmlOglInterfaces: anchorPoint: SelectAnchorPoint = self.__getAttachmentPoint( xmlOglInterface) xmlInterface: Element = xmlOglInterface.getElementsByTagName( PyutXmlConstants.ELEMENT_MODEL_INTERFACE)[0] pyutInterface: PyutInterface = PyutInterface() pyutInterface.name = xmlInterface.getAttribute( PyutXmlConstants.ATTR_NAME) pyutInterface.description = xmlOglInterface.getAttribute( PyutXmlConstants.ATTR_DESCRIPTION) pyutInterface.methods = self._getMethods(xmlInterface) pyutInterface.implementors = self._getImplementors(xmlInterface) oglInterface: OglInterface2 = OglInterface2( pyutInterface=pyutInterface, destinationAnchor=anchorPoint) oglInterfaces.append(oglInterface) return oglInterfaces
def testHash(self): oglInterface: OglInterface2 = OglInterface2( pyutInterface=self._pyutInterface, destinationAnchor=self._destinationAnchor) currentHash: int = oglInterface.__hash__() hashAgain: int = oglInterface.__hash__() self.assertEqual(currentHash, hashAgain, '__hash__ seems to be broken')
def testEqual(self): oglInterface: OglInterface2 = OglInterface2( pyutInterface=self._pyutInterface, destinationAnchor=self._destinationAnchor) doppleGanger: OglInterface2 = oglInterface self.assertEqual( oglInterface, doppleGanger, 'Magic method __equ__ does not appear to be working anymore')
def testCacheOglInterface(self): oglInterface: OglInterface2 = OglInterface2( pyutInterface=self._pyutInterface, destinationAnchor=self._destinationAnchor) doppleGanger: OglInterface2 = oglInterface initialId: int = self._idFactory.getID(oglInterface) nextId: int = self._idFactory.getID(doppleGanger) self.assertEqual(initialId, nextId, 'Should be the same')
def _createLollipopInterface(self, pyutInterface: PyutInterface, attachmentAnchor: SelectAnchorPoint): from org.pyut.general.Mediator import getMediator from org.pyut.general.Mediator import Mediator oglInterface: OglInterface2 = OglInterface2(pyutInterface, attachmentAnchor) anchorPosition: Tuple[float, float] = attachmentAnchor.GetPosition() self.logger.info(f'anchorPosition: {anchorPosition}') x = anchorPosition[0] y = anchorPosition[1] med: Mediator = getMediator() umlFrame: UmlClassDiagramsFrame = med.getFileHandling( ).getCurrentFrame() umlFrame.addShape(oglInterface, x, y, withModelUpdate=True) umlFrame.Refresh()
def testInterfaceNameEast(self): oglInterface: OglInterface2 = OglInterface2( pyutInterface=self._pyutInterface, destinationAnchor=self._destinationAnchor) pixelSize: Tuple[int, int] = (6, 12) textSize: Tuple[int, int] = (80, 12) mockDestinationAnchor: Mock = Mock() type(mockDestinationAnchor).attachmentPoint = PropertyMock( return_value=AttachmentPoint.EAST) mockDestinationAnchor.GetPosition.return_value = (437, 144) namePosition: OglPosition = oglInterface._determineInterfaceNamePosition( destinationAnchor=mockDestinationAnchor, pixelSize=pixelSize, textSize=textSize) self.assertIsNotNone(namePosition, 'Minimally return an object') self.assertEqual(485, namePosition.x, 'East name position X is bad') self.assertEqual(120, namePosition.y, 'East name position Y is bad')
def testInterfaceNameWestOverSizeName(self): oglInterface: OglInterface2 = OglInterface2( pyutInterface=self._pyutInterface, destinationAnchor=self._destinationAnchor) pixelSize: Tuple[int, int] = (6, 12) textSize: Tuple[int, int] = (135, 12) mockDestinationAnchor: Mock = Mock() type(mockDestinationAnchor).attachmentPoint = PropertyMock( return_value=AttachmentPoint.WEST) mockDestinationAnchor.GetPosition.return_value = (330, 573) namePosition: OglPosition = oglInterface._determineInterfaceNamePosition( destinationAnchor=mockDestinationAnchor, pixelSize=pixelSize, textSize=textSize) self.assertIsNotNone(namePosition, 'Minimally return an object') self.assertEqual(193, namePosition.x, 'West name position X is bad') self.assertEqual(549, namePosition.y, 'West name position Y is bad')
def testInterfaceNameSouth(self): oglInterface: OglInterface2 = OglInterface2( pyutInterface=self._pyutInterface, destinationAnchor=self._destinationAnchor) pixelSize: Tuple[int, int] = (6, 12) textSize: Tuple[int, int] = (111, 12) mockDestinationAnchor: Mock = Mock() type(mockDestinationAnchor).attachmentPoint = PropertyMock( return_value=AttachmentPoint.SOUTH) mockDestinationAnchor.GetPosition.return_value = (738, 451) namePosition: OglPosition = oglInterface._determineInterfaceNamePosition( destinationAnchor=mockDestinationAnchor, pixelSize=pixelSize, textSize=textSize) self.assertIsNotNone(namePosition, 'Minimally return an object') self.assertEqual(683, namePosition.x, 'South name position X is bad') self.assertEqual(525, namePosition.y, 'South name position Y is bad')