use of org.eclipse.emf.common.util.BasicEList in project tdq-studio-se by Talend.
the class SoftwareSystemManagerTest method testGetNewDBTypes.
@Test
public void testGetNewDBTypes() {
SoftwareSystemManager softwareSystemManger = SoftwareSystemManager.getInstance();
Set<String> existingTypes = new HashSet<String>();
// $NON-NLS-1$
existingTypes.add("MYSQL");
// $NON-NLS-1$
existingTypes.add("oracle");
PowerMockito.mockStatic(EMFSharedResources.class);
EMFSharedResources emfSharedResourceMock = mock(EMFSharedResources.class);
when(EMFSharedResources.getInstance()).thenReturn(emfSharedResourceMock).thenReturn(emfSharedResourceMock);
Resource softwareSysResource = mock(Resource.class);
when(emfSharedResourceMock.getSoftwareDeploymentResource()).thenReturn(softwareSysResource);
EList<EObject> existedSystems = new BasicEList<EObject>();
TdSoftwareSystem softwareSystem1 = SoftwaredeploymentPackage.eINSTANCE.getSoftwaredeploymentFactory().createTdSoftwareSystem();
// $NON-NLS-1$
softwareSystem1.setSubtype("mysql");
TdSoftwareSystem softwareSystem2 = SoftwaredeploymentPackage.eINSTANCE.getSoftwaredeploymentFactory().createTdSoftwareSystem();
// $NON-NLS-1$
softwareSystem2.setSubtype("VERTICA");
TdSoftwareSystem softwareSystem3 = SoftwaredeploymentPackage.eINSTANCE.getSoftwaredeploymentFactory().createTdSoftwareSystem();
// $NON-NLS-1$
softwareSystem3.setSubtype("Oracle");
existedSystems.add(softwareSystem1);
existedSystems.add(softwareSystem2);
existedSystems.add(softwareSystem3);
when(softwareSysResource.getContents()).thenReturn(existedSystems);
List<String> newTypes = softwareSystemManger.getNewDBTypesFromSoftwareSystem(existingTypes);
Assert.assertEquals(1, newTypes.size());
// $NON-NLS-1$
Assert.assertEquals("VERTICA", newTypes.get(0));
}
use of org.eclipse.emf.common.util.BasicEList in project tdq-studio-se by Talend.
the class EObjectHelperTest method testGetFirstDependency.
/**
* Test method for
* {@link org.talend.dq.helper.EObjectHelper#getFirstDependency(org.talend.repository.model.IRepositoryNode)}.
*/
@Test
public void testGetFirstDependency() {
// test when the node is null
List<ModelElement> firstDependency = EObjectHelper.getFirstDependency(null);
assertTrue(firstDependency.isEmpty());
IRepositoryNode tableNode = mock(IRepositoryNode.class);
MetadataTable mod = mock(MetadataTable.class);
// $NON-NLS-1$
when(mod.getName()).thenReturn("mod");
PowerMockito.mockStatic(RepositoryNodeHelper.class);
when(RepositoryNodeHelper.getMetadataElement(tableNode)).thenReturn(mod);
Connection connection = mock(Connection.class);
PowerMockito.mockStatic(ModelElementHelper.class);
when(ModelElementHelper.getConnection(mod)).thenReturn(connection);
EList<Dependency> supplierDependency = new BasicEList<Dependency>();
when(connection.getSupplierDependency()).thenReturn(supplierDependency);
// when there is no SupplierDependency for this node
assertTrue(EObjectHelper.getFirstDependency(tableNode).isEmpty());
// add some analysis to use this table node
Analysis analysis = mock(Analysis.class);
Dependency dependency = mock(Dependency.class);
when(dependency.getKind()).thenReturn(DependenciesHandler.USAGE);
EList<ModelElement> analysisList = new BasicEList<ModelElement>();
analysisList.add(analysis);
when(dependency.getClient()).thenReturn(analysisList);
when(analysis.eIsProxy()).thenReturn(false);
supplierDependency.add(dependency);
when(connection.getSupplierDependency()).thenReturn(supplierDependency);
AnalysisParameters parameters = mock(AnalysisParameters.class);
when(parameters.getExecutionLanguage()).thenReturn(ExecutionLanguage.SQL);
when(analysis.getParameters()).thenReturn(parameters);
AnalysisContext context = mock(AnalysisContext.class);
when(analysis.getContext()).thenReturn(context);
EList<ModelElement> modList = new BasicEList<ModelElement>();
modList.add(mod);
when(ModelElementHelper.compareUUID(mod, mod)).thenReturn(true);
MetadataTable mod1 = mock(MetadataTable.class);
// $NON-NLS-1$
when(mod1.getName()).thenReturn("mod1");
when(mod1.eIsProxy()).thenReturn(false);
modList.add(mod1);
MetadataTable mod2 = mock(MetadataTable.class);
// $NON-NLS-1$
when(mod2.getName()).thenReturn("mod2");
when(mod2.eIsProxy()).thenReturn(false);
modList.add(mod2);
when(context.getAnalysedElements()).thenReturn(modList);
assertFalse(EObjectHelper.getFirstDependency(tableNode).isEmpty());
assertEquals(analysis, EObjectHelper.getFirstDependency(tableNode).get(0));
}
use of org.eclipse.emf.common.util.BasicEList in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetSqlExpressionDB2Case5.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
*/
@Test
public void testGetSqlExpressionDB2Case5() {
// $NON-NLS-1$
String sqlLang = "SQL";
// $NON-NLS-1$
String sqlBody = "SQL body";
// $NON-NLS-1$
String db2Lang = "DB2";
// $NON-NLS-1$
String db2Body = "DB2 body";
// $NON-NLS-1$
String db2NTLang = "DB2/NT";
// $NON-NLS-1$
String db2NTBody = "DB2/NT body";
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
// $NON-NLS-1$
String language = "unknown";
EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression1.setLanguage(sqlLang);
tdExpression1.setBody(sqlBody);
sqlGenericExpression.add(tdExpression1);
TdExpression tdExpression2 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression2.setLanguage(db2Lang);
tdExpression2.setBody(db2Body);
sqlGenericExpression.add(tdExpression2);
TdExpression tdExpression3 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression3.setLanguage(db2NTLang);
tdExpression3.setBody(db2NTBody);
sqlGenericExpression.add(tdExpression3);
ProductVersion dbVersion = new ProductVersion(1, 0);
TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, language, sqlGenericExpression, dbVersion);
Assert.assertEquals(tdExpression1, sqlExpression);
}
use of org.eclipse.emf.common.util.BasicEList in project tdq-studio-se by Talend.
the class DbmsLanguageTest method testGetSqlExpressionDB2Case3.
/**
* Test method for
* {@link org.talend.dq.dbms.DbmsLanguage#getSqlExpression(IndicatorDefinition, String, EList, ProductVersion)} .
*/
@Test
public void testGetSqlExpressionDB2Case3() {
// $NON-NLS-1$
String sqlLang = "SQL";
// $NON-NLS-1$
String sqlBody = "SQL body";
// $NON-NLS-1$
String db2Lang = "DB2";
// $NON-NLS-1$
String db2Body = "DB2 body";
// $NON-NLS-1$
String db2NTLang = "DB2/NT";
IndicatorDefinition indicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
String language = db2NTLang;
EList<TdExpression> sqlGenericExpression = new BasicEList<TdExpression>();
TdExpression tdExpression1 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression1.setLanguage(sqlLang);
tdExpression1.setBody(sqlBody);
sqlGenericExpression.add(tdExpression1);
TdExpression tdExpression2 = RelationalFactory.eINSTANCE.createTdExpression();
tdExpression2.setLanguage(db2Lang);
tdExpression2.setBody(db2Body);
sqlGenericExpression.add(tdExpression2);
ProductVersion dbVersion = new ProductVersion(1, 0);
TdExpression sqlExpression = DbmsLanguage.getSqlExpression(indicatorDefinition, language, sqlGenericExpression, dbVersion);
Assert.assertEquals(tdExpression2, sqlExpression);
}
use of org.eclipse.emf.common.util.BasicEList in project tdq-studio-se by Talend.
the class TdqProposalProvider method getProposals.
public IContentProposal[] getProposals(String contents, int position) {
List<IContentProposal> proposals = new ArrayList<IContentProposal>();
if (this.getSupportContextEditor() != null && this.getSupportContextEditor().getContextManager() != null) {
IContextManager contextManager = this.getSupportContextEditor().getContextManager();
String defaultContextName = contextManager.getDefaultContext().getName();
EList<ContextType> contexts = new BasicEList<ContextType>();
contextManager.saveToEmf(contexts);
List<IContextParameter> ctxParams = new JobContextManager(contexts, defaultContextName).getDefaultContext().getContextParameterList();
for (IContextParameter ctxParam : ctxParams) {
proposals.add(new ContextParameterProposal(ctxParam));
}
}
return proposals.toArray(new IContentProposal[proposals.size()]);
}
Aggregations