Search in sources :

Example 56 with BasicEList

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));
}
Also used : EMFSharedResources(org.talend.dq.writer.EMFSharedResources) EObject(org.eclipse.emf.ecore.EObject) BasicEList(org.eclipse.emf.common.util.BasicEList) TdSoftwareSystem(org.talend.cwm.softwaredeployment.TdSoftwareSystem) Resource(org.eclipse.emf.ecore.resource.Resource) HashSet(java.util.HashSet) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 57 with BasicEList

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));
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) BasicEList(org.eclipse.emf.common.util.BasicEList) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) Connection(org.talend.core.model.metadata.builder.connection.Connection) Dependency(orgomg.cwm.objectmodel.core.Dependency) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 58 with BasicEList

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);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) BasicEList(org.eclipse.emf.common.util.BasicEList) ProductVersion(org.talend.utils.ProductVersion) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 59 with BasicEList

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);
}
Also used : TdExpression(org.talend.cwm.relational.TdExpression) BasicEList(org.eclipse.emf.common.util.BasicEList) ProductVersion(org.talend.utils.ProductVersion) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Test(org.junit.Test)

Example 60 with BasicEList

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()]);
}
Also used : IContentProposal(org.eclipse.jface.fieldassist.IContentProposal) ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) BasicEList(org.eclipse.emf.common.util.BasicEList) ContextParameterProposal(org.talend.core.ui.proposal.ContextParameterProposal) ArrayList(java.util.ArrayList) JobContextManager(org.talend.core.model.context.JobContextManager) IContextManager(org.talend.core.model.process.IContextManager) IContextParameter(org.talend.core.model.process.IContextParameter)

Aggregations

BasicEList (org.eclipse.emf.common.util.BasicEList)75 Test (org.junit.Test)25 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)16 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)16 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)16 EEFFeatureEditorDialog (org.eclipse.emf.eef.runtime.ui.widgets.EEFFeatureEditorDialog)16 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)16 GridData (org.eclipse.swt.layout.GridData)16 TdExpression (org.talend.cwm.relational.TdExpression)11 EObject (org.eclipse.emf.ecore.EObject)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)9 UDIndicatorDefinition (org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition)9 ProductVersion (org.talend.utils.ProductVersion)9 Button (org.eclipse.swt.widgets.Button)8 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)6 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)6 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)5 Widget (org.eclipse.smarthome.model.sitemap.Widget)5