Search in sources :

Example 1 with ResourceNamingInterface

use of org.pentaho.di.resource.ResourceNamingInterface in project pentaho-kettle by pentaho.

the class XMLOutputMetaTest method testExportResources.

@Test
public void testExportResources() throws Exception {
    XMLOutputMeta xmlOutputMeta = new XMLOutputMeta();
    xmlOutputMeta.setDefault();
    ResourceNamingInterface resourceNamingInterface = mock(ResourceNamingInterface.class);
    Variables space = new Variables();
    when(resourceNamingInterface.nameResource(any(FileObject.class), eq(space), eq(true))).thenReturn("exportFile");
    xmlOutputMeta.exportResources(space, null, resourceNamingInterface, null, null);
    assertEquals("exportFile", xmlOutputMeta.getFileName());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) FileObject(org.apache.commons.vfs2.FileObject) ResourceNamingInterface(org.pentaho.di.resource.ResourceNamingInterface) Test(org.junit.Test)

Example 2 with ResourceNamingInterface

use of org.pentaho.di.resource.ResourceNamingInterface in project pentaho-kettle by pentaho.

the class MetaInjectMetaTest method exportResources.

@Test
public void exportResources() throws KettleException {
    VariableSpace variableSpace = mock(VariableSpace.class);
    ResourceNamingInterface resourceNamingInterface = mock(ResourceNamingInterface.class);
    Repository repository = mock(Repository.class);
    IMetaStore metaStore = mock(IMetaStore.class);
    MetaInjectMeta injectMetaSpy = spy(metaInjectMeta);
    TransMeta transMeta = mock(TransMeta.class);
    Map<String, ResourceDefinition> definitions = Collections.<String, ResourceDefinition>emptyMap();
    doReturn(TEST_FILE_NAME).when(transMeta).exportResources(transMeta, definitions, resourceNamingInterface, repository, metaStore);
    doReturn(transMeta).when(injectMetaSpy).loadTransformationMeta(repository, variableSpace);
    String actualExportedFileName = injectMetaSpy.exportResources(variableSpace, definitions, resourceNamingInterface, repository, metaStore);
    assertEquals(TEST_FILE_NAME, actualExportedFileName);
    assertEquals(EXPORTED_FILE_NAME, injectMetaSpy.getFileName());
    verify(transMeta).exportResources(transMeta, definitions, resourceNamingInterface, repository, metaStore);
}
Also used : Repository(org.pentaho.di.repository.Repository) VariableSpace(org.pentaho.di.core.variables.VariableSpace) ResourceDefinition(org.pentaho.di.resource.ResourceDefinition) TransMeta(org.pentaho.di.trans.TransMeta) Matchers.anyString(org.mockito.Matchers.anyString) IMetaStore(org.pentaho.metastore.api.IMetaStore) ResourceNamingInterface(org.pentaho.di.resource.ResourceNamingInterface) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ResourceNamingInterface (org.pentaho.di.resource.ResourceNamingInterface)2 FileObject (org.apache.commons.vfs2.FileObject)1 Matchers.anyString (org.mockito.Matchers.anyString)1 VariableSpace (org.pentaho.di.core.variables.VariableSpace)1 Variables (org.pentaho.di.core.variables.Variables)1 Repository (org.pentaho.di.repository.Repository)1 ResourceDefinition (org.pentaho.di.resource.ResourceDefinition)1 TransMeta (org.pentaho.di.trans.TransMeta)1 IMetaStore (org.pentaho.metastore.api.IMetaStore)1