summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorYoung Gyu Park <younggyu@google.com>2018-05-23 19:50:18 +0900
committerYoung Gyu Park <younggyu@google.com>2018-05-24 10:15:20 +0900
commitcbc85bb9ca316948975bba087be530286dd6803e (patch)
treefb6115146a90d012065b326c99dd2d40b3c8b8b1 /src/main/java
parent3b8326d5bd720dc18a9ac3e50847f858df062b61 (diff)
downloaddashboard-cbc85bb9ca316948975bba087be530286dd6803e.tar.gz
% format cts-on-gsi
Test: go/vts-web/show_plan_release?plan=cts-on-gsi&type=suite&testCategoryType=4 Bug: 79972525 Change-Id: Ia284e34532787d250990ec4432407291e3f33f28
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/android/vts/config/ObjectifyListener.java9
-rw-r--r--src/main/java/com/android/vts/entity/TestSuiteResultEntity.java13
-rw-r--r--src/main/java/com/android/vts/util/Pagination.java12
3 files changed, 19 insertions, 15 deletions
diff --git a/src/main/java/com/android/vts/config/ObjectifyListener.java b/src/main/java/com/android/vts/config/ObjectifyListener.java
index 61ca159..22b6011 100644
--- a/src/main/java/com/android/vts/config/ObjectifyListener.java
+++ b/src/main/java/com/android/vts/config/ObjectifyListener.java
@@ -43,10 +43,11 @@ public class ObjectifyListener implements ServletContextListener {
*/
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
- ObjectifyFactory objectifyFactory = ObjectifyService.factory();
- objectifyFactory.register(TestSuiteFileEntity.class);
- objectifyFactory.register(TestSuiteResultEntity.class);
- objectifyFactory.begin();
+ ObjectifyService.init();
+ // ObjectifyFactory objectifyFactory = ObjectifyService.factory();
+ ObjectifyService.register(TestSuiteFileEntity.class);
+ ObjectifyService.register(TestSuiteResultEntity.class);
+ ObjectifyService.begin();
logger.log(Level.INFO, "Value Initialized from context.");
}
diff --git a/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java b/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java
index 934f2ea..7ba1373 100644
--- a/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java
+++ b/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java
@@ -16,7 +16,6 @@
package com.android.vts.entity;
-import com.google.appengine.api.datastore.Query;
import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
@@ -41,6 +40,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
@@ -245,7 +246,7 @@ public class TestSuiteResultEntity {
@Index @Getter @Setter int failedTestCaseCount;
/** Test Suite ratio of success to find candidate build */
- @Index @Getter @Setter int passedTestCaseRatio;
+ @Index @Getter @Setter float passedTestCaseRatio;
/** When this record was created or updated */
@Index @Getter Date updated;
@@ -294,11 +295,13 @@ public class TestSuiteResultEntity {
this.passedTestCaseCount = passedTestCaseCount;
this.failedTestCaseCount = failedTestCaseCount;
- int totalTestCaseCount = passedTestCaseCount + failedTestCaseCount;
- if (totalTestCaseCount <= 0) {
+ BigDecimal totalTestCaseCount = new BigDecimal(passedTestCaseCount + failedTestCaseCount);
+ if (totalTestCaseCount.intValue() <= 0) {
this.passedTestCaseRatio = 0;
} else {
- this.passedTestCaseRatio = passedTestCaseCount / totalTestCaseCount * 100;
+ BigDecimal passedTestCaseCountDecimal= new BigDecimal(passedTestCaseCount);
+ BigDecimal result = passedTestCaseCountDecimal.divide(totalTestCaseCount, 10, BigDecimal.ROUND_FLOOR);
+ this.passedTestCaseRatio = result.longValue() * 100;
}
if (!this.buildVendorFingerprint.isEmpty()) {
diff --git a/src/main/java/com/android/vts/util/Pagination.java b/src/main/java/com/android/vts/util/Pagination.java
index fc4d3f7..4a0d652 100644
--- a/src/main/java/com/android/vts/util/Pagination.java
+++ b/src/main/java/com/android/vts/util/Pagination.java
@@ -16,8 +16,8 @@
package com.android.vts.util;
-import com.google.appengine.api.datastore.Cursor;
-import com.google.appengine.api.datastore.QueryResultIterator;
+import com.google.cloud.datastore.Cursor;
+import com.google.cloud.datastore.QueryResults;
import com.googlecode.objectify.cmd.Query;
import java.util.ArrayList;
@@ -96,7 +96,7 @@ public class Pagination<T> implements Iterable<T> {
if (startPageToken.equals("")) {
this.totalCount = query.count();
} else {
- query = query.startAt(Cursor.fromWebSafeString(startPageToken));
+ query = query.startAt(Cursor.fromUrlSafe(startPageToken));
this.totalCount = query.count();
}
@@ -106,14 +106,14 @@ public class Pagination<T> implements Iterable<T> {
int iteratorIndex = 0;
int startIndex = (page % pageSize == 0 ? 9 : page % pageSize - 1) * pageSize;
- QueryResultIterator<T> resultIterator = query.iterator();
+ QueryResults<T> resultIterator = query.iterator();
while (resultIterator.hasNext()) {
if (startIndex <= iteratorIndex && iteratorIndex < startIndex + this.pageSize)
this.list.add(resultIterator.next());
else resultIterator.next();
if (iteratorIndex == DEFAULT_PAGE_WINDOW * this.pageSize) {
- if ( Objects.nonNull(resultIterator) && Objects.nonNull(resultIterator.getCursor()) ) {
- this.nextPageCountToken = resultIterator.getCursor().toWebSafeString();
+ if ( Objects.nonNull(resultIterator) && Objects.nonNull(resultIterator.getCursorAfter()) ) {
+ this.nextPageCountToken = resultIterator.getCursorAfter().toUrlSafe();
}
}
iteratorIndex++;