Search in sources :

Example 16 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class AElementPersistanceRealTest method testCreateItemAnalysis.

/**
 * Test method for
 * {@link org.talend.dq.writer.AElementPersistance#createItem(orgomg.cwm.objectmodel.core.ModelElement)}.
 */
@Test
public void testCreateItemAnalysis() {
    AnalysisWriter createAnalysisWrite = ElementWriterFactory.getInstance().createAnalysisWrite();
    // test normal name
    // $NON-NLS-1$
    String anaName = "ana1";
    // $NON-NLS-1$
    String exceptedFileName = anaName + "_0.1.ana";
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    createAnalysis.setName(anaName);
    Item createItem = createAnalysisWrite.createItem(createAnalysis);
    assertTrue(createItem instanceof TDQAnalysisItem);
    TDQAnalysisItem analysisItem = (TDQAnalysisItem) createItem;
    assertTrue(analysisItem.getFilename().equals(exceptedFileName));
    // test special name
    // $NON-NLS-1$
    String anaNameWithSpecialChar = "ana1~!`";
    // $NON-NLS-1$
    String exceptedFileName2 = "ana1____0.1.ana";
    Analysis createAnalysis2 = AnalysisFactory.eINSTANCE.createAnalysis();
    createAnalysis2.setName(anaNameWithSpecialChar);
    Item createItem2 = createAnalysisWrite.createItem(createAnalysis2);
    assertTrue(createItem2 instanceof TDQAnalysisItem);
    TDQAnalysisItem analysisItem2 = (TDQAnalysisItem) createItem2;
    assertTrue(analysisItem2.getFilename().equals(exceptedFileName2));
}
Also used : TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) Item(org.talend.core.model.properties.Item) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Test(org.junit.Test)

Example 17 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class AElementPersistanceRealTest method testSaveWithoutDependenciesReport.

/**
 * Test method for
 * {@link org.talend.dq.writer.AElementPersistance#saveWithoutDependencies(org.talend.core.model.properties.Item, orgomg.cwm.objectmodel.core.ModelElement)}
 * .
 *
 * @throws PersistenceException
 */
@Test
public void testSaveWithoutDependenciesReport() throws PersistenceException {
    ReportWriter createReportWriter = ElementWriterFactory.getInstance().createReportWriter();
    // create analysis
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    createAnalysis.setResults(createAnalysisResult);
    // $NON-NLS-1$
    createAnalysis.setName("AElementPersistanceRealTestanalysis6");
    // create analysis item
    TDQAnalysisItem createTDQAnalysisItem = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
    createTDQAnalysisItem.setAnalysis(createAnalysis);
    Property createAnalysisProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    // $NON-NLS-1$
    createAnalysisProperty.setLabel("AElementPersistanceRealTestanalysis6");
    createAnalysisProperty.setId(EcoreUtil.generateUUID());
    createTDQAnalysisItem.setProperty(createAnalysisProperty);
    ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem, Path.EMPTY, false);
    // create report
    TdReport createTdReport = ReportsFactory.eINSTANCE.createTdReport();
    TDQReportItem createTDQReportItem = PropertiesFactory.eINSTANCE.createTDQReportItem();
    createTDQReportItem.setReport(createTdReport);
    Property createReportProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    // $NON-NLS-1$
    createReportProperty.setLabel("AElementPersistanceRealTestreport6");
    createTDQReportItem.setProperty(createReportProperty);
    createReportProperty.setId(EcoreUtil.generateUUID());
    ProxyRepositoryFactory.getInstance().create(createTDQReportItem, Path.EMPTY, false);
    createTdReport.addAnalysis(createAnalysis);
    // $NON-NLS-1$
    String repName = "rep61";
    // $NON-NLS-1$
    String exceptedFileName = repName + "_0.1.rep";
    createTdReport.setName(repName);
    ReturnCode create = createReportWriter.saveWithoutDependencies(createTDQReportItem, createTdReport);
    assertTrue(create.isOk());
    Assert.assertEquals(exceptedFileName, createTDQReportItem.getFilename());
    // $NON-NLS-1$
    String repName2 = "rep62";
    // $NON-NLS-1$
    String exceptedFileName2 = repName2 + "_0.1.rep";
    createTdReport.setName(repName2);
    create = createReportWriter.saveWithDependencies(createTDQReportItem, createTdReport);
    assertTrue(create.isOk());
    Assert.assertEquals(exceptedFileName2, createTDQReportItem.getFilename());
}
Also used : ReportWriter(org.talend.dq.writer.impl.ReportWriter) ReturnCode(org.talend.utils.sugars.ReturnCode) Analysis(org.talend.dataquality.analysis.Analysis) TdReport(org.talend.dataquality.reports.TdReport) Property(org.talend.core.model.properties.Property) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Test(org.junit.Test)

Example 18 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class EMFSharedResourcesTest method createRealAnalysis.

private Item createRealAnalysis(String name, IFolder folder, Boolean isDelete) {
    IPath createPath = Path.EMPTY;
    if (folder != null) {
        createPath = new Path(folder.getFullPath().lastSegment());
    }
    Analysis analysis1 = AnalysisHelper.createAnalysis(name);
    TDQAnalysisItem item1 = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
    org.talend.core.model.properties.Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    property1.setId(EcoreUtil.generateUUID());
    property1.setItem(item1);
    property1.setLabel(analysis1.getName());
    item1.setProperty(property1);
    item1.setAnalysis(analysis1);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(isDelete);
    item1.setState(itemState);
    AnalysisResult analysisResult1 = AnalysisFactory.eINSTANCE.createAnalysisResult();
    analysis1.setResults(analysisResult1);
    try {
        ProxyRepositoryFactory.getInstance().create(item1, createPath, false);
    } catch (PersistenceException e) {
        fail(e.getMessage());
    }
    return item1;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 19 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class UnitTestBuildHelper method createRealAnalysis.

/**
 * DOC qiongli Comment method "createRealAnalysis".
 *
 * @param name
 * @param folder
 * @param isDelete
 * @return
 */
public static Analysis createRealAnalysis(String name, IFolder folder, Boolean isDelete) {
    IPath createPath = Path.EMPTY;
    if (folder != null) {
        createPath = new Path(folder.getFullPath().lastSegment());
    }
    Analysis analysis1 = AnalysisHelper.createAnalysis(name);
    TDQAnalysisItem item1 = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
    org.talend.core.model.properties.Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    property1.setId(EcoreUtil.generateUUID());
    property1.setItem(item1);
    property1.setLabel(analysis1.getName());
    item1.setProperty(property1);
    item1.setAnalysis(analysis1);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(isDelete);
    item1.setState(itemState);
    AnalysisResult analysisResult1 = AnalysisFactory.eINSTANCE.createAnalysisResult();
    analysis1.setResults(analysisResult1);
    try {
        ProxyRepositoryFactory.getInstance().create(item1, createPath, false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    return analysis1;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 20 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class DataExplorerTestHelper method getAnalysis.

public static Analysis getAnalysis(Indicator indicator, DbmsLanguage dbmsLanguage) {
    Analysis analysis = mock(Analysis.class);
    AnalysisContext context = mock(AnalysisContext.class);
    when(analysis.getContext()).thenReturn(context);
    DataManager dataManager = mock(DataManager.class);
    when(context.getConnection()).thenReturn(dataManager);
    // mock setEntity
    when(indicator.eClass()).thenReturn(null);
    // MOCKING STATIC METHODS
    stub(method(DbmsLanguageFactory.class, "createDbmsLanguage", DataManager.class, ExecutionLanguage.class)).toReturn(dbmsLanguage);
    return analysis;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext)

Aggregations

Analysis (org.talend.dataquality.analysis.Analysis)137 Test (org.junit.Test)36 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)36 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)30 ArrayList (java.util.ArrayList)28 Property (org.talend.core.model.properties.Property)28 Indicator (org.talend.dataquality.indicators.Indicator)27 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)27 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)26 PersistenceException (org.talend.commons.exception.PersistenceException)19 Connection (org.talend.core.model.metadata.builder.connection.Connection)18 ReturnCode (org.talend.utils.sugars.ReturnCode)18 Dependency (orgomg.cwm.objectmodel.core.Dependency)18 TdColumn (org.talend.cwm.relational.TdColumn)16 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)16 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)15 Pattern (org.talend.dataquality.domain.pattern.Pattern)15 IFile (org.eclipse.core.resources.IFile)14 File (java.io.File)12 IPath (org.eclipse.core.runtime.IPath)12