use of org.pentaho.di.starmodeler.StarDomain in project pentaho-kettle by pentaho.
the class StarDomainMetaStoreUtilTest method testLoadStarDomain.
@Test
public void testLoadStarDomain() throws Exception {
final String id = "id";
final String msName = "MSName";
when(metaStore.getName()).thenReturn(msName);
final DelegatingMetaStore delegatingMetaStore = spy(new DelegatingMetaStore(metaStore));
delegatingMetaStore.setActiveMetaStoreName(msName);
doAnswer(new Answer<IMetaStoreElementType>() {
@Override
public IMetaStoreElementType answer(InvocationOnMock invocationOnMock) throws Throwable {
return metaStore.getElementTypeByName((String) invocationOnMock.getArguments()[0], (String) invocationOnMock.getArguments()[1]);
}
}).when(delegatingMetaStore).getElementTypeByName(anyString(), anyString());
assertNull(StarDomainMetaStoreUtil.loadStarDomain(delegatingMetaStore, id));
final IMetaStoreElement metaStoreElement = mock(IMetaStoreElement.class);
final String name = "name";
when(metaStoreElement.getName()).thenReturn(name);
doReturn(metaStoreElement).when(delegatingMetaStore).getElement(anyString(), eq(metaStoreElementType), eq(id));
final StarDomain starDomain = StarDomainMetaStoreUtil.loadStarDomain(delegatingMetaStore, id);
assertEquals(id, starDomain.getObjectId().getId());
assertEquals(name, starDomain.getName());
}
use of org.pentaho.di.starmodeler.StarDomain in project pentaho-kettle by pentaho.
the class StarDomainMetaStoreUtil method loadStarDomain.
public static StarDomain loadStarDomain(DelegatingMetaStore metaStore, String id) throws MetaStoreException {
IMetaStoreElementType elementType = getStarDomainElementType(metaStore);
IMetaStoreElement element = metaStore.getElement(namespace, elementType, id);
if (element == null) {
return null;
}
StarDomain starDomain = new StarDomain();
starDomain.setObjectId(new StringObjectId(id));
starDomain.setName(element.getName());
starDomain.setDescription(getChildString(element, Attribute.ID_STAR_DOMAIN_DESCRIPTION.id));
return starDomain;
}
use of org.pentaho.di.starmodeler.StarDomain in project pentaho-kettle by pentaho.
the class JobGeneratorTest method setUp.
@Before
public void setUp() throws Exception {
final StarDomain starDomain = mock(StarDomain.class);
final Domain domain = mock(Domain.class);
when(domain.getProperty(eq(DefaultIDs.DOMAIN_TARGET_DATABASE))).thenReturn("test_domain_target_db");
when(starDomain.getDomain()).thenReturn(domain);
final Repository repository = mock(Repository.class);
final RepositoryDirectoryInterface targetDirectory = mock(RepositoryDirectoryInterface.class);
final DatabaseMeta meta = Mockito.mock(DatabaseMeta.class);
Mockito.when(meta.getName()).thenReturn("test_domain_target_db");
final LinkedList<DatabaseMeta> databases = new LinkedList<DatabaseMeta>() {
{
add(meta);
}
};
final String locale = Locale.US.toString();
jobGenerator = new JobGenerator(starDomain, repository, targetDirectory, databases, locale);
}
use of org.pentaho.di.starmodeler.StarDomain in project pentaho-kettle by pentaho.
the class StarDomainMetaStoreUtilTest method testSaveStarDomain.
@Test
public void testSaveStarDomain() throws Exception {
final StarDomain starDomain = mock(StarDomain.class);
final ObjectId objectId = mock(ObjectId.class);
final String objectIdStr = "objectIdStr";
when(objectId.toString()).thenReturn(objectIdStr);
when(starDomain.getObjectId()).thenReturn(objectId);
final String starDomainName = "starDomainName";
when(starDomain.getName()).thenReturn(starDomainName);
final IMetaStoreElement metaStoreElement = mock(IMetaStoreElement.class);
when(metaStoreElement.getId()).thenReturn("id");
when(metaStore.getElement(anyString(), eq(metaStoreElementType), eq(objectIdStr))).thenReturn(metaStoreElement);
StarDomainMetaStoreUtil.saveStarDomain(metaStore, starDomain);
verify(metaStoreElement, times(1)).setElementType(eq(metaStoreElementType));
verify(metaStoreElement, times(1)).setName(eq(starDomainName));
verify(metaStoreElement, times(1)).addChild(any(IMetaStoreAttribute.class));
verify(metaStore, times(1)).updateElement(anyString(), eq(metaStoreElementType), eq(objectIdStr), eq(metaStoreElement));
verify(starDomain, times(1)).setObjectId(any(ObjectId.class));
}
Aggregations