Search in sources :

Example 11 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.

the class SharedDimensionMetaStoreUtilTest method testSaveSharedDimension.

@Test
public void testSaveSharedDimension() throws Exception {
    final String locale = Locale.US.toString();
    final IMetaStore metaStore = mock(IMetaStore.class);
    final IMetaStoreElementType metaStoreElementType = mock(IMetaStoreElementType.class);
    when(metaStore.newElementType(anyString())).thenReturn(metaStoreElementType);
    final IMetaStoreElement metaStoreElement = mock(IMetaStoreElement.class);
    final String sdId = "sdId";
    when(metaStore.getElement(anyString(), eq(metaStoreElementType), eq(sdId))).thenReturn(metaStoreElement);
    final LogicalTable sharedDimension = mock(LogicalTable.class);
    final String sdName = "sdName";
    when(sharedDimension.getName(eq(locale))).thenReturn(sdName);
    when(sharedDimension.getId()).thenReturn(sdId);
    SharedDimensionMetaStoreUtil.saveSharedDimension(metaStore, sharedDimension, locale);
    verify(metaStoreElement, times(1)).setElementType(eq(metaStoreElementType));
    verify(metaStoreElement, times(1)).setName(eq(sdName));
    verify(metaStoreElement, times(2)).addChild(any(IMetaStoreAttribute.class));
    verify(metaStore, times(1)).updateElement(anyString(), eq(metaStoreElementType), eq(sdId), eq(metaStoreElement));
    verify(sharedDimension, times(1)).setId(anyString());
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) IMetaStoreAttribute(org.pentaho.metastore.api.IMetaStoreAttribute) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) Matchers.anyString(org.mockito.Matchers.anyString) LogicalTable(org.pentaho.metadata.model.LogicalTable) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 12 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.

the class StarModelerPerspective method testMetaStore.

protected void testMetaStore() {
    try {
        // Force repository meta store
        IMetaStore metaStore = Spoon.getInstance().getRepository().getMetaStore();
        LogChannel.GENERAL.logBasic("Active metastore: " + metaStore.getName());
        StarDomainMetaStoreUtil.verifyNamespaceCreated(metaStore, "pentaho");
        IMetaStoreElementType elementType = StarDomainMetaStoreUtil.getStarDomainElementType(metaStore);
        if (elementType == null) {
            throw new KettleException("Unable to find star domain element type");
        }
        LogChannel.GENERAL.logBasic("Found star domain element type: " + elementType.getName() + " : " + elementType.getDescription());
        elementType = metaStore.getElementTypeByName(PentahoDefaults.NAMESPACE, elementType.getName());
        if (elementType == null) {
            throw new KettleException("Unable to find star domain element type by name");
        }
        LogChannel.GENERAL.logBasic("Found element type by name");
        List<IdNameDescription> list = new ArrayList<IdNameDescription>();
        for (IMetaStoreElement element : metaStore.getElements(PentahoDefaults.NAMESPACE, elementType)) {
            IdNameDescription nameDescription = new IdNameDescription(element.getId(), element.getName(), null);
            list.add(nameDescription);
        }
        LogChannel.GENERAL.logBasic("Found " + list.size() + " star domain elements.");
        StarDomainMetaStoreUtil.getStarDomainList(metaStore);
    } catch (Exception e) {
        new ErrorDialog(Spoon.getInstance().getShell(), "ERROR", "Error testing meta store: ", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) IdNameDescription(org.pentaho.di.starmodeler.metastore.IdNameDescription) IMetaStore(org.pentaho.metastore.api.IMetaStore) XulException(org.pentaho.ui.xul.XulException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleException(org.pentaho.di.core.exception.KettleException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)

Example 13 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore 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)

Example 14 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.

the class NamedClusterEmbedManagerTest method setUp.

@Before
public void setUp() {
    mockLog = mock(LogChannelInterface.class);
    mockMeta = mock(AbstractMeta.class);
    mockMetaStoreFactory = mock(MetaStoreFactory.class);
    NamedClusterEmbedManager.testMetaStoreFactory = mockMetaStoreFactory;
    IMetaStore mockMetaStore = mock(IMetaStore.class);
    mockNamedCluster1 = mock(NamedClusterOsgi.class);
    mockNamedCluster2 = mock(NamedClusterOsgi.class);
    when(mockNamedCluster1.getName()).thenReturn(CLUSTER1_NAME);
    when(mockNamedCluster2.getName()).thenReturn(CLUSTER2_NAME);
    mockNamedClusterService = mock(NamedClusterServiceOsgi.class);
    when(mockMeta.getNamedClusterServiceOsgi()).thenReturn(mockNamedClusterService);
    when(mockMeta.getMetaStore()).thenReturn(mockMetaStore);
    when(mockNamedClusterService.getClusterTemplate()).thenReturn(mock(NamedClusterOsgi.class));
    when(mockNamedClusterService.getNamedClusterByName(eq(CLUSTER1_NAME), any())).thenReturn(mockNamedCluster1);
    when(mockNamedClusterService.getNamedClusterByName(eq(CLUSTER2_NAME), any())).thenReturn(mockNamedCluster2);
    namedClusterEmbedManager = new NamedClusterEmbedManager(mockMeta, mockLog);
}
Also used : NamedClusterOsgi(org.pentaho.di.core.osgi.api.NamedClusterOsgi) MetaStoreFactory(org.pentaho.metastore.persist.MetaStoreFactory) AbstractMeta(org.pentaho.di.base.AbstractMeta) NamedClusterServiceOsgi(org.pentaho.di.core.osgi.api.NamedClusterServiceOsgi) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) IMetaStore(org.pentaho.metastore.api.IMetaStore) Before(org.junit.Before)

Example 15 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.

the class RestMetaTest method testStepChecks.

@Test
public void testStepChecks() {
    RestMeta meta = new RestMeta();
    List<CheckResultInterface> remarks = new ArrayList<CheckResultInterface>();
    TransMeta transMeta = new TransMeta();
    StepMeta step = new StepMeta();
    RowMetaInterface prev = new RowMeta();
    RowMetaInterface info = new RowMeta();
    String[] input = new String[0];
    String[] output = new String[0];
    VariableSpace variables = new Variables();
    Repository repo = null;
    IMetaStore metaStore = null;
    // In a default configuration, it's expected that some errors will occur.
    // For this, we'll grab a baseline count of the number of errors
    // as the error count should decrease as we change configuration settings to proper values.
    remarks.clear();
    meta.check(remarks, transMeta, step, prev, input, output, info, variables, repo, metaStore);
    final int errorsDefault = getCheckResultErrorCount(remarks);
    assertTrue(errorsDefault > 0);
    // Setting the step to read the URL from a field should fix one of the check() errors
    meta.setUrlInField(true);
    meta.setUrlField("urlField");
    prev.addValueMeta(new ValueMetaString("urlField"));
    remarks.clear();
    meta.check(remarks, transMeta, step, prev, input, output, info, variables, repo, metaStore);
    int errorsCurrent = getCheckResultErrorCount(remarks);
    assertTrue(errorsDefault > errorsCurrent);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) VariableSpace(org.pentaho.di.core.variables.VariableSpace) ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) Test(org.junit.Test)

Aggregations

IMetaStore (org.pentaho.metastore.api.IMetaStore)75 Test (org.junit.Test)55 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)20 SQL (org.pentaho.di.core.sql.SQL)17 Repository (org.pentaho.di.repository.Repository)17 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)11 TransMeta (org.pentaho.di.trans.TransMeta)11 Matchers.anyString (org.mockito.Matchers.anyString)10 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)10 StepMeta (org.pentaho.di.trans.step.StepMeta)10 KettleException (org.pentaho.di.core.exception.KettleException)9 IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)9 Node (org.w3c.dom.Node)8 ArrayList (java.util.ArrayList)7 Variables (org.pentaho.di.core.variables.Variables)7 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)7 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)7 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)6 CheckResultInterface (org.pentaho.di.core.CheckResultInterface)5 StringObjectId (org.pentaho.di.repository.StringObjectId)5