use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class DependenciesHandlerTest method testSetUsageDependencyOnModelElementModelElementCase2.
/**
* Test method for
* {@link org.talend.cwm.dependencies.DependenciesHandler#setUsageDependencyOn(ModelElement, ModelElement)} . 、
* case2 supplier side is lost
*/
@Test
public void testSetUsageDependencyOnModelElementModelElementCase2() {
// analysis init
TDQAnalysisItem analysisItem = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
// $NON-NLS-1$
analysis.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase2Analysis");
analysisItem.setAnalysis(analysis);
Property propertyAna = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
propertyAna.setId(EcoreUtil.generateUUID());
// $NON-NLS-1$
propertyAna.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase2Analysis");
analysisItem.setProperty(propertyAna);
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
analysisItem.setState(itemState);
AnalysisResult analysisResult1 = AnalysisFactory.eINSTANCE.createAnalysisResult();
analysis.setResults(analysisResult1);
analysis.setContext(AnalysisFactory.eINSTANCE.createAnalysisContext());
try {
ProxyRepositoryFactory.getInstance().create(analysisItem, Path.EMPTY, false);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
// UDI init
TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem = PropertiesFactoryImpl.eINSTANCE.createTDQIndicatorDefinitionItem();
UserDefIndicator createUserDefIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
// $NON-NLS-1$
createIndicatorDefinition.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase2UDI");
createTDQIndicatorDefinitionItem.setIndicatorDefinition(createIndicatorDefinition);
createUserDefIndicator.setIndicatorDefinition(createIndicatorDefinition);
Property propertyUDI = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
propertyUDI.setId(EcoreUtil.generateUUID());
// $NON-NLS-1$
propertyUDI.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase2UDI");
createTDQIndicatorDefinitionItem.setProperty(propertyUDI);
try {
ProxyRepositoryFactory.getInstance().create(createTDQIndicatorDefinitionItem, new Path(EResourceConstant.USER_DEFINED_INDICATORS.getName()), false);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
// init UDI supplier Dependency
analysisResult1.getIndicators().add(createUserDefIndicator);
ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, true);
if (!createIndicatorDefinition.getSupplierDependency().isEmpty()) {
createIndicatorDefinition.getSupplierDependency().get(0).getClient().clear();
}
Analysis analysisFromFile = AnalysisFactory.eINSTANCE.createAnalysis();
try {
analysis.eResource().unload();
IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(propertyAna.getId());
analysisFromFile = ((TDQAnalysisItem) lastVersion.getProperty().getItem()).getAnalysis();
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
// call the test method
TypedReturnCode<Dependency> setUsageDependencyOn = DependenciesHandler.getInstance().setUsageDependencyOn(analysisFromFile, createIndicatorDefinition);
// $NON-NLS-1$
Assert.assertEquals("call setUsageDependencyOn method should return ok stauts", true, setUsageDependencyOn.isOk());
Assert.assertEquals(analysisFromFile, setUsageDependencyOn.getObject().getClient().get(0));
Assert.assertEquals(1, setUsageDependencyOn.getObject().getClient().size());
Assert.assertEquals(createIndicatorDefinition, setUsageDependencyOn.getObject().getSupplier().get(0));
Assert.assertEquals(1, setUsageDependencyOn.getObject().getSupplier().size());
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class DependenciesHandlerTest method testSetUsageDependencyOnModelElementModelElementCase1.
/**
* Test method for
* {@link org.talend.cwm.dependencies.DependenciesHandler#setUsageDependencyOn(ModelElement, ModelElement)} . case1
* noraml case the dependency has been set between clint and supplier
*/
@Test
public void testSetUsageDependencyOnModelElementModelElementCase1() {
// analysis init
TDQAnalysisItem analysisItem = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
// $NON-NLS-1$
analysis.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase1Analysis");
analysisItem.setAnalysis(analysis);
Property propertyAna = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
propertyAna.setId(EcoreUtil.generateUUID());
// $NON-NLS-1$
propertyAna.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase1Analysis");
analysisItem.setProperty(propertyAna);
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
analysisItem.setState(itemState);
AnalysisResult analysisResult1 = AnalysisFactory.eINSTANCE.createAnalysisResult();
analysis.setResults(analysisResult1);
analysis.setContext(AnalysisFactory.eINSTANCE.createAnalysisContext());
try {
ProxyRepositoryFactory.getInstance().create(analysisItem, Path.EMPTY, false);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
// UDI init
TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem = PropertiesFactoryImpl.eINSTANCE.createTDQIndicatorDefinitionItem();
UserDefIndicator createUserDefIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
// $NON-NLS-1$
createIndicatorDefinition.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase1UDI");
createTDQIndicatorDefinitionItem.setIndicatorDefinition(createIndicatorDefinition);
createUserDefIndicator.setIndicatorDefinition(createIndicatorDefinition);
Property propertyUDI = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
propertyUDI.setId(EcoreUtil.generateUUID());
// $NON-NLS-1$
propertyUDI.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase1UDI");
createTDQIndicatorDefinitionItem.setProperty(propertyUDI);
try {
ProxyRepositoryFactory.getInstance().create(createTDQIndicatorDefinitionItem, new Path(EResourceConstant.USER_DEFINED_INDICATORS.getName()), false);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
// init UDI supplier Dependency
analysisResult1.getIndicators().add(createUserDefIndicator);
ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, true);
if (!createIndicatorDefinition.getSupplierDependency().isEmpty()) {
createIndicatorDefinition.getSupplierDependency().get(0).getClient().clear();
}
// call the test method
TypedReturnCode<Dependency> setUsageDependencyOn = DependenciesHandler.getInstance().setUsageDependencyOn(analysis, createIndicatorDefinition);
// $NON-NLS-1$
Assert.assertEquals("call setUsageDependencyOn method should return ok stauts", true, setUsageDependencyOn.isOk());
Assert.assertEquals(analysis, setUsageDependencyOn.getObject().getClient().get(0));
Assert.assertEquals(1, setUsageDependencyOn.getObject().getClient().size());
Assert.assertEquals(createIndicatorDefinition, setUsageDependencyOn.getObject().getSupplier().get(0));
Assert.assertEquals(1, setUsageDependencyOn.getObject().getSupplier().size());
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class DependenciesHandlerTest method testSetUsageDependencyOnModelElementModelElementCase3.
/**
* Test method for
* {@link org.talend.cwm.dependencies.DependenciesHandler#setUsageDependencyOn(ModelElement, ModelElement)} . case3
* client side is lost
*/
@Test
public void testSetUsageDependencyOnModelElementModelElementCase3() {
// analysis init
TDQAnalysisItem analysisItem = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
// $NON-NLS-1$
analysis.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase3Analysis");
analysisItem.setAnalysis(analysis);
Property propertyAna = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
propertyAna.setId(EcoreUtil.generateUUID());
// $NON-NLS-1$
propertyAna.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase3Analysis");
analysisItem.setProperty(propertyAna);
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
analysisItem.setState(itemState);
AnalysisResult analysisResult1 = AnalysisFactory.eINSTANCE.createAnalysisResult();
analysis.setResults(analysisResult1);
analysis.setContext(AnalysisFactory.eINSTANCE.createAnalysisContext());
try {
ProxyRepositoryFactory.getInstance().create(analysisItem, Path.EMPTY, false);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
// UDI init
TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem = PropertiesFactoryImpl.eINSTANCE.createTDQIndicatorDefinitionItem();
UserDefIndicator createUserDefIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
// $NON-NLS-1$
createIndicatorDefinition.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase3UDI");
createTDQIndicatorDefinitionItem.setIndicatorDefinition(createIndicatorDefinition);
createUserDefIndicator.setIndicatorDefinition(createIndicatorDefinition);
Property propertyUDI = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
propertyUDI.setId(EcoreUtil.generateUUID());
// $NON-NLS-1$
propertyUDI.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase3UDI");
createTDQIndicatorDefinitionItem.setProperty(propertyUDI);
try {
ProxyRepositoryFactory.getInstance().create(createTDQIndicatorDefinitionItem, new Path(EResourceConstant.USER_DEFINED_INDICATORS.getName()), false);
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
// init UDI supplier Dependency
analysisResult1.getIndicators().add(createUserDefIndicator);
ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, true);
if (!analysis.getClientDependency().isEmpty()) {
analysis.getClientDependency().get(0).getSupplier().clear();
}
IndicatorDefinition createIndicatorDefinitionFromFile = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
try {
createIndicatorDefinition.eResource().unload();
IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(propertyUDI.getId());
createIndicatorDefinitionFromFile = ((TDQIndicatorDefinitionItem) lastVersion.getProperty().getItem()).getIndicatorDefinition();
} catch (PersistenceException e) {
Assert.fail(e.getMessage());
}
// call the test method
TypedReturnCode<Dependency> setUsageDependencyOn = DependenciesHandler.getInstance().setUsageDependencyOn(analysis, createIndicatorDefinitionFromFile);
// $NON-NLS-1$
Assert.assertEquals("call setUsageDependencyOn method should return ok stauts", true, setUsageDependencyOn.isOk());
Assert.assertEquals(analysis, setUsageDependencyOn.getObject().getClient().get(0));
Assert.assertEquals(1, setUsageDependencyOn.getObject().getClient().size());
Assert.assertEquals(createIndicatorDefinitionFromFile, setUsageDependencyOn.getObject().getSupplier().get(0));
Assert.assertEquals(1, setUsageDependencyOn.getObject().getSupplier().size());
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class AnalysisHandlerTest method testGetDefaultLoadedRowCount.
/**
* Test method for {@link org.talend.dq.analysis.AnalysisHandler#getDefaultLoadedRowCount()}.
*/
@Test
public void testGetDefaultLoadedRowCount() {
int rowCountValue = 100;
Analysis createAna = AnalysisFactory.eINSTANCE.createAnalysis();
AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
createAna.setResults(createAnalysisResult);
ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
createAnalysisResult.setResultMetadata(createExecutionInformations);
AnalysisHandler createHandler = AnalysisHandler.createHandler(createAna);
// default case the value should be 50
String defaultLoadedRowCount = createHandler.getDefaultLoadedRowCount();
Assert.assertEquals(Integer.valueOf(50), Integer.valueOf(defaultLoadedRowCount));
// after setting the value the result should be changed
TaggedValueHelper.setTaggedValue(createAna, TaggedValueHelper.PREVIEW_ROW_NUMBER, String.valueOf(rowCountValue));
defaultLoadedRowCount = createHandler.getDefaultLoadedRowCount();
Assert.assertEquals(Integer.valueOf(rowCountValue), Integer.valueOf(defaultLoadedRowCount));
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class AnalysisExecutorHelperTest method testCheckPatternWithOutDependencyFiles.
@Test
public void testCheckPatternWithOutDependencyFiles() {
// Load analysis item/property model from test file.
// $NON-NLS-1$
String anaPropertyFile = "/data/builtin/pattern_without_dep/TDQ_Data_Profiling/Analyses/patternMatchAna_0.1.properties";
Resource anaPropertyResource = getPlatformResource(anaPropertyFile);
Analysis ana = null;
Property anaProperty = null;
while (anaPropertyResource.getAllContents().hasNext()) {
EObject eobj = anaPropertyResource.getAllContents().next();
if (eobj instanceof Property) {
anaProperty = (Property) eobj;
ana = ((TDQAnalysisItem) anaProperty.getItem()).getAnalysis();
break;
}
}
if (ana == null) {
Assert.fail("The analysis is null!");
}
if (ana.getResults() == null) {
Assert.fail("The result of analysis is null!");
}
if (ana.getResults().getIndicators() == null) {
Assert.fail("The indicators of analysis is null!");
}
assertTrue(ana.getResults().getIndicators().get(0).getParameters().getDataValidDomain().getPatterns().get(0).getName() == null);
ReturnCode rc = AnalysisExecutorHelper.check(ana);
assertTrue(rc.isOk());
assertTrue(ana.getResults().getIndicators().get(0).getParameters().getDataValidDomain().getPatterns().get(0).getName() == null);
}
Aggregations