Source:
private void checkNoteLabelAlignment(SWTBotGefEditPart editPart) { assertNotNull(editPart); EditPart part = editPart.part(); assertTrue(part instanceof SiriusDescriptionCompartmentEditPart); EditPart parentPart = part.getParent(); assertTrue(parentPart instanceof SiriusNoteEditPart); IFigure noteFigure = ((SiriusNoteEditPart) parentPart).getFigure(); assertTrue(noteFigure instanceof NoteFigure); Rectangle noteFigureBounds = noteFigure.getBounds(); IFigure wrapLabelFigure = ((SiriusDescriptionCompartmentEditPart) part).getFigure(); assertTrue(wrapLabelFigure instanceof WrappingLabel); List<?> childrenFigure = wrapLabelFigure.getChildren(); assertSame(1, childrenFigure.size()); Object flowPageFigure = childrenFigure.get(0); assertTrue(flowPageFigure instanceof FlowPage); Rectangle flowPageBounds = ((FlowPage) flowPageFigure).getBounds(); int middleOfTheNoteX = noteFigureBounds.x + noteFigureBounds.width / 2; int beginingOfTheLabelX = flowPageBounds.x; int endOfTheLabelX = flowPageBounds.x + flowPageBounds.width; assertTrue(beginingOfTheLabelX < middleOfTheNoteX); assertTrue(middleOfTheNoteX < endOfTheLabelX); int middleOfTheNoteY = noteFigureBounds.y + noteFigureBounds.height / 2; int beginingOfTheLabelY = flowPageBounds.y; int endOfTheLabelY = flowPageBounds.y + flowPageBounds.height; assertTrue(beginingOfTheLabelY < middleOfTheNoteY); assertTrue(endOfTheLabelY < middleOfTheNoteY); }

Target:
private void checkNoteLabelAlignment(SWTBotGefEditPart editPart) { assertNotNull("The edit part shouldn't be null for the note label", editPart); EditPart part = editPart.part(); assertTrue("The edit part of the note label should an instance of SiriusDescriptionCompartmentEditPart", part instanceof SiriusDescriptionCompartmentEditPart); EditPart parentPart = part.getParent(); assertTrue("The edit part of the note should an instance of SiriusNoteEditPart", parentPart instanceof SiriusNoteEditPart); IFigure noteFigure = ((SiriusNoteEditPart) parentPart).getFigure(); assertTrue("The figure of the note should an instance of NoteFigure", noteFigure instanceof NoteFigure); Rectangle noteFigureBounds = noteFigure.getBounds(); Border noteFigureBorder = noteFigure.getBorder(); Insets noteFigureInsets = noteFigureBorder.getInsets(noteFigure); IFigure wrapLabelFigure = ((SiriusDescriptionCompartmentEditPart) part).getFigure(); assertTrue("The figure of the note label should an instance of WrappingLabel", wrapLabelFigure instanceof WrappingLabel); List<?> childrenFigure = wrapLabelFigure.getChildren(); assertSame("The figure of the note label should have only one child", 1, childrenFigure.size()); Object flowPageFigure = childrenFigure.get(0); assertTrue("The figure of the note label child should be an instance of FlowPage", flowPageFigure instanceof FlowPage); Rectangle flowPageBounds = ((FlowPage) flowPageFigure).getBounds(); int middleOfTheNoteX = noteFigureBounds.x + ((noteFigureBounds.width + noteFigureInsets.left - noteFigureInsets.right) / 2); int middleOfTheLabelX = flowPageBounds.x + flowPageBounds.width / 2; assertEquals("The label should be centered in the note", middleOfTheNoteX, middleOfTheLabelX, 2); int middleOfTheNoteY = noteFigureBounds.y + noteFigureBounds.height / 2; int beginingOfTheLabelY = flowPageBounds.y; int endOfTheLabelY = flowPageBounds.y + flowPageBounds.height; assertTrue("The label should be at the top of the note", beginingOfTheLabelY < middleOfTheNoteY); assertTrue("The label should be centered of the note", endOfTheLabelY < middleOfTheNoteY); }