本文整理汇总了Java中org.datacleaner.data.MockInputColumn类的典型用法代码示例。如果您正苦于以下问题:Java MockInputColumn类的具体用法?Java MockInputColumn怎么用?Java MockInputColumn使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MockInputColumn类属于org.datacleaner.data包,在下文中一共展示了MockInputColumn类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testConfigureByConfigurableBean
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testConfigureByConfigurableBean() throws Exception {
final IdGenerator IdGenerator = new PrefixedIdGenerator("");
final TransformerDescriptor<ConvertToNumberTransformer> descriptor =
Descriptors.ofTransformer(ConvertToNumberTransformer.class);
final TransformerComponentBuilder<ConvertToNumberTransformer> builder =
new TransformerComponentBuilder<>(new AnalysisJobBuilder(null), descriptor, IdGenerator);
assertFalse(builder.isConfigured());
final ConvertToNumberTransformer configurableBean = builder.getComponentInstance();
final InputColumn<String> input = new MockInputColumn<>("foo", String.class);
configurableBean.setInput(input);
assertTrue(builder.isConfigured(true));
final ConfiguredPropertyDescriptor propertyDescriptor =
descriptor.getConfiguredPropertiesForInput().iterator().next();
final InputColumn<?>[] value = (InputColumn<?>[]) builder.getConfiguredProperties().get(propertyDescriptor);
assertEquals("[MockInputColumn[name=foo]]", Arrays.toString(value));
}
示例2: testSerializeAndDeserialize
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testSerializeAndDeserialize() throws Exception {
final RowAnnotationFactory annotationFactory = RowAnnotations.getDefaultFactory();
final RowAnnotation annotation = annotationFactory.createAnnotation();
final InputColumn<String> col1 = new MockInputColumn<>("foo", String.class);
final InputColumn<String> col2 = new MockInputColumn<>("bar", String.class);
annotationFactory.annotate(new MockInputRow().put(col1, "1").put(col2, "2"), 1, annotation);
annotationFactory.annotate(new MockInputRow().put(col1, "3").put(col2, "4"), 1, annotation);
final AnnotatedRowsResult result1 = new AnnotatedRowsResult(annotation, annotationFactory, col1);
performAssertions(result1);
final AnnotatedRowsResult result2 =
(AnnotatedRowsResult) SerializationUtils.deserialize(SerializationUtils.serialize(result1));
performAssertions(result2);
}
示例3: testRefreshInputColumns
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
@Test
public void testRefreshInputColumns() throws Exception {
// original columns - col1 and col2
final InputColumn<?> col1 = new MockInputColumn<>("foo1", String.class);
final InputColumn<?> col2 = new MockInputColumn<>("foo2", String.class);
final InputColumn<?>[] allInputColumns1 = new InputColumn[] { col1, col2 };
// cloned columns - col3 and col4
final InputColumn<?> col3 = new MockInputColumn<>("foo1", String.class);
final InputColumn<?> col4 = new MockInputColumn<>("foo2", String.class);
final InputColumn<?>[] allInputColumns2 = new InputColumn[] { col3, col4 };
CoalesceUnit unit = new CoalesceUnit(allInputColumns1);
Assert.assertArrayEquals(allInputColumns1, unit.getInputColumns());
unit = unit.updateInputColumns(allInputColumns2);
Assert.assertArrayEquals(allInputColumns2, unit.getInputColumns());
}
示例4: testSimpleScenario
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testSimpleScenario() throws Exception {
final MockInputColumn<String> col = new MockInputColumn<>("foo", String.class);
final DateMaskMatcherTransformer t = new DateMaskMatcherTransformer(col);
t.setDateMasks(new String[] { "yyyy-MM-dd", "yyyy-dd-MM" });
t.init();
final OutputColumns outputColumns = t.getOutputColumns();
assertEquals(2, outputColumns.getColumnCount());
assertEquals("foo 'yyyy-MM-dd'", outputColumns.getColumnName(0));
assertEquals("foo 'yyyy-dd-MM'", outputColumns.getColumnName(1));
assertEquals("[true, false]", Arrays.toString(t.transform(new MockInputRow().put(col, "2010-03-21"))));
assertEquals("[false, false]", Arrays.toString(t.transform(new MockInputRow().put(col, "hello world"))));
assertEquals("[false, false]", Arrays.toString(t.transform(new MockInputRow().put(col, null))));
assertEquals("[true, true]", Arrays.toString(t.transform(new MockInputRow().put(col, "2010-03-11"))));
assertEquals("[false, false]", Arrays.toString(t.transform(new MockInputRow().put(col, "2010/03/21"))));
}
示例5: testFindAllNoMatch
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testFindAllNoMatch() throws Exception {
final MockOutputRowCollector outputRowCollector = new MockOutputRowCollector();
final MockInputColumn<String> col = new MockInputColumn<>("foobar", String.class);
final RegexParserTransformer t = new RegexParserTransformer();
t.column = col;
t.pattern = Pattern.compile("(\\d+\\,?\\d*)(x|X)(\\d+\\,?\\d*)");
t.mode = RegexParserTransformer.Mode.FIND_ALL;
t.outputRowCollector = outputRowCollector;
final String[] transformResult1 = t.transform(new MockInputRow().put(col, "foo"));
assertEquals("[null, null, null, null]", Arrays.toString(transformResult1));
final List<Object[]> output1 = outputRowCollector.getOutput();
assertEquals(0, output1.size());
}
示例6: before
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
@Before
public void before() {
final InputColumn<String> baseColumn = new MockInputColumn<>("baseCol", String.class);
_stringColumn = new MockInputColumn<>("stringCol", String.class);
final InputColumn<?> numberColumn = new MockInputColumn<>("numberCol", Number.class);
final InputColumn<?> listColumn = new MockInputColumn<>("listCol", List.class);
// Just to test that other types doesn't sent it spinning
final InputColumn<?> booleanColumn = new MockInputColumn<>("booleanCol", Boolean.class);
final InputColumn<?>[] subtractColumns =
new InputColumn[] { _stringColumn, numberColumn, listColumn, booleanColumn };
_inputRow =
new MockInputRow().put(baseColumn, "hello goodbye, 5, a, 2, c, true, false").put(_stringColumn, "bye")
.put(numberColumn, 5).put(listColumn, Arrays.asList("a", 2, false)).put(booleanColumn, true);
_transformer = new RemoveSubstringTransformer();
_transformer.baseColumn = baseColumn;
_transformer.substringColumns = subtractColumns;
}
示例7: testTransformDefaultDateConfiguration
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testTransformDefaultDateConfiguration() throws Exception {
final DatePartTransformer transformer = new DatePartTransformer();
final MockInputColumn<Date> column = new MockInputColumn<>("my date", Date.class);
transformer.column = column;
final OutputColumns outputColumns = transformer.getOutputColumns();
assertEquals(3, outputColumns.getColumnCount());
assertEquals("my date (year)", outputColumns.getColumnName(0));
assertEquals("my date (month)", outputColumns.getColumnName(1));
assertEquals("my date (day of month)", outputColumns.getColumnName(2));
final Date date = DateUtils.get(2011, Month.MARCH, 16);
final Number[] result = transformer.transform(new MockInputRow().put(column, date));
assertEquals(3, result.length);
assertEquals(2011, result[0]);
assertEquals(3, result[1]);
assertEquals(16, result[2]);
}
示例8: testTransformTime
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testTransformTime() throws Exception {
final DatePartTransformer transformer = new DatePartTransformer();
transformer.column = new MockInputColumn<>("my time", Date.class);
transformer.year = false;
transformer.month = false;
transformer.dayOfMonth = false;
transformer.hour = true;
transformer.minute = true;
transformer.second = true;
final OutputColumns outputColumns = transformer.getOutputColumns();
assertEquals(3, outputColumns.getColumnCount());
assertEquals("my time (hour)", outputColumns.getColumnName(0));
assertEquals("my time (minute)", outputColumns.getColumnName(1));
assertEquals("my time (second)", outputColumns.getColumnName(2));
final Date date = new SimpleDateFormat("HH:mm:ss").parse("13:21:55");
final Number[] result = transformer.transform(date);
assertEquals(3, result.length);
assertEquals(13, result[0]);
assertEquals(21, result[1]);
assertEquals(55, result[2]);
}
示例9: testCreateSimpleJsonOfDataTypes
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
@Test
public void testCreateSimpleJsonOfDataTypes() throws Exception {
final InputColumn<Object> col = new MockInputColumn<>("obj", Object.class);
final ComposeJsonTransformer jsonTransformer = new ComposeJsonTransformer(col);
jsonTransformer.init();
assertEquals("OutputColumns[obj (as JSON)]", jsonTransformer.getOutputColumns().toString());
assertEquals("123", jsonTransformer.transform(new MockInputRow().put(col, 123))[0]);
assertEquals("123.0", jsonTransformer.transform(new MockInputRow().put(col, 123.0))[0]);
assertEquals("\"str\"", jsonTransformer.transform(new MockInputRow().put(col, "str"))[0]);
assertEquals("true", jsonTransformer.transform(new MockInputRow().put(col, true))[0]);
assertEquals("null", jsonTransformer.transform(new MockInputRow().put(col, null))[0]);
}
示例10: testSimpleList
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
@Test
public void testSimpleList() throws Exception {
final List<String> list = new ArrayList<>();
list.add("hello");
list.add("world");
final InputColumn<List<?>> col = new MockInputColumn<>("list");
final ComposeJsonTransformer jsonTransformer = new ComposeJsonTransformer(col);
jsonTransformer.init();
assertEquals(1, jsonTransformer.getOutputColumns().getColumnCount());
final String[] jsonDocs = jsonTransformer.transform(new MockInputRow().put(col, list));
assertEquals(1, jsonDocs.length);
assertEquals("[\"hello\",\"world\"]", jsonDocs[0]);
}
示例11: testAllFieldsEvaluationMode
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testAllFieldsEvaluationMode() throws Exception {
final InputColumn<?> col1 = new MockInputColumn<String>("foo");
final InputColumn<?> col2 = new MockInputColumn<String>("bar");
final CompletenessAnalyzer analyzer = new CompletenessAnalyzer();
analyzer._evaluationMode = CompletenessAnalyzer.EvaluationMode.ALL_FIELDS;
analyzer._valueColumns = new InputColumn[] { col1, col2 };
analyzer._conditions = new CompletenessAnalyzer.Condition[] { CompletenessAnalyzer.Condition.NOT_NULL,
CompletenessAnalyzer.Condition.NOT_NULL };
analyzer.init();
analyzer.run(new MockInputRow(1001).put(col1, null).put(col2, null), 1);
analyzer.run(new MockInputRow(1002).put(col1, "hello").put(col2, null), 1);
analyzer.run(new MockInputRow(1002).put(col1, null).put(col2, "world"), 1);
analyzer.run(new MockInputRow(1002).put(col1, "hello").put(col2, "world"), 1);
assertEquals(4, analyzer.getResult().getTotalRowCount());
assertEquals(1, analyzer.getResult().getInvalidRowCount());
assertEquals(3, analyzer.getResult().getValidRowCount());
}
示例12: testIntegrationScenarioWithLocalTomcat
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
@Test
@Ignore
public void testIntegrationScenarioWithLocalTomcat() throws Exception {
final HttpRequestTransformer t = new HttpRequestTransformer();
t.setHttpClient(HttpClients.createSystem());
t.setMethod(HttpMethod.GET);
t.setRequestBody("Hello ${name}");
t.setUrl("http://localhost:8080");
final InputColumn<?> col1 = new MockInputColumn<>("foo");
t.setInputAndVariables(new InputColumn[] { col1 }, new String[] { "${name}" });
t.init();
final Object[] result = t.transform(new MockInputRow().put(col1, "world"));
t.close();
assertEquals("[200, Hello world!]", Arrays.toString(result));
}
示例13: testTransform
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testTransform() throws Exception {
final SelectFromListTransformer trans = new SelectFromListTransformer();
final InputColumn<List<?>> col = new MockInputColumn<>("foo");
trans.listColumn = col;
trans.indices = new Number[] { 0, 3, 50, 1, -1 };
trans.elementType = Integer.class;
trans.verifyTypes = true;
final List<Number> list = new ArrayList<>();
list.add(1000);
list.add(1001);
list.add(1003);
list.add(1004);
final Object[] result = trans.transform(new MockInputRow().put(col, list));
assertEquals(5, result.length);
assertEquals("[1000, 1004, null, 1001, null]", Arrays.toString(result));
}
示例14: testTransform
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testTransform() throws Exception {
final ELTransformer transformer = new ELTransformer();
transformer._expression = "Hello #{name}";
transformer.init();
String[] result;
result = transformer
.transform(new MockInputRow().put(new MockInputColumn<>("name", String.class), "Donald Duck"));
assertEquals(1, result.length);
assertEquals("Hello Donald Duck", result[0]);
result = transformer.transform(new MockInputRow().put(new MockInputColumn<>("name", String.class), null));
assertEquals(1, result.length);
assertEquals("Hello ", result[0]);
result = transformer.transform(new MockInputRow());
assertEquals(1, result.length);
assertEquals(null, result[0]);
}
示例15: testSimpleScriptParseIntExecution
import org.datacleaner.data.MockInputColumn; //导入依赖的package包/类
public void testSimpleScriptParseIntExecution() throws Exception {
final JavaScriptTransformer t = new JavaScriptTransformer();
t.setSourceCode("function eval() {return parseInt(values[0], 10)}; eval();");
final InputColumn<String> col = new MockInputColumn<>("my number", String.class);
t.setColumns(new InputColumn[] { col });
t.init();
assertEquals("123", t.transform(new MockInputRow().put(col, 123))[0]);
assertEquals("1", t.transform(new MockInputRow().put(col, 1.0))[0]);
assertEquals("1", t.transform(new MockInputRow().put(col, 1.5))[0]);
assertEquals("10", t.transform(new MockInputRow().put(col, "010"))[0]);
//the Number cannot be parsed because it starts with letter 'O'
assertEquals("NaN", t.transform(new MockInputRow().put(col, "O10"))[0]);
}