Search in sources :

Example 36 with Repository

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"));
}
Also used : Repository(org.pentaho.di.repository.Repository) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Result(org.pentaho.di.core.Result) Test(org.junit.Test)

Example 37 with Repository

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) StringWriter(java.io.StringWriter) ObjectId(org.pentaho.di.repository.ObjectId) HttpServletResponse(javax.servlet.http.HttpServletResponse) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 38 with Repository

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) StringWriter(java.io.StringWriter) ObjectId(org.pentaho.di.repository.ObjectId) HttpServletResponse(javax.servlet.http.HttpServletResponse) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 39 with Repository

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Repository(org.pentaho.di.repository.Repository) StringWriter(java.io.StringWriter) HttpServletResponse(javax.servlet.http.HttpServletResponse) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 40 with Repository

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) JobMeta(org.pentaho.di.job.JobMeta) StringWriter(java.io.StringWriter) ObjectId(org.pentaho.di.repository.ObjectId) HttpServletResponse(javax.servlet.http.HttpServletResponse) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

Repository (org.pentaho.di.repository.Repository)194 Test (org.junit.Test)110 KettleException (org.pentaho.di.core.exception.KettleException)66 TransMeta (org.pentaho.di.trans.TransMeta)48 ObjectId (org.pentaho.di.repository.ObjectId)36 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)31 IMetaStore (org.pentaho.metastore.api.IMetaStore)29 JobMeta (org.pentaho.di.job.JobMeta)27 StringObjectId (org.pentaho.di.repository.StringObjectId)26 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)24 ArrayList (java.util.ArrayList)20 StepMeta (org.pentaho.di.trans.step.StepMeta)20 VariableSpace (org.pentaho.di.core.variables.VariableSpace)18 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)18 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)17 PrintWriter (java.io.PrintWriter)15 Variables (org.pentaho.di.core.variables.Variables)15 IOException (java.io.IOException)14 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)14 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)13