@Test
public void testRemoveModule() throws Exception {
String moduleName = randomString();
File baseModuleDir = newFile(env.getInstalledImage().getModulesDir(), SYSTEM, LAYERS, BASE);
File moduleDir = createModule0(baseModuleDir, moduleName);
String baseLayerPatchID = randomString();
Patch patch = PatchBuilder.create()
.setPatchId(randomString())
.setDescription(randomString())
.oneOffPatchIdentity(productConfig.getProductName(), productConfig.getProductVersion())
.getParent()
.oneOffPatchElement(baseLayerPatchID, BASE, false)
.addContentModification(ContentModificationUtils.removeModule(moduleDir))
.getParent()
.build();
File patchDir = mkdir(tempDir, patch.getPatchId());
createPatchXMLFile(patchDir, patch);
File zippedPatch = createZippedPatchFile(patchDir, patch.getPatchId());
PatchingResult result = executePatch(zippedPatch);
assertPatchHasBeenApplied(result, patch);
InstalledIdentity installedIdentity = loadInstalledIdentity();
File modulesPatchDir = installedIdentity.getLayers().get(0).loadTargetInfo().getDirectoryStructure().getModulePatchDirectory(baseLayerPatchID);
assertDirExists(modulesPatchDir);
assertDefinedAbsentModule(modulesPatchDir, moduleName);
}