use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class JobEntrySetVariablesTest method testJobEntrySetVariablesExecute_VARIABLE_TYPE_CURRENT_JOB_NullVariable.
@Test
public void testJobEntrySetVariablesExecute_VARIABLE_TYPE_CURRENT_JOB_NullVariable() throws Exception {
List<DatabaseMeta> databases = mock(List.class);
List<SlaveServer> slaveServers = mock(List.class);
Repository repository = mock(Repository.class);
IMetaStore metaStore = mock(IMetaStore.class);
entry.loadXML(getEntryNode("nullVariable", null, "CURRENT_JOB"), databases, slaveServers, repository, metaStore);
Result result = entry.execute(new Result(), 0);
assertTrue("Result should be true", result.getResult());
assertNull(entry.getVariable("nullVariable"));
}
use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class RunJobServletTest method doGetWrongCredentialsRepoTest.
@Test
public void doGetWrongCredentialsRepoTest() throws Exception {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
TransformationMap transformationMap = mock(TransformationMap.class);
SlaveServerConfig slaveServerConfig = mock(SlaveServerConfig.class);
Repository repository = mock(Repository.class);
RepositoryDirectoryInterface repDirInterface = mock(RepositoryDirectoryInterface.class);
ObjectId objId = mock(ObjectId.class);
Whitebox.setInternalState(runJobServlet, "transformationMap", transformationMap);
KettleLogStore.init();
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
when(mockHttpServletRequest.getParameter("job")).thenReturn("dummyJob");
when(mockHttpServletRequest.getParameter("level")).thenReturn("SomethingInvalid");
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(transformationMap.getSlaveServerConfig()).thenReturn(slaveServerConfig);
when(slaveServerConfig.getRepository()).thenReturn(repository);
when(repository.isConnected()).thenReturn(true);
when(repository.loadRepositoryDirectoryTree()).thenReturn(repDirInterface);
when(repDirInterface.findDirectory(anyString())).thenReturn(repDirInterface);
when(repository.getJobId("dummyJob", repDirInterface)).thenReturn(objId);
when(repository.loadJob(objId, null)).thenThrow(new KettleException("The server sent HTTP status code 401"));
runJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_OK);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_UNAUTHORIZED);
}
use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class RunJobServletTest method doGetNonExistingJobTest.
@Test
public void doGetNonExistingJobTest() throws Exception {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
TransformationMap transformationMap = mock(TransformationMap.class);
SlaveServerConfig slaveServerConfig = mock(SlaveServerConfig.class);
Repository repository = mock(Repository.class);
RepositoryDirectoryInterface repDirInterface = mock(RepositoryDirectoryInterface.class);
ObjectId objId = mock(ObjectId.class);
Whitebox.setInternalState(runJobServlet, "transformationMap", transformationMap);
KettleLogStore.init();
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
when(mockHttpServletRequest.getParameter("job")).thenReturn("dummyJob");
when(mockHttpServletRequest.getParameter("level")).thenReturn("SomethingInvalid");
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(transformationMap.getSlaveServerConfig()).thenReturn(slaveServerConfig);
when(slaveServerConfig.getRepository()).thenReturn(repository);
when(repository.isConnected()).thenReturn(true);
when(repository.loadRepositoryDirectoryTree()).thenReturn(repDirInterface);
when(repDirInterface.findDirectory(anyString())).thenReturn(repDirInterface);
when(repository.getJobId("dummyJob", repDirInterface)).thenReturn(objId);
when(repository.loadJob(objId, null)).thenThrow(new KettleException("Unable to load job"));
runJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_OK);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_NOT_FOUND);
}
use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class RunJobServletTest method doGetMissingMandatoryParamJobTest.
@Test
public void doGetMissingMandatoryParamJobTest() throws Exception {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
TransformationMap transformationMap = mock(TransformationMap.class);
SlaveServerConfig slaveServerConfig = mock(SlaveServerConfig.class);
Repository repository = mock(Repository.class);
Whitebox.setInternalState(runJobServlet, "transformationMap", transformationMap);
KettleLogStore.init();
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
when(mockHttpServletRequest.getParameter("job")).thenReturn(null);
when(mockHttpServletRequest.getParameter("level")).thenReturn("BASIC");
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(transformationMap.getSlaveServerConfig()).thenReturn(slaveServerConfig);
when(slaveServerConfig.getRepository()).thenReturn(repository);
when(repository.isConnected()).thenReturn(true);
runJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_OK);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
use of org.pentaho.di.repository.Repository in project pentaho-kettle by pentaho.
the class RunJobServletTest method doGetInvalidLogLevelTest.
@Test
public void doGetInvalidLogLevelTest() throws Exception {
HttpServletRequest mockHttpServletRequest = mock(HttpServletRequest.class);
HttpServletResponse mockHttpServletResponse = mock(HttpServletResponse.class);
TransformationMap transformationMap = mock(TransformationMap.class);
SlaveServerConfig slaveServerConfig = mock(SlaveServerConfig.class);
Repository repository = mock(Repository.class);
RepositoryDirectoryInterface repDirInterface = mock(RepositoryDirectoryInterface.class);
JobMeta jobMeta = mock(JobMeta.class);
ObjectId objId = mock(ObjectId.class);
Whitebox.setInternalState(runJobServlet, "transformationMap", transformationMap);
KettleLogStore.init();
StringWriter out = new StringWriter();
PrintWriter printWriter = new PrintWriter(out);
when(mockHttpServletRequest.getParameter("job")).thenReturn("dummyJob");
when(mockHttpServletRequest.getParameter("level")).thenReturn("SomethingInvalid");
when(mockHttpServletResponse.getWriter()).thenReturn(printWriter);
when(transformationMap.getSlaveServerConfig()).thenReturn(slaveServerConfig);
when(slaveServerConfig.getRepository()).thenReturn(repository);
when(repository.isConnected()).thenReturn(true);
when(repository.loadRepositoryDirectoryTree()).thenReturn(repDirInterface);
when(repDirInterface.findDirectory(anyString())).thenReturn(repDirInterface);
when(repository.getJobId("dummyJob", repDirInterface)).thenReturn(objId);
when(repository.loadJob(objId, null)).thenReturn(jobMeta);
when(mockHttpServletRequest.getParameterNames()).thenReturn(Collections.enumeration(Collections.emptyList()));
runJobServlet.doGet(mockHttpServletRequest, mockHttpServletResponse);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_OK);
verify(mockHttpServletResponse).setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
Aggregations