private void copyContent(Scenario source, Scenario target) { target.setContent(EcoreUtil.copy(source.getContent())); target.setTeslaContent(EcoreUtil.copy(source.getTeslaContent())); target.getAttachments().clear(); target.getAttachments().addAll(EcoreUtil.copyAll(source.getAttachments())); target.getContexts().clear(); target.getContexts().addAll(source.getContexts()); target.getVerifications().clear(); target.getVerifications().addAll(source.getVerifications()); target.setDescription(source.getDescription()); }
private boolean isDirty() { ITestCase model = getModel(); if (model != null && model.exists()) { try { Scenario saved = (Scenario) model.getNamedElement(); if (saved != null) { if (!EcoreUtil.equals(saved.getContent(), scenario.getContent())) return true; // special case when underlying Script model object is still // not created if (saved.getContent() == null) { if (!EcoreUtil.equals(saved.getTeslaContent(), scenario.getTeslaContent())) return true; } if (saved.getContexts().size() != scenario.getContexts().size()) return true; int size = saved.getContexts().size(); for (int i = 0; i < size; i++) { if (!saved.getContexts().get(i).equals(scenario.getContexts().get(i))) return true; } if (saved.getVerifications().size() != scenario.getVerifications().size()) return true; size = saved.getVerifications().size(); for (int i = 0; i < size; i++) { if (!saved.getVerifications().get(i).equals(scenario.getVerifications().get(i))) return true; } String savedDesc = saved.getDescription(); String desc = scenario.getDescription(); if (savedDesc == null && desc != null) return true; if (savedDesc != null && !savedDesc.equals(desc)) return true; return false; } return model.hasUnsavedChanges(); } catch (ModelException e) { Q7UIPlugin.log(e); } } String content = Scenarios.getScriptContent(scenario); return content != null && content.length() > 0; }
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]; } }