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());
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations