use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class SharedDimensionMetaStoreUtilTest method testGetSharedDimensionElementTypeNew.
@Test
public void testGetSharedDimensionElementTypeNew() throws Exception {
final IMetaStore metaStore = mock(IMetaStore.class);
final IMetaStoreElementType metaStoreElementType = mock(IMetaStoreElementType.class);
when(metaStore.newElementType(anyString())).thenReturn(metaStoreElementType);
final IMetaStoreElementType sharedDimensionElementType = SharedDimensionMetaStoreUtil.getSharedDimensionElementType(metaStore);
verify(metaStore, times(1)).createNamespace(anyString());
assertNotNull(sharedDimensionElementType);
assertEquals(metaStoreElementType, sharedDimensionElementType);
verify(sharedDimensionElementType, times(1)).setName(eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_NAME));
verify(sharedDimensionElementType, times(1)).setDescription(eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_DESCRIPTION));
verify(metaStore, times(1)).createElementType(anyString(), eq(sharedDimensionElementType));
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class SharedDimensionMetaStoreUtilTest method testGetSharedDimensionElementTypeExist.
@Test
public void testGetSharedDimensionElementTypeExist() throws Exception {
final IMetaStore metaStore = mock(IMetaStore.class);
final IMetaStoreElementType metaStoreElementType = mock(IMetaStoreElementType.class);
when(metaStore.getElementTypeByName(anyString(), eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_NAME))).thenReturn(metaStoreElementType);
final IMetaStoreElementType sharedDimensionElementType = SharedDimensionMetaStoreUtil.getSharedDimensionElementType(metaStore);
verify(metaStore, times(1)).createNamespace(anyString());
assertNotNull(sharedDimensionElementType);
assertEquals(metaStoreElementType, sharedDimensionElementType);
verify(sharedDimensionElementType, never()).setName(eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_NAME));
verify(sharedDimensionElementType, never()).setDescription(eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_DESCRIPTION));
verify(metaStore, never()).createElementType(anyString(), eq(sharedDimensionElementType));
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class Spoon method setRepository.
public void setRepository(Repository rep) {
this.rep = rep;
this.repositoryName = rep != null ? rep.getName() : null;
try {
//
if (metaStore.getMetaStoreList().size() > 1) {
metaStore.getMetaStoreList().remove(0);
metaStore.setActiveMetaStoreName(metaStore.getMetaStoreList().get(0).getName());
}
if (rep != null) {
this.capabilities = rep.getRepositoryMeta().getRepositoryCapabilities();
// add a wrapper metastore to the delegation
//
IMetaStore repositoryMetaStore = rep.getMetaStore();
if (repositoryMetaStore != null) {
// first priority for explicitly connected repositories.
metaStore.addMetaStore(0, repositoryMetaStore);
metaStore.setActiveMetaStoreName(repositoryMetaStore.getName());
log.logBasic("Connected to metastore : " + repositoryMetaStore.getName() + ", added to delegating metastore");
} else {
log.logBasic("No metastore found in the repository : " + rep.getName() + ", connected? " + rep.isConnected());
}
}
} catch (MetaStoreException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorAddingRepositoryMetaStore.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message"), e);
}
// Registering the UI Support classes
UISupportRegistery.getInstance().registerUISupport(RepositorySecurityProvider.class, BaseRepositoryExplorerUISupport.class);
UISupportRegistery.getInstance().registerUISupport(RepositorySecurityManager.class, ManageUserUISupport.class);
if (rep != null) {
SpoonPluginManager.getInstance().notifyLifecycleListeners(SpoonLifeCycleEvent.REPOSITORY_CHANGED);
}
delegates.update(this);
enableMenus();
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class SystemDataMetaTest method testLoadXML.
@Test
public void testLoadXML() throws Exception {
SystemDataMeta systemDataMeta = new SystemDataMeta();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
Document document = documentBuilder.parse(new InputSource(new StringReader(expectedXML)));
Node node = document;
IMetaStore store = null;
systemDataMeta.loadXML(node, null, store);
assertEquals(expectedSystemDataMeta, systemDataMeta);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class AbortMetaTest method testBackwardsCapatibilityAbortWithError.
@Test
public void testBackwardsCapatibilityAbortWithError() throws KettleXMLException {
IMetaStore metaStore = mock(IMetaStore.class);
AbortMeta meta = new AbortMeta();
// Abort with error
String inputXml = " <step>\n" + " <name>Abort</name>\n" + " <type>Abort</type>\n" + " <abort_with_error>Y</abort_with_error>\n" + " </step>";
Node node = XMLHandler.loadXMLString(inputXml).getFirstChild();
meta.loadXML(node, Collections.emptyList(), metaStore);
assertTrue(meta.isAbortWithError());
// Don't abort with error
inputXml = " <step>\n" + " <name>Abort</name>\n" + " <type>Abort</type>\n" + " <abort_with_error>N</abort_with_error>\n" + " </step>";
node = XMLHandler.loadXMLString(inputXml).getFirstChild();
meta.loadXML(node, Collections.emptyList(), metaStore);
assertTrue(meta.isAbort());
// Don't abort with error
inputXml = " <step>\n" + " <name>Abort</name>\n" + " <type>Abort</type>\n" + " </step>";
node = XMLHandler.loadXMLString(inputXml).getFirstChild();
meta.loadXML(node, Collections.emptyList(), metaStore);
assertTrue(meta.isAbortWithError());
}
Aggregations