### Question:
WorkflowFilesDeployer { URI getTargetJsFileUri(URI uri) throws URISyntaxException { String path = uri.getPath() + File.separator + config.getWorkflowName() + ".js"; return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), path, uri.getQuery(), uri.getFragment()); } WorkflowFilesDeployer(CelosCiContext context); void undeploy(); void deploy(); static final String WORKFLOW_FILENAME; static final String DEFAULTS_FILENAME; }### Answer:
@Test public void testGetWorkflowJsUri1() throws FileSystemException, URISyntaxException { CelosCiContext context = mock(CelosCiContext.class); WorkflowFilesDeployer deployer = new WorkflowFilesDeployer(context); CelosCiTarget target = new CelosCiTarget(URI.create(""), URI.create(""), emptyURI, emptyURI, URI.create("hiveJdbc")); doReturn(target).when(context).getTarget(); doReturn("workflow").when(context).getWorkflowName(); Assert.assertEquals(deployer.getTargetJsFileUri(URI.create("")), URI.create("/workflow.js")); }
@Test public void testGetWorkflowJsUri2() throws FileSystemException, URISyntaxException { CelosCiContext context = mock(CelosCiContext.class); WorkflowFilesDeployer deployer = new WorkflowFilesDeployer(context); doReturn("workflow").when(context).getWorkflowName(); Assert.assertEquals(deployer.getTargetJsFileUri(URI.create("/home")), URI.create("/home/workflow.js")); }
@Test public void testGetWorkflowJsUri3() throws FileSystemException, URISyntaxException { CelosCiContext context = mock(CelosCiContext.class); WorkflowFilesDeployer deployer = new WorkflowFilesDeployer(context); doReturn("workflow").when(context).getWorkflowName(); Assert.assertEquals(deployer.getTargetJsFileUri(URI.create("sftp: }
@Test(expected = NullPointerException.class) public void testGetWorkflowJsUri4() throws FileSystemException, URISyntaxException { CelosCiContext context = mock(CelosCiContext.class); WorkflowFilesDeployer deployer = new WorkflowFilesDeployer(context); doReturn("workflow").when(context).getWorkflowName(); Assert.assertEquals(deployer.getTargetJsFileUri(null), null); }