MleBO { public String deleteMle(String mleName, String mleVersion, String osName, String osVersion, String oemName, String mleUuid) { TblMle tblMle; try { if (mleUuid != null && !mleUuid.isEmpty()) { tblMle = mleJpaController.findTblMleByUUID(mleUuid); } else { tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName); } if (tblMle == null) { throw new ASException(ErrorCode.WS_MLE_DOES_NOT_EXIST, mleName, mleVersion); } Collection<TblHosts> tblHostsCollection; if (oemName == null || oemName.isEmpty()) { tblHostsCollection = tblMle.getTblHostsCollection(); } else { tblHostsCollection = tblMle.getTblHostsCollection1(); } if (tblHostsCollection != null) { log.debug("MLE {} is currently associated with {} hosts. ", mleName, tblHostsCollection.size()); if (!tblHostsCollection.isEmpty()) { throw new ASException(ErrorCode.WS_MLE_ASSOCIATION_EXISTS, mleName, mleVersion, tblHostsCollection.size()); } } for (TblModuleManifest moduleManifest : tblMle.getTblModuleManifestCollection()) { moduleManifestJpaController.destroy(moduleManifest.getId()); } for (TblPcrManifest manifest : tblMle.getTblPcrManifestCollection()) { pcrManifestJpaController.destroy(manifest.getId()); } MwMeasurementXmlJpaController mxJpa = My.jpa().mwMeasurementXml(); MwMeasurementXml measurementXml = mxJpa.findByMleId(tblMle.getId()); if (measurementXml != null) { mxJpa.destroy(measurementXml.getId()); } deleteMleSource(mleName, mleVersion, osName, osVersion, oemName, mleUuid); mleJpaController.destroy(tblMle.getId()); } catch (ASException ase) { throw ase; } catch (Exception e) { log.error("Error during MLE deletion.", e); throw new ASException(ErrorCode.WS_MLE_DELETE_ERROR, e.getClass().getSimpleName()); } return "true"; } MleBO(); String addMLe(MleData mleData, String mleUuid); String updateMle(MleData mleData, String mleUuid); String deleteMle(String mleName, String mleVersion, String osName, String osVersion, String oemName, String mleUuid); List<MleData> listMles(String searchCriteria); MleData findMle(String mleName, String mleVersion, String osName, String osVersion, String oemName); MleData createMleDataFromDatabaseRecord(TblMle tblMle, boolean addManifest); String addPCRWhiteList(PCRWhiteList pcrData); String addPCRWhiteList(PCRWhiteList pcrData, EntityManager em, String uuid, String mleUuid); String updatePCRWhiteList(PCRWhiteList pcrData); String updatePCRWhiteList(PCRWhiteList pcrData, EntityManager em, String uuid); String deletePCRWhiteList(String pcrName, String algorithmBank, String mleName, String mleVersion, String osName, String osVersion, String oemName, String pcrUuid); String addModuleWhiteList(ModuleWhiteList moduleData); String addModuleWhiteList(ModuleWhiteList moduleData, EntityManager em, String uuid, String mleUuid); String updateModuleWhiteList(ModuleWhiteList moduleData); String updateModuleWhiteList(ModuleWhiteList moduleData, EntityManager em, String uuid); String deleteModuleWhiteList(String componentName, String eventName, String pcrBank, String mleName, String mleVersion,
            String osName, String osVersion, String oemName, String uuid); List<ModuleWhiteList> getModuleWhiteList(String mleName, String mleVersion,
            String osName, String osVersion, String oemName); String addMleSource(MleSource mleSourceObj, String uuid, String mleUuid); String updateMleSource(MleSource mleSourceObj, String mleUuid); String deleteMleSource(String mleName, String mleVersion, String osName, String osVersion, String oemName, String mleUuid); String getMleSource(String mleName, String mleVersion, String osName, String osVersion, String oemName);  }
@Test public void testDeleteMleVmm() { System.out.println("deleteMleVmm"); MleBO instance = new MleBO(); String expResult = "true"; MleData vmm = getVmmMle(); String resultVmm = instance.deleteMle(vmm.getName(), vmm.getVersion(), vmm.getOsName(), vmm.getOsVersion(), vmm.getOemName(), null); assertEquals(expResult, resultVmm); }
@Test public void testDeleteMleBios() { System.out.println("deleteMleBios"); MleBO instance = new MleBO(); String expResult = "true"; MleData bios = getBiosMle(); String resultBios = instance.deleteMle(bios.getName(), bios.getVersion(), bios.getOsName(), bios.getOsVersion(), bios.getOemName(), null); assertEquals(expResult, resultBios); }