Search in sources :

Example 36 with IMetaStoreElementType

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));
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 37 with IMetaStoreElementType

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());
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) Test(org.junit.Test)

Example 38 with IMetaStoreElementType

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));
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) Test(org.junit.Test)

Example 39 with IMetaStoreElementType

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;
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType)

Example 40 with IMetaStoreElementType

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());
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException) IMetaStoreElementOwner(org.pentaho.metastore.api.security.IMetaStoreElementOwner) List(java.util.List) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)

Aggregations

IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)40 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)19 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)12 MetaStoreDependenciesExistsException (org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)10 ArrayList (java.util.ArrayList)9 Test (org.junit.Test)9 IMetaStore (org.pentaho.metastore.api.IMetaStore)9 MetaStoreElementTypeExistsException (org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)9 StringObjectId (org.pentaho.di.repository.StringObjectId)7 MetaStoreElementExistException (org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)7 LongObjectId (org.pentaho.di.repository.LongObjectId)6 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)6 Matchers.anyString (org.mockito.Matchers.anyString)4 List (java.util.List)3 ObjectId (org.pentaho.di.repository.ObjectId)3 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)2 StarDomain (org.pentaho.di.starmodeler.StarDomain)2