### Question:
WorkflowFilesDeployer { public void undeploy() throws FileSystemException, URISyntaxException { undeployJSFile(config.getTarget().getWorkflowsDirUri()); undeployJSFile(config.getTarget().getDefaultsDirUri()); } WorkflowFilesDeployer(CelosCiContext context); void undeploy(); void deploy(); static final String WORKFLOW_FILENAME; static final String DEFAULTS_FILENAME; }### Answer:
@Test public void testUndeployWf() throws IOException, URISyntaxException { CelosCiContext context = mock(CelosCiContext.class); File remoteFolderWf = tempDir.newFolder(); remoteFolderWf.mkdirs(); File wfFile = new File(remoteFolderWf, "workflow.js"); wfFile.createNewFile(); File remoteFolderDef = tempDir.newFolder(); remoteFolderDef.mkdirs(); CelosCiTarget target = new CelosCiTarget(URI.create(""), URI.create(""), remoteFolderWf.toURI(), remoteFolderDef.toURI(), URI.create("hiveJdbc")); doReturn(remoteFolderDef).when(context).getDeployDir(); doReturn(target).when(context).getTarget(); doReturn("workflow").when(context).getWorkflowName(); WorkflowFilesDeployer deployer = new WorkflowFilesDeployer(context); Assert.assertTrue(wfFile.exists()); deployer.undeploy(); Assert.assertFalse(wfFile.exists()); }
@Test public void testUndeployDef() throws IOException, URISyntaxException { CelosCiContext context = mock(CelosCiContext.class); File remoteFolderWf = tempDir.newFolder(); remoteFolderWf.mkdirs(); File remoteFolderDef = tempDir.newFolder(); remoteFolderDef.mkdirs(); File defFile = new File(remoteFolderDef, "workflow.js"); defFile.createNewFile(); CelosCiTarget target = new CelosCiTarget(URI.create(""), URI.create(""), remoteFolderWf.toURI(), remoteFolderDef.toURI(), URI.create("hiveJdbc")); doReturn(remoteFolderDef).when(context).getDeployDir(); doReturn(target).when(context).getTarget(); doReturn("workflow").when(context).getWorkflowName(); WorkflowFilesDeployer deployer = new WorkflowFilesDeployer(context); Assert.assertTrue(defFile.exists()); deployer.undeploy(); Assert.assertFalse(defFile.exists()); }
@Test public void testUndeployBoth() throws IOException, URISyntaxException { CelosCiContext context = mock(CelosCiContext.class); File remoteFolderWf = tempDir.newFolder(); remoteFolderWf.mkdirs(); File wfFile = new File(remoteFolderWf, "workflow.js"); wfFile.createNewFile(); File remoteFolderDef = tempDir.newFolder(); remoteFolderDef.mkdirs(); File defFile = new File(remoteFolderDef, "workflow.js"); defFile.createNewFile(); CelosCiTarget target = new CelosCiTarget(URI.create(""), URI.create(""), remoteFolderWf.toURI(), remoteFolderDef.toURI(), URI.create("hiveJdbc")); doReturn(remoteFolderDef).when(context).getDeployDir(); doReturn(target).when(context).getTarget(); doReturn("workflow").when(context).getWorkflowName(); WorkflowFilesDeployer deployer = new WorkflowFilesDeployer(context); Assert.assertTrue(wfFile.exists()); Assert.assertTrue(defFile.exists()); deployer.undeploy(); Assert.assertFalse(wfFile.exists()); Assert.assertFalse(defFile.exists()); }