protected static String getResourcePath(String resourceId) { IQ7NamedElement element = Q7SearchCore.findById(resourceId); if (element == null) { return null; } return element.getResource().getFullPath().toString(); }
public void testDeleteTestcase() throws ModelException { IQ7Project prj = getQ7Project(PRJ_NAME); startDeltas(); IQ7NamedElement element = prj.getFolder(new Path("contexts")).getNamedElement("group.ctx"); try { element.getResource().delete(true, new NullProgressMonitor()); } catch (CoreException e) { e.printStackTrace(); } TestCase.assertTrue(!element.exists()); assertDeltas( "Assert delta", "ModelMembersq[*]: {CHILDREN}\n" + "\tcontexts[*]: {CHILDREN}\n" + "\t\tgroup.ctx[-]: {}"); stopDeltas(); }
private static String getTitle(ExecutionStatus status) { IQ7NamedElement element = status.getElement(); if (element != null) { if (element instanceof IContext) { try { return NLS.bind( Messages.ControlPanelWindow_ExecutionFailedDialogTitle_Context, element.getElementName()); } catch (ModelException e) { Q7UIPlugin.log(e); } } } return Messages.ControlPanelWindow_ExecutionFailedDialogTitle_Script; }
@Override public Change perform(IProgressMonitor pm) throws CoreException { pm.beginTask("", 1); // $NON-NLS-1$ try { IQ7NamedElement e = (IQ7NamedElement) getElement(); IQ7NamedElement copy = e.getWorkingCopy(new NullProgressMonitor()); try { List<String> references = getVerificationReferences(copy); references.add(getIndex(), getVerificationId()); if (copy instanceof ITestCase) { ((ITestCase) copy).setVerifications(references.toArray(new String[references.size()])); } else if (copy instanceof IQ7ProjectMetadata) { NamedElement namedElement = copy.getNamedElement(); if (namedElement instanceof ProjectMetadata) { ProjectMetadata meta = (ProjectMetadata) namedElement; meta.getVerifications().clear(); meta.getVerifications().addAll(references); } } copy.commitWorkingCopy(true, new NullProgressMonitor()); return new DeleteVerificationReferenceChange( getElement(), getVerification(), getVerificationId()); } finally { copy.discardWorkingCopy(); } } finally { pm.done(); } }
public void testElementRename() throws ModelException { IQ7Project prj = getQ7Project(PRJ_NAME); startDeltas(); IQ7NamedElement element = prj.getFolder(new Path("contexts")).getNamedElement("debug.ctx"); try { IResource res = element.getResource(); res.move( res.getFullPath().removeLastSegments(1).append("newdebug.ctx"), true, new NullProgressMonitor()); } catch (CoreException e) { e.printStackTrace(); } TestCase.assertTrue(!element.exists()); assertDeltas( "Assert delta", "ModelMembersq[*]: {CHILDREN}\n" + "\tcontexts[*]: {CHILDREN}\n" + "\t\tdebug.ctx[-]: {MOVED_TO(newdebug.ctx [in contexts [in ModelMembersq]])}\n" + "\t\tnewdebug.ctx[+]: {MOVED_FROM(debug.ctx [in ModelMembersq])}"); stopDeltas(); }
private static IContext[] getReferencedContexts(IQ7NamedElement element) { if (element == null) { return new IContext[0]; } try { List<IContext> result = new ArrayList<IContext>(); if (element instanceof Q7InternalTestCase) { Scenario scenario = ((Q7InternalTestCase) element).getNamedElement(); for (String id : scenario.getContexts()) { IQ7NamedElement ref = Q7SearchCore.findById(id); if (!(ref instanceof IContext)) { continue; } result.add((IContext) ref); } return result.toArray(new IContext[result.size()]); } if (element instanceof ITestCase) { String[] ids = ((ITestCase) element).getContexts(); return RcpttCore.getInstance() .getContexts((ITestCase) element, Arrays.asList(ids), null, true); } IQ7ProjectMetadata metadata = element.getQ7Project().getMetadata(); if (metadata.exists()) { String[] ids = metadata.getContexts(); for (String id : ids) { IQ7NamedElement ref = Q7SearchCore.findById(id); if (!(ref instanceof IContext)) { continue; } result.add((IContext) ref); } } return result.toArray(new IContext[result.size()]); } catch (ModelException e) { return new IContext[0]; } }
private String calculateDependenciesHash(IQ7NamedElement element) { StringBuilder bb = new StringBuilder(); for (IContext context : getReferencedContexts(element)) { try { bb.append("_").append(context.getID()); } catch (ModelException e) { RcpttPlugin.log(e); } } if (element != null && element.isWorkingCopy() && element instanceof ITestCase) { String[] ctxs; try { ctxs = ((ITestCase) element).getContexts(); if (ctxs != null) { for (String ctx : ctxs) { bb.append("_").append(ctx); } } } catch (ModelException e) { RcpttPlugin.log(e); } } return bb.toString(); }