/** * Switching to the default Avaloq perspective and resets it. */ public static void switchAndResetPerspective() { PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { final IWorkbench workbench = PlatformUI.getWorkbench(); final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); IWorkbenchPage page = null; try { page = workbench.showPerspective("com.avaloq.ice.perspectives.Development", window); } catch (final WorkbenchException exception) { // Try customer perspective try { page = workbench.showPerspective("com.avaloq.ice.perspectives.Development", window); } catch (final WorkbenchException second) { // Both perspectives are missing throw new AssertionFailedException("Could not switch to Avaloq Perspective: " + exception.getLocalizedMessage()); } } if (page != null) { page.resetPerspective(); } } }); }
/** * Apply linked mode rename refactoring. * * @param apply contains new element name * @return refactoring result * @throws RefactoringException when refactoring session not found. * @throws CoreException when impossible to apply rename refactoring */ public RefactoringResult applyLinkedRename(LinkedRenameRefactoringApply apply) throws RefactoringException, CoreException { RefactoringSession session = getRefactoringSession(apply.getSessionId()); if (session instanceof RenameLinkedModeRefactoringSession) { RenameLinkedModeRefactoringSession renameSession = (RenameLinkedModeRefactoringSession) session; try { RefactoringResult refactoringResult = renameSession.doRename(apply.getNewName()); deleteRefactoringSession(apply.getSessionId()); return refactoringResult; } catch (InvocationTargetException | InterruptedException | AssertionFailedException e) { LOG.error(e.getMessage(), e); return DtoConverter.toRefactoringResultDto( org.eclipse.ltk.core.refactoring.RefactoringStatus.createFatalErrorStatus( e.getMessage())); } } throw new RefactoringException("There is no RenameLinkedModeRefactoringSession."); }
private void assertCreateProjectWithBadNameArg(String name) { URI location = null; try { LEProjectSupport.createProject(name, location); Assert.fail("The call to LEProjectSupport.createProject() did not fail"); } catch (AssertionFailedException e) { // TODO: handle exception } }
/** * Open view. * * @param id * the view id, must not be {@code null} */ public static void openView(final String id) { Assert.isNotNull(id, "id"); PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { @Override public void run() { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(id); } catch (final PartInitException exception) { throw new AssertionFailedException("Could not open change view: " + exception.getLocalizedMessage()); } } }); }
private SWTBotTreeItem checkForModelExistenceUI(final SWTBotTreeItem treeItem) { try { treeItem.expand(); SWTBotTreeItem models = treeItem.getNode("models"); models.expand(); return models.getNode(TEST_MODEL).select(); } catch(AssertionFailedException e) { Assert.fail(e.getMessage()); } return null; }
public void setViewMovableAndClosable(IPageLayout layout, String id, boolean state) { try { layout.getViewLayout(id).setCloseable(state); layout.getViewLayout(id).setMoveable(state); } catch (AssertionFailedException e) { LogUtil.error("Can not find view id: "+id,e); } }
public void setViewMovableNotClosable(IPageLayout layout, String id) { try { layout.getViewLayout(id).setCloseable(false); layout.getViewLayout(id).setMoveable(true); } catch (AssertionFailedException e) { LogUtil.error("Can not find view id: "+id,e); } }
@Test public void getAdapterFromAdapterRegistryWithNonMatchingAdapterType() { Collection<Object> expected = new ArrayList<Object>(); registerAdapterFactory( stubAdapterFactory( expected ), Boolean.class ); Throwable actual = thrownBy( () -> adapters.getAdapter( Boolean.TRUE, ADAPTER_TYPE_2 ) ); assertThat( actual ).isInstanceOf( AssertionFailedException.class ); }
@Test(expected = AssertionFailedException.class) public void testEmptyId() throws ParseException, CoreException { CharmTask task = new CharmTask(); taskDataHandler.parseCharmTask(repository, task, null); }
@Override @Deprecated public void addSrcPath(final String srcPath) { throw new AssertionFailedException("srcPath should not be used in CustomClassAwareEcoreGenerator"); }
@Test(expected = AssertionFailedException.class) public void testDelimitedStringToSetNoDelimiter() throws Exception { final String str = "single"; ParseUtil.delimitedStringToSet(str, null); }
@Test( expected = AssertionFailedException.class ) public void getAdapterWithNullAdapterType() { adapters.getAdapter( mock( ADAPTER_TYPE_2 ), null ); }
/** * Returns the full text of the first CcomboItem found with the given prefix. * <p> * <em>Note</em>: Throws an AssertionError if the item could not be found. * </p> * * @param ccombo * the ccomboBox to search in, must not be {@code null} * @param prefix * the prefix of the item to search for, must not be {@code null} * @return the full name of the item as string, never {@code null} */ public static String getCcomboItemText(final SWTBotCCombo ccombo, final String prefix) { Assert.isNotNull(ccombo, "ccombo"); Assert.isNotNull(prefix, "prefix"); for (String ccomboItem : ccombo.items()) { if (ccomboItem.startsWith(prefix)) { return ccomboItem; } } throw new AssertionFailedException(NLS.bind("Must have a CcomboItem named ''{0}''.", prefix)); }
/** * Tells whether there are quick fixes for this annotation. * * <p><strong>Note:</strong> This method must only be called if {@link #isQuickFixableStateSet()} * returns <code>true</code>. * * @return <code>true</code> if this annotation offers quick fixes * @throws AssertionFailedException if called when {@link #isQuickFixableStateSet()} is <code> * false</code> */ boolean isQuickFixable() throws AssertionFailedException;
/** * Returns the nearest parent of the given class. Fails if cannot find one. * Returns the reference itself if is an instance of the given class. * * @param reference * the reference element * @param eClass * the type * @return any enclosing element of the given class */ public static <T extends Element> T getNearest(Element reference, EClass eClass) { Optional<T> result = findNearest(reference, eClass); return result.orElseThrow(() -> new AssertionFailedException("No '" + eClass.getName() + "' around ")); }