Skip to content

Commit

Permalink
#69 write count test
Browse files Browse the repository at this point in the history
  • Loading branch information
mincong-h committed Jun 25, 2016
1 parent ab9df58 commit 64727ba
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/test/java/org/hibernate/search/jsr352/DeploymentIT.java
Expand Up @@ -60,7 +60,6 @@ public static WebArchive createDeployment() {
.addPackages(true, "org.hibernate.search.jsr352")
.addPackages(true, "javax.persistence")
.addPackages(true, "org.hibernate.search.annotations")
// .addClasses(Address.class, Stock.class)
.addClass(Serializable.class)
.addClass(Date.class)
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
Expand Down Expand Up @@ -91,11 +90,8 @@ public void testJobStart() throws InterruptedException {
break;

case "produceLuceneDoc":
Map<Metric.MetricType, Long> metricsMap = BatchTestHelper.getMetricsMap(stepExecution.getMetrics());
// The read count.
long addressCount = (long) Math.ceil((double) DB_ADDRESS_ROWS_LOADED / ARRAY_CAPACITY);
long stockCount = (long) Math.ceil((double) DB_STOCK_ROWS / ARRAY_CAPACITY);
assertEquals(addressCount + stockCount, metricsMap.get(Metric.MetricType.READ_COUNT).longValue());
Metric[] metrics = stepExecution.getMetrics();
testChunk(BatchTestHelper.getMetricsMap(metrics));
break;

default:
Expand All @@ -106,6 +102,21 @@ public void testJobStart() throws InterruptedException {
logger.info("Finished");
}

private void testChunk(Map<Metric.MetricType, Long> metricsMap) {
long addressCount = (long) Math.ceil((double) DB_ADDRESS_ROWS_LOADED / ARRAY_CAPACITY);
long stockCount = (long) Math.ceil((double) DB_STOCK_ROWS / ARRAY_CAPACITY);
// The read count.
long expectedReadCount = addressCount + stockCount;
long actualReadCount = metricsMap.get(Metric.MetricType.READ_COUNT);
assertEquals(expectedReadCount, actualReadCount);
// The write count
// TODO: make BatchItemProcessor generic in order to process the
// entity `stock` in the current implementation
long expectedWriteCount = addressCount + 0;
long actualWriteCount = metricsMap.get(Metric.MetricType.WRITE_COUNT);
assertEquals(expectedWriteCount, actualWriteCount);
}

private MassIndexer createAndInitJob() {
MassIndexer massIndexer = new MassIndexerImpl()
.arrayCapacity(ARRAY_CAPACITY)
Expand All @@ -127,6 +138,4 @@ private Set<Class<?>> getRootEntities() {
rootEntities.add(Stock.class);
return rootEntities;
}


}

0 comments on commit 64727ba

Please sign in to comment.