use of org.pentaho.metastore.api.IMetaStoreElementType 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.IMetaStoreElementType in project pentaho-kettle by pentaho.
the class StarDomainMetaStoreUtilTest method testGetStarDomainElementType.
@Test
public void testGetStarDomainElementType() throws Exception {
final IMetaStoreElementType starDomainElementType = StarDomainMetaStoreUtil.getStarDomainElementType(metaStore);
assertEquals(starDomainElementType, metaStoreElementType);
verify(metaStore, times(1)).createNamespace(anyString());
}
use of org.pentaho.metastore.api.IMetaStoreElementType in project pentaho-kettle by pentaho.
the class StarDomainMetaStoreUtilTest method testCreateStarDomainElementType.
@Test
public void testCreateStarDomainElementType() throws Exception {
final IMetaStoreElementType metaStoreElementType = mock(IMetaStoreElementType.class);
when(metaStore.newElementType(anyString())).thenReturn(metaStoreElementType);
final IMetaStoreElementType starDomainElementType = StarDomainMetaStoreUtil.createStarDomainElementType(metaStore);
assertEquals(starDomainElementType, metaStoreElementType);
verify(starDomainElementType, times(1)).setName(StarDomainMetaStoreUtil.METASTORE_STAR_DOMAIN_TYPE_NAME);
verify(starDomainElementType, times(1)).setDescription(StarDomainMetaStoreUtil.METASTORE_STAR_DOMAIN_TYPE_DESCRIPTION);
verify(metaStore, times(1)).createElementType(anyString(), eq(metaStoreElementType));
}
use of org.pentaho.metastore.api.IMetaStoreElementType in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method newElementType.
@Override
public IMetaStoreElementType newElementType(String namespace) throws MetaStoreException {
IMetaStoreElementType elementType = super.newElementType(namespace);
elementType.setMetaStoreName(getName());
return elementType;
}
use of org.pentaho.metastore.api.IMetaStoreElementType in project pentaho-kettle by pentaho.
the class KettleMetaStoreTestBase method testFunctionality.
public void testFunctionality(IMetaStore metaStore) throws MetaStoreException {
if (!metaStore.namespaceExists(namespace)) {
metaStore.createNamespace(namespace);
}
List<String> namespaces = metaStore.getNamespaces();
assertEquals(1, namespaces.size());
IMetaStoreElementType elementType = metaStore.newElementType(namespace);
elementType.setName(SHARED_DIMENSION_NAME);
elementType.setDescription(SHARED_DIMENSION_DESCRIPTION);
metaStore.createElementType(namespace, elementType);
assertNotNull(elementType.getId());
List<IMetaStoreElementType> elementTypes = metaStore.getElementTypes(namespace);
assertEquals(1, elementTypes.size());
try {
metaStore.createElementType(namespace, elementType);
fail("Duplicate creation error expected!");
} catch (MetaStoreElementTypeExistsException e) {
// OK!
} catch (MetaStoreException e) {
e.printStackTrace();
fail("Create exception needs to be MetaStoreDataTypesExistException");
}
//
try {
metaStore.deleteNamespace(namespace);
fail("Expected error while deleting namespace with content!");
} catch (MetaStoreDependenciesExistsException e) {
// OK!
List<String> dependencies = e.getDependencies();
assertNotNull(dependencies);
assertEquals(1, dependencies.size());
assertEquals(elementType.getId(), dependencies.get(0));
}
IMetaStoreElement customerDimension = generateCustomerDimensionElement(metaStore, elementType);
IMetaStoreElementOwner elementOwner = customerDimension.getOwner();
assertNotNull(elementOwner);
assertEquals("joe", elementOwner.getName());
assertEquals(MetaStoreElementOwnerType.USER, elementOwner.getOwnerType());
metaStore.createElement(namespace, elementType, customerDimension);
assertNotNull(customerDimension.getId());
List<IMetaStoreElement> elements = metaStore.getElements(namespace, elementType);
assertEquals(1, elements.size());
assertNotNull(elements.get(0));
assertEquals(CUSTOMER_DIMENSION_NAME, elements.get(0).getName());
//
try {
metaStore.deleteElementType(namespace, elementType);
fail("Expected error while deleting data type with content!");
} catch (MetaStoreDependenciesExistsException e) {
// OK!
List<String> dependencies = e.getDependencies();
assertNotNull(dependencies);
assertEquals(1, dependencies.size());
assertEquals(customerDimension.getId(), dependencies.get(0));
}
// Some lookup-by-name tests...
//
assertNotNull(metaStore.getElementTypeByName(namespace, SHARED_DIMENSION_NAME));
assertNotNull(metaStore.getElementByName(namespace, elementType, CUSTOMER_DIMENSION_NAME));
// Clean up shop!
//
metaStore.deleteElement(namespace, elementType, customerDimension.getId());
elements = metaStore.getElements(namespace, elementType);
assertEquals(0, elements.size());
metaStore.deleteElementType(namespace, elementType);
elementTypes = metaStore.getElementTypes(namespace);
assertEquals(0, elementTypes.size());
metaStore.deleteNamespace(namespace);
namespaces = metaStore.getNamespaces();
assertEquals(0, namespaces.size());
}
Aggregations