void addTest(String name, String description, String[] idReqs, TestList pSuite, String toWrite) { name = getTestName(name, pSuite, 0); AutomaticTest pTest = new AutomaticTest(name, description, id_plugin); pTest.setConceptorLoginInModel(DataModel.getCurrentUser().getLoginFromModel()); if (Api.isConnected()) { try { pSuite.addTestInDBAndModel(pTest); } catch (Exception e1) { Tools.ihmExceptionView(e1); return; } } File file = null; try { Util.log("[JMeterIntegrationPlugin:AddTest] Create test Script file"); file = writeJunitFile(null, pTest, toWrite); } catch (Exception e2) { Tools.ihmExceptionView(e2); e2.printStackTrace(); return; } Script pScript = new Script(file.getName(), "Junit test script"); pScript.setLocalisation(file.getAbsolutePath()); pScript.setTypeInModel(ApiConstants.TEST_SCRIPT); pScript.setScriptExtensionInModel(pTest.getExtensionFromModel()); // pScript.setPlugArg(""); if (Api.isConnected()) { try { pTest.addScriptInDBAndModel(pScript, file); Util.log( "[JMeterIntegrationPlugin:AddTest] Add Script : " + pScript.getNameFromModel() + " to DB & Model"); } catch (Exception e3) { Tools.ihmExceptionView(e3); return; } } // add associated requirements Vector<ReqManager> reqManagers = pIPlugObject.getReqManagers(); for (ReqManager reqManager : reqManagers) { for (String idReqString : idReqs) { int idReq = new Integer(idReqString).intValue(); reqManager.addReqLinkWithTest(pTest, idReq); } } }
boolean addAttachmentToProject(Attachment pAttach, Project pProject) { if (Api.isConnected()) { try { pProject.addAttachementInDBAndModel(pAttach); Util.log( "[JMeterIntegrationPlugin:addAttachmentToSuite] add attach in DB & model : " + pAttach); } catch (Exception exception) { Tools.ihmExceptionView(exception); return false; } } return true; }