use of org.talend.dataquality.indicators.BenfordLawFrequencyIndicator in project tdq-studio-se by Talend.
the class BenfordLawFrequencyStateTest method setUp.
/**
* init the state.
*
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
UnitTestBuildHelper.initProjectStructure();
List<IndicatorUnit> units = new ArrayList<IndicatorUnit>();
BenfordLawFrequencyIndicator benfordLawFrequencyIndicator = IndicatorsFactory.eINSTANCE.createBenfordLawFrequencyIndicator();
List<IRepositoryViewObject> all = ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.SYSTEM_INDICATORS_FRAUDDETECTION);
Assert.assertEquals(1, all.size());
IRepositoryViewObject iRepositoryViewObject = all.get(0);
Assert.assertNotNull(iRepositoryViewObject);
TDQIndicatorDefinitionItem benfordItem = (TDQIndicatorDefinitionItem) iRepositoryViewObject.getProperty().getItem();
benfordLawFrequencyIndicator.setIndicatorDefinition(benfordItem.getIndicatorDefinition());
ModelElementIndicator modelElementIndicator = UnitTestBuildHelper.createModelElementIndicator();
ColumnIndicatorUnit columnIndicatorUnit = new ColumnIndicatorUnit(IndicatorEnum.BenfordLawFrequencyIndicatorEnum, benfordLawFrequencyIndicator, modelElementIndicator);
// IndicatorUnit unit = mock(IndicatorUnit.class);
units.add(columnIndicatorUnit);
for (int i = 0; i < 10; i++) {
benfordLawFrequencyIndicator.handle(i);
}
benState = new BenfordLawFrequencyState(units);
}
use of org.talend.dataquality.indicators.BenfordLawFrequencyIndicator in project tdq-studio-se by Talend.
the class FrequencyTypeStateUtil method createChartEntity.
public static ChartDataEntity createChartEntity(Indicator indicator, FrequencyExt freqExt, String keyLabel, boolean isWithRowCountIndicator) {
ChartDataEntity entity = new ChartDataEntity();
entity.setIndicator(indicator);
// MOD mzhao feature:6307 display soundex distinct count and real count.
entity.setKey(freqExt == null ? null : freqExt.getKey());
entity.setLabelNull(freqExt == null || freqExt.getKey() == null);
entity.setLabel(keyLabel);
entity.setValue(String.valueOf(freqExt == null ? StringUtils.EMPTY : freqExt.getValue()));
if (freqExt == null) {
entity.setPercent(0.0);
} else if (indicator instanceof BenfordLawFrequencyIndicator) {
entity.setPercent(freqExt.getFrequency());
} else {
Double percent = isWithRowCountIndicator ? freqExt.getFrequency() : Double.NaN;
entity.setPercent(percent);
}
return entity;
}
Aggregations