use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class DateFrequencyStateUtil method getCustomerDataset.
public static ICustomerDataset getCustomerDataset(List<IndicatorUnit> units, int sortType) {
CustomerDefaultCategoryDataset customerdataset = new CustomerDefaultCategoryDataset();
for (IndicatorUnit unit : units) {
if (unit.isExcuted()) {
FrequencyExt[] frequencyExt = (FrequencyExt[]) unit.getValue();
ComparatorsFactory.sort(frequencyExt, sortType);
int numOfShown = FrequencyTypeStateUtil.getNumberOfShown(unit, frequencyExt);
for (int i = 0; i < numOfShown; i++) {
FrequencyExt freqExt = frequencyExt[i];
String keyLabel = FrequencyTypeStateUtil.getKeyLabel(freqExt, 30);
customerdataset.addValue(freqExt.getValue(), unit.getIndicatorName(), keyLabel);
ChartDataEntity entity = createDataEntity(unit, freqExt, keyLabel);
customerdataset.addDataEntity(entity);
}
}
}
return customerdataset;
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class BenfordLawFrequencyStateTest method testSortIndicator.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.freq.BenfordLawFrequencyState#sortIndicator(org.talend.dq.indicators.ext.FrequencyExt[])}
* . just test normal cases: contains 1~9
*/
@SuppressWarnings("deprecation")
@Test
public void testSortIndicator() {
FrequencyExt[] frequencyExt = new FrequencyExt[9];
Long value = 100l;
for (int i = 0; i < 9; i++) {
frequencyExt[i] = new FrequencyExt();
frequencyExt[i].setKey(i + 1);
frequencyExt[i].setValue(value);
if (i > 4) {
value = value * 2;
} else {
value = value / 2;
}
}
benState.sortIndicator(frequencyExt);
for (int i = 0; i < 8; i++) {
// Assert.assertTrue(frequencyExt[i].getValue() > frequencyExt[i + 1].getValue());
Assert.assertTrue(NumberUtils.stringToInt(frequencyExt[i].getKey().toString()) < NumberUtils.stringToInt(frequencyExt[i + 1].getKey().toString()));
}
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class BenfordLawFrequencyStateTest method testSetValueToDataset.
/**
* Test method for
* {@link org.talend.dataprofiler.core.ui.editor.preview.model.states.freq.BenfordLawFrequencyState#setValueToDataset(org.talend.dataprofiler.core.ui.editor.preview.model.dataset.CustomerDefaultCategoryDataset, org.talend.dq.indicators.ext.FrequencyExt, java.lang.String)}
* .
*/
@Test
public void testSetValueToDataset() {
CustomerDefaultCategoryDataset customerdataset = new CustomerDefaultCategoryDataset();
FrequencyExt fre = new FrequencyExt();
fre.setKey(2);
fre.setValue(3l);
fre.setFrequency(0.33);
// $NON-NLS-1$
benState.setValueToDataset(customerdataset, fre, "2");
Number n = TOPChartUtils.getInstance().getValue(customerdataset.getDataset(), 0, 0);
Assert.assertEquals(0.33, n);
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class ComparatorsFactoryTest method testSortObject_1.
/**
* Test method for {@link org.talend.dataprofiler.core.ui.utils.ComparatorsFactory#sort(java.lang.Object[], int)}.
*/
@Test
public void testSortObject_1() {
FrequencyExt[] frequencyExt = new FrequencyExt[9];
Long value = 100l;
for (int i = 0; i < 9; i++) {
frequencyExt[i] = new FrequencyExt();
frequencyExt[i].setKey(i);
frequencyExt[i].setValue(value);
if (i > 5) {
value = value * 2;
} else {
value = value / 2;
}
}
Assert.assertEquals("0", frequencyExt[0].getKey().toString());
ComparatorsFactory.sort(frequencyExt, ComparatorsFactory.BENFORDLAW_FREQUENCY_COMPARATOR_ID);
for (int i = 0; i < 7; i++) {
Assert.assertTrue(frequencyExt[i].getKey().toString().compareTo(frequencyExt[i + 1].getKey().toString()) < 0);
}
Assert.assertEquals("0", frequencyExt[8].getKey().toString());
}
use of org.talend.dq.indicators.ext.FrequencyExt in project tdq-studio-se by Talend.
the class ComparatorsFactoryTest method testSortObject_2.
@SuppressWarnings("deprecation")
@Test
public void testSortObject_2() {
FrequencyExt[] frequencyExt = new FrequencyExt[9];
Long value = 100l;
double key = 1d;
for (int i = 0; i < 9; i++) {
frequencyExt[i] = new FrequencyExt();
frequencyExt[i].setKey(key);
frequencyExt[i].setValue(value);
if (i > 5) {
value = value * 2;
} else {
value = value / 2;
}
key++;
}
ComparatorsFactory.sort(frequencyExt, ComparatorsFactory.BENFORDLAW_FREQUENCY_COMPARATOR_ID);
for (int i = 0; i < 8; i++) {
Assert.assertTrue(frequencyExt[i].getKey().toString().compareTo(frequencyExt[i + 1].getKey().toString()) < 0);
}
}
Aggregations