use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class WebServiceMetaTest method testCheck.
@Test
public void testCheck() throws Exception {
WebServiceMeta webServiceMeta = new WebServiceMeta();
TransMeta transMeta = mock(TransMeta.class);
StepMeta stepMeta = mock(StepMeta.class);
RowMetaInterface prev = mock(RowMetaInterface.class);
RowMetaInterface info = mock(RowMetaInterface.class);
Repository rep = mock(Repository.class);
IMetaStore metastore = mock(IMetaStore.class);
String[] input = { "one" };
ArrayList<CheckResultInterface> remarks = new ArrayList<>();
webServiceMeta.check(remarks, transMeta, stepMeta, null, input, null, info, new Variables(), rep, metastore);
assertEquals(2, remarks.size());
assertEquals("Not receiving any fields from previous steps!", remarks.get(0).getText());
assertEquals("Step is receiving info from other steps.", remarks.get(1).getText());
remarks.clear();
webServiceMeta.setInFieldArgumentName("ifan");
when(prev.size()).thenReturn(2);
webServiceMeta.check(remarks, transMeta, stepMeta, prev, new String[] {}, null, info, new Variables(), rep, metastore);
assertEquals(2, remarks.size());
assertEquals("Step is connected to previous one, receiving 2 fields", remarks.get(0).getText());
assertEquals("No input received from other steps!", remarks.get(1).getText());
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class ZipFileMetaTest method testLoadAndGetXml.
@Test
public void testLoadAndGetXml() throws Exception {
ZipFileMeta zipFileMeta = new ZipFileMeta();
Node stepnode = getTestNode();
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
IMetaStore metaStore = mock(IMetaStore.class);
StepMeta mockParentStepMeta = mock(StepMeta.class);
zipFileMeta.setParentStepMeta(mockParentStepMeta);
TransMeta mockTransMeta = mock(TransMeta.class);
NamedClusterEmbedManager embedManager = mock(NamedClusterEmbedManager.class);
when(mockParentStepMeta.getParentTransMeta()).thenReturn(mockTransMeta);
when(mockTransMeta.getNamedClusterEmbedManager()).thenReturn(embedManager);
zipFileMeta.loadXML(stepnode, Collections.singletonList(dbMeta), metaStore);
assertXmlOutputMeta(zipFileMeta);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class ZipFileMetaTest method testCheck.
@Test
public void testCheck() {
ZipFileMeta zipFileMeta = new ZipFileMeta();
zipFileMeta.setDefault();
TransMeta transMeta = mock(TransMeta.class);
StepMeta stepInfo = mock(StepMeta.class);
RowMetaInterface prev = mock(RowMetaInterface.class);
Repository repos = mock(Repository.class);
IMetaStore metastore = mock(IMetaStore.class);
RowMetaInterface info = mock(RowMetaInterface.class);
ArrayList<CheckResultInterface> remarks = new ArrayList<>();
zipFileMeta.check(remarks, transMeta, stepInfo, prev, new String[] { "input" }, new String[] { "output" }, info, new Variables(), repos, metastore);
assertEquals(2, remarks.size());
assertEquals("Source Filename field is missing!", remarks.get(0).getText());
assertEquals("Step is receiving info from other steps.", remarks.get(1).getText());
remarks = new ArrayList<>();
zipFileMeta = new ZipFileMeta();
zipFileMeta.setDynamicSourceFileNameField("sourceFileField");
zipFileMeta.check(remarks, transMeta, stepInfo, prev, new String[0], new String[] { "output" }, info, new Variables(), repos, metastore);
assertEquals(2, remarks.size());
assertEquals("Target Filename field was specified", remarks.get(0).getText());
assertEquals("No input received from other steps!", remarks.get(1).getText());
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class PurRepositoryIT method testMetaStoreElementTypes.
@Test
public void testMetaStoreElementTypes() throws MetaStoreException {
IMetaStore metaStore = repository.getMetaStore();
assertNotNull(metaStore);
String ns = PentahoDefaults.NAMESPACE;
// We start with a clean slate...
//
assertEquals(1, metaStore.getNamespaces().size());
assertEquals(true, metaStore.namespaceExists(ns));
// Now create an element type
//
IMetaStoreElementType elementType = metaStore.newElementType(ns);
elementType.setName(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME);
elementType.setDescription(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_DESCRIPTION);
metaStore.createElementType(ns, elementType);
IMetaStoreElementType verifyElementType = metaStore.getElementType(ns, elementType.getId());
assertEquals(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME, verifyElementType.getName());
assertEquals(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_DESCRIPTION, verifyElementType.getDescription());
verifyElementType = metaStore.getElementTypeByName(ns, PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME);
assertEquals(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME, verifyElementType.getName());
assertEquals(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_DESCRIPTION, verifyElementType.getDescription());
// Get the list of element type ids.
//
List<String> ids = metaStore.getElementTypeIds(ns);
assertNotNull(ids);
assertEquals(1, ids.size());
assertEquals(elementType.getId(), ids.get(0));
//
try {
metaStore.deleteNamespace(ns);
fail("The namespace deletion didn't cause an exception because there are still an element type in it");
} catch (MetaStoreDependenciesExistsException e) {
assertNotNull(e.getDependencies());
assertEquals(1, e.getDependencies().size());
assertEquals(elementType.getId(), e.getDependencies().get(0));
}
metaStore.deleteElementType(ns, elementType);
assertEquals(0, metaStore.getElementTypes(ns).size());
metaStore.deleteNamespace(ns);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class PurRepositoryIT method testMetaStoreElements.
@Test
public void testMetaStoreElements() throws MetaStoreException {
// Set up a namespace
//
String ns = PentahoDefaults.NAMESPACE;
IMetaStore metaStore = repository.getMetaStore();
if (!metaStore.namespaceExists(ns)) {
metaStore.createNamespace(ns);
}
// And an element type
//
IMetaStoreElementType elementType = metaStore.newElementType(ns);
elementType.setName(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME);
elementType.setDescription(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_DESCRIPTION);
metaStore.createElementType(ns, elementType);
// Now we play with elements...
//
IMetaStoreElement oneElement = populateElement(metaStore, elementType, "Element One");
metaStore.createElement(ns, elementType, oneElement);
IMetaStoreElement verifyOneElement = metaStore.getElement(ns, elementType, oneElement.getId());
assertNotNull(verifyOneElement);
validateElement(verifyOneElement, "Element One");
assertEquals(1, metaStore.getElements(ns, elementType).size());
IMetaStoreElement twoElement = populateElement(metaStore, elementType, "Element Two");
metaStore.createElement(ns, elementType, twoElement);
IMetaStoreElement verifyTwoElement = metaStore.getElement(ns, elementType, twoElement.getId());
assertNotNull(verifyTwoElement);
assertEquals(2, metaStore.getElements(ns, elementType).size());
try {
metaStore.deleteElementType(ns, elementType);
fail("Delete element type failed to properly detect element dependencies");
} catch (MetaStoreDependenciesExistsException e) {
List<String> ids = e.getDependencies();
assertEquals(2, ids.size());
assertTrue(ids.contains(oneElement.getId()));
assertTrue(ids.contains(twoElement.getId()));
}
metaStore.deleteElement(ns, elementType, oneElement.getId());
assertEquals(1, metaStore.getElements(ns, elementType).size());
metaStore.deleteElement(ns, elementType, twoElement.getId());
assertEquals(0, metaStore.getElements(ns, elementType).size());
}
Aggregations