Search in sources :

Example 6 with IJobEntryAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer in project pentaho-metaverse by pentaho.

the class JobAnalyzerTest method testAnalyzerWithEntriesGenericAnalyzer.

@Test
public void testAnalyzerWithEntriesGenericAnalyzer() throws MetaverseAnalyzerException {
    analyzer.setJobEntryAnalyzerProvider(jobEntryAnalyzerProvider);
    final List<IJobEntryAnalyzer> jobEntryAnalyzers = null;
    when(jobEntryAnalyzerProvider.getAnalyzers(any(Collection.class))).thenReturn(jobEntryAnalyzers);
    IMetaverseNode node = analyzer.analyze(descriptor, mockJobDoc);
    assertNotNull(node);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IJobEntryAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer) Collection(java.util.Collection) Test(org.junit.Test)

Example 7 with IJobEntryAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer in project pentaho-metaverse by pentaho.

the class JobAnalyzerTest method testAnalyzerWithEntriesSpecificAnalyzer.

@Test
public void testAnalyzerWithEntriesSpecificAnalyzer() throws MetaverseAnalyzerException {
    analyzer.setJobEntryAnalyzerProvider(jobEntryAnalyzerProvider);
    final Set<IJobEntryAnalyzer> jobEntryAnalyzers = null;
    when(jobEntryAnalyzerProvider.getAnalyzers(any(Collection.class))).thenReturn(new ArrayList<IJobEntryAnalyzer>() {

        {
            add(mock(IJobEntryAnalyzer.class));
        }
    });
    IMetaverseNode node = analyzer.analyze(descriptor, mockJobDoc);
    assertNotNull(node);
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) IJobEntryAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer) Collection(java.util.Collection) Test(org.junit.Test)

Example 8 with IJobEntryAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer in project pentaho-metaverse by pentaho.

the class AnalyzerInfoServiceTest method testGetSupportedEntries.

@Test
public void testGetSupportedEntries() throws Exception {
    List<IJobEntryAnalyzer> analyzers = new ArrayList<>();
    final TransJobEntryAnalyzer transJobEntryAnalyzer = new TransJobEntryAnalyzer();
    analyzers.add(transJobEntryAnalyzer);
    when(jobEntryAnalyzerProvider.getAnalyzers()).thenReturn(analyzers);
    Response supportedJobEntries = service.getSupportedJobEntries();
    assertEquals(Response.Status.OK.getStatusCode(), supportedJobEntries.getStatus());
    assertNotNull(supportedJobEntries.getEntity());
    assertTrue(supportedJobEntries.getEntity() instanceof List);
    List<AnalyzerInfo> responseList = (List<AnalyzerInfo>) supportedJobEntries.getEntity();
    assertEquals(analyzers.size(), responseList.size());
    // should be sorted based on meta name
    assertEquals(transJobEntryAnalyzer.getSupportedEntries().iterator().next().getSimpleName(), responseList.get(0).getMeta());
}
Also used : Response(javax.ws.rs.core.Response) TransJobEntryAnalyzer(org.pentaho.metaverse.analyzer.kettle.jobentry.transjob.TransJobEntryAnalyzer) IJobEntryAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 9 with IJobEntryAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer in project pentaho-metaverse by pentaho.

the class JobAnalyzer method getJobEntryAnalyzers.

public Set<IJobEntryAnalyzer> getJobEntryAnalyzers(final JobEntryInterface jobEntryInterface) {
    Set<IJobEntryAnalyzer> jobEntryAnalyzers = new HashSet<>();
    // Attempt to discover a BaseStepMeta from the given StepMeta
    jobEntryAnalyzerProvider = getJobEntryAnalyzerProvider();
    if (jobEntryAnalyzerProvider != null) {
        if (jobEntryInterface == null) {
            jobEntryAnalyzers.addAll(jobEntryAnalyzerProvider.getAnalyzers());
        } else {
            Set<Class<?>> analyzerClassSet = new HashSet<>(1);
            analyzerClassSet.add(jobEntryInterface.getClass());
            jobEntryAnalyzers.addAll(jobEntryAnalyzerProvider.getAnalyzers(analyzerClassSet));
        }
    } else {
        jobEntryAnalyzers.add(new GenericJobEntryMetaAnalyzer());
    }
    return jobEntryAnalyzers;
}
Also used : IJobEntryAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer) GenericJobEntryMetaAnalyzer(org.pentaho.metaverse.analyzer.kettle.jobentry.GenericJobEntryMetaAnalyzer) HashSet(java.util.HashSet)

Example 10 with IJobEntryAnalyzer

use of org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer in project pentaho-metaverse by pentaho.

the class JobEntryAnalyzerProviderTest method testRemoveAnalyzer_multipleWithTheSameType.

@Test
public void testRemoveAnalyzer_multipleWithTheSameType() throws Exception {
    IJobEntryAnalyzer baseStepAnalyzer = mock(IJobEntryAnalyzer.class);
    when(baseStepAnalyzer.getSupportedEntries()).thenReturn(Sets.newSet(JobEntryInterface.class));
    IJobEntryAnalyzer jobEntryTransAnalyzer = mock(IJobEntryAnalyzer.class);
    when(jobEntryTransAnalyzer.getSupportedEntries()).thenReturn(Sets.newSet(JobEntryTrans.class));
    IJobEntryAnalyzer jobEntryTransAnalyzer2 = mock(IJobEntryAnalyzer.class);
    when(jobEntryTransAnalyzer2.getSupportedEntries()).thenReturn(Sets.newSet(JobEntryTrans.class));
    provider.setJobEntryAnalyzers(Lists.newArrayList(baseStepAnalyzer, jobEntryTransAnalyzer, jobEntryTransAnalyzer2));
    Set<IJobEntryAnalyzer> tableOutputStepAnalyzers = provider.analyzerTypeMap.get(JobEntryTrans.class);
    assertNotNull(tableOutputStepAnalyzers);
    assertEquals(tableOutputStepAnalyzers.size(), 2);
    provider.removeAnalyzer(jobEntryTransAnalyzer2);
    tableOutputStepAnalyzers = provider.analyzerTypeMap.get(JobEntryTrans.class);
    assertNotNull(tableOutputStepAnalyzers);
    assertEquals(tableOutputStepAnalyzers.size(), 1);
}
Also used : JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) IJobEntryAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) Test(org.junit.Test)

Aggregations

IJobEntryAnalyzer (org.pentaho.metaverse.api.analyzer.kettle.jobentry.IJobEntryAnalyzer)10 Test (org.junit.Test)7 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)5 ArrayList (java.util.ArrayList)3 JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)3 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)3 Collection (java.util.Collection)2 GenericJobEntryMetaAnalyzer (org.pentaho.metaverse.analyzer.kettle.jobentry.GenericJobEntryMetaAnalyzer)2 Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Response (javax.ws.rs.core.Response)1 StatusCodes (org.codehaus.enunciate.jaxrs.StatusCodes)1 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)1 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)1 Job (org.pentaho.di.job.Job)1 JobHopMeta (org.pentaho.di.job.JobHopMeta)1