use of org.apache.apex.malhar.contrib.util.TestPOJO in project apex-malhar by apache.
the class MemcachePOJOOperatorTest method testMemcacheOutputOperatorInternal.
@SuppressWarnings("unchecked")
@Test
public void testMemcacheOutputOperatorInternal() throws Exception {
MemcachePOJOOutputOperator operator = new MemcachePOJOOutputOperator();
operator.setStore(store);
TableInfo tableInfo = new TableInfo();
tableInfo.setRowOrIdExpression(TestPOJO.getRowExpression());
tableInfo.setFieldsInfo(TestPOJO.getFieldsInfo());
tableInfo.setRowOrIdExpression(TestPOJO.getRowExpression());
operator.setTableInfo(tableInfo);
operator.setup(null);
TupleGenerator<TestPOJO> generator = new TupleGenerator<TestPOJO>(TestPOJO.class);
for (int i = 0; i < TUPLE_SIZE; ++i) {
operator.processTuple(generator.getNextTuple());
}
readDataAndVerify(operator.getStore(), generator);
}
use of org.apache.apex.malhar.contrib.util.TestPOJO in project apex-malhar by apache.
the class GeodePOJOOperatorTest method testGeodeOutputOperatorInternal.
@SuppressWarnings("unchecked")
@Test
public void testGeodeOutputOperatorInternal() throws Exception {
GeodePOJOOutputOperator operator = new GeodePOJOOutputOperator();
operator.setStore(store);
TableInfo tableInfo = new TableInfo();
tableInfo.setRowOrIdExpression(TestPOJO.getRowExpression());
tableInfo.setFieldsInfo(TestPOJO.getFieldsInfo());
tableInfo.setRowOrIdExpression(TestPOJO.getRowExpression());
operator.setTableInfo(tableInfo);
operator.setup(null);
TupleGenerator<TestPOJO> generator = new TupleGenerator<TestPOJO>(TestPOJO.class);
for (int i = 0; i < TUPLE_SIZE; ++i) {
operator.processTuple(generator.getNextTuple());
}
generator.reset();
for (int i = 0; i < TUPLE_SIZE; ++i) {
operator.processTuple(generator.getNextTuple());
}
// readDataAndVerify(operator.getStore(), generator);
}
use of org.apache.apex.malhar.contrib.util.TestPOJO in project apex-malhar by apache.
the class MemcachePOJOOperatorTest method readDataAndVerify.
public void readDataAndVerify(MemcacheStore store, TupleGenerator<TestPOJO> generator) {
generator.reset();
for (int i = 0; i < TUPLE_SIZE; ++i) {
TestPOJO expected = generator.getNextTuple();
TestPOJO read = (TestPOJO) store.get(expected.getRow());
Assert.assertTrue(String.format("expected={%s}, actually={%s}", expected.toString(), read.toString()), expected.completeEquals(read));
}
}
use of org.apache.apex.malhar.contrib.util.TestPOJO in project apex-malhar by apache.
the class HBasePOJOPutOperatorTest method readRecordsAndVerify.
protected void readRecordsAndVerify() {
int[] rowIds = new int[TEST_SIZE];
for (int i = 1; i <= TEST_SIZE; ++i) {
rowIds[i - 1] = 1;
}
try {
HTable table = operator.getStore().getTable();
Scan scan = new Scan();
ResultScanner resultScanner = table.getScanner(scan);
int recordCount = 0;
while (true) {
Result result = resultScanner.next();
if (result == null) {
break;
}
int rowId = Integer.valueOf(Bytes.toString(result.getRow()));
Assert.assertTrue("rowId=" + rowId + " aut of range", (rowId > 0 && rowId <= TEST_SIZE));
Assert.assertTrue("the rowId=" + rowId + " already processed.", rowIds[rowId - 1] == 1);
rowIds[rowId - 1] = 0;
List<Cell> cells = result.listCells();
Map<String, byte[]> map = new HashMap<>();
for (Cell cell : cells) {
String columnName = Bytes.toString(CellUtil.cloneQualifier(cell));
byte[] value = CellUtil.cloneValue(cell);
map.put(columnName, value);
}
TestPOJO read = TestPOJO.from(map);
read.setRowId((long) rowId);
TestPOJO expected = new TestPOJO(rowId);
Assert.assertTrue(String.format("expected %s, get %s ", expected.toString(), read.toString()), expected.completeEquals(read));
recordCount++;
}
int missedCount = 0;
if (recordCount != TEST_SIZE) {
logger.error("unsaved records: ");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < TEST_SIZE; ++i) {
if (rowIds[i] != 0) {
sb.append(i + 1).append(", ");
missedCount++;
}
if (missedCount > 0 && (missedCount % 20 == 0)) {
logger.error(sb.toString());
sb.delete(0, sb.length());
}
}
logger.error(sb.toString());
logger.error("End of unsaved records");
}
Assert.assertTrue("expected total records = " + TEST_SIZE + ", got " + recordCount + ", missed " + missedCount, recordCount == TEST_SIZE);
} catch (Exception e) {
throw new RuntimeException("exception", e);
}
}
use of org.apache.apex.malhar.contrib.util.TestPOJO in project apex-malhar by apache.
the class GeodePOJOOperatorTest method readDataAndVerify.
public void readDataAndVerify(GeodeStore store, TupleGenerator<TestPOJO> generator) {
generator.reset();
for (int i = 0; i < TUPLE_SIZE; ++i) {
TestPOJO expected = generator.getNextTuple();
TestPOJO read = (TestPOJO) store.get(expected.getRow());
Assert.assertTrue(String.format("expected={%s}, actually={%s}", expected.toString(), read.toString()), expected.completeEquals(read));
}
}
Aggregations