summaryrefslogtreecommitdiff
path: root/src/main/java/com/android/vts/entity
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/android/vts/entity')
-rw-r--r--src/main/java/com/android/vts/entity/ApiCoverageEntity.java159
-rw-r--r--src/main/java/com/android/vts/entity/ApiCoverageExcludedEntity.java133
-rw-r--r--src/main/java/com/android/vts/entity/BranchEntity.java111
-rw-r--r--src/main/java/com/android/vts/entity/BuildTargetEntity.java111
-rw-r--r--src/main/java/com/android/vts/entity/CodeCoverageEntity.java135
-rw-r--r--src/main/java/com/android/vts/entity/CodeCoverageFileEntity.java101
-rw-r--r--src/main/java/com/android/vts/entity/CoverageEntity.java312
-rw-r--r--src/main/java/com/android/vts/entity/DashboardEntity.java56
-rw-r--r--src/main/java/com/android/vts/entity/DeviceInfoEntity.java320
-rw-r--r--src/main/java/com/android/vts/entity/HalApiEntity.java105
-rw-r--r--src/main/java/com/android/vts/entity/ProfilingPointEntity.java198
-rw-r--r--src/main/java/com/android/vts/entity/ProfilingPointRunEntity.java368
-rw-r--r--src/main/java/com/android/vts/entity/ProfilingPointSummaryEntity.java371
-rw-r--r--src/main/java/com/android/vts/entity/RoleEntity.java43
-rw-r--r--src/main/java/com/android/vts/entity/TestAcknowledgmentEntity.java304
-rw-r--r--src/main/java/com/android/vts/entity/TestCaseRunEntity.java233
-rw-r--r--src/main/java/com/android/vts/entity/TestCoverageStatusEntity.java242
-rw-r--r--src/main/java/com/android/vts/entity/TestEntity.java151
-rw-r--r--src/main/java/com/android/vts/entity/TestPlanEntity.java87
-rw-r--r--src/main/java/com/android/vts/entity/TestPlanRunEntity.java310
-rw-r--r--src/main/java/com/android/vts/entity/TestRunEntity.java497
-rw-r--r--src/main/java/com/android/vts/entity/TestStatusEntity.java198
-rw-r--r--src/main/java/com/android/vts/entity/TestSuiteFileEntity.java78
-rw-r--r--src/main/java/com/android/vts/entity/TestSuiteResultEntity.java555
-rw-r--r--src/main/java/com/android/vts/entity/UserEntity.java128
-rw-r--r--src/main/java/com/android/vts/entity/UserFavoriteEntity.java132
26 files changed, 0 insertions, 5438 deletions
diff --git a/src/main/java/com/android/vts/entity/ApiCoverageEntity.java b/src/main/java/com/android/vts/entity/ApiCoverageEntity.java
deleted file mode 100644
index 9c74032..0000000
--- a/src/main/java/com/android/vts/entity/ApiCoverageEntity.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.googlecode.objectify.Key;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Parent;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-/** Entity Class for ApiCoverageEntity */
-@Cache
-@Entity(name = "ApiCoverage")
-@EqualsAndHashCode(of = "id")
-@NoArgsConstructor
-@JsonAutoDetect(fieldVisibility = Visibility.ANY)
-@JsonIgnoreProperties({"id", "parent"})
-public class ApiCoverageEntity implements DashboardEntity {
-
- /** ApiCoverageEntity id field */
- @Id @Getter @Setter String id;
-
- @Parent @Getter Key<?> parent;
-
- /** HAL package name. e.g. android.hardware.foo. */
- @Index @Getter @Setter String halPackageName;
-
- /** HAL (major) version. e.g. 1. */
- @Index @Getter @Setter int halMajorVersion;
-
- /** HAL (minor) version. e.g. 0. */
- @Index @Getter @Setter int halMinorVersion;
-
- /** HAL interface name. e.g. IFoo. */
- @Index @Getter @Setter String halInterfaceName;
-
- /** List of HAL API */
- @Getter @Setter List<String> halApi;
-
- /** List of HAL covered API */
- @Getter @Setter List<String> coveredHalApi;
-
- /** When this record was created or updated */
- @Index Date updated;
-
- /** Constructor function for ApiCoverageEntity Class */
- public ApiCoverageEntity(
- com.google.appengine.api.datastore.Key testRunKey,
- String halPackageName,
- int halVersionMajor,
- int halVersionMinor,
- String halInterfaceName,
- List<String> halApi,
- List<String> coveredHalApi) {
- this.id = UUID.randomUUID().toString();
- this.parent = getParentKey(testRunKey);
-
- this.halPackageName = halPackageName;
- this.halMajorVersion = halVersionMajor;
- this.halMinorVersion = halVersionMinor;
- this.halInterfaceName = halInterfaceName;
- this.halApi = halApi;
- this.coveredHalApi = coveredHalApi;
- this.updated = new Date();
- }
-
- /** Constructor function for ApiCoverageEntity Class with objectify Key. */
- public ApiCoverageEntity(
- Key testRunKey,
- String halPackageName,
- int halVersionMajor,
- int halVersionMinor,
- String halInterfaceName,
- List<String> halApi,
- List<String> coveredHalApi) {
- this.id = UUID.randomUUID().toString();
- this.parent = testRunKey;
-
- this.halPackageName = halPackageName;
- this.halMajorVersion = halVersionMajor;
- this.halMinorVersion = halVersionMinor;
- this.halInterfaceName = halInterfaceName;
- this.halApi = halApi;
- this.coveredHalApi = coveredHalApi;
- this.updated = new Date();
- }
-
- /** Get objectify Key from datastore Key type */
- private Key getParentKey(com.google.appengine.api.datastore.Key testRunKey) {
- Key testParentKey = Key.create(TestEntity.class, testRunKey.getParent().getName());
- return Key.create(testParentKey, TestRunEntity.class, testRunKey.getId());
- }
-
- /** Get UrlSafeKey from ApiCoverageEntity Information */
- public String getUrlSafeKey() {
- Key uuidKey = Key.create(this.parent, ApiCoverageEntity.class, this.id);
- return uuidKey.toUrlSafe();
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<ApiCoverageEntity> save() {
- this.id = UUID.randomUUID().toString();
- this.updated = new Date();
- return ofy().save().entity(this).now();
- }
-
- /** Get List of ApiCoverageEntity by HAL interface name */
- public static ApiCoverageEntity getByUrlSafeKey(String urlSafeKey) {
- return ofy().load()
- .type(ApiCoverageEntity.class)
- .filterKey(com.google.cloud.datastore.Key.fromUrlSafe(urlSafeKey))
- .first()
- .now();
- }
-
- /** Get List of ApiCoverageEntity by HAL interface name */
- public static List<ApiCoverageEntity> getByInterfaceNameList(String halInterfaceName) {
- return ofy().load()
- .type(ApiCoverageEntity.class)
- .filter("halInterfaceName", halInterfaceName)
- .list();
- }
-
- /** Get List of ApiCoverageEntity by HAL package name */
- public static List<ApiCoverageEntity> getByPackageNameList(String packageName) {
- return ofy().load()
- .type(ApiCoverageEntity.class)
- .filter("halPackageName", packageName)
- .list();
- }
-}
diff --git a/src/main/java/com/android/vts/entity/ApiCoverageExcludedEntity.java b/src/main/java/com/android/vts/entity/ApiCoverageExcludedEntity.java
deleted file mode 100644
index 61bd6a7..0000000
--- a/src/main/java/com/android/vts/entity/ApiCoverageExcludedEntity.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.googlecode.objectify.Key;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Index;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-import java.util.Date;
-import java.util.List;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-/**
- * This entity class contain the excluded API information. And this information will be used to
- * calculate more precise the ratio of API coverage.
- */
-@Cache
-@Entity(name = "ApiCoverageExcluded")
-@EqualsAndHashCode(of = "id")
-@NoArgsConstructor
-@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
-@JsonIgnoreProperties({"id", "parent"})
-public class ApiCoverageExcludedEntity implements DashboardEntity {
-
- /** ApiCoverageEntity id field */
- @Id @Getter @Setter private String id;
-
- /** Package name. e.g. android.hardware.foo. */
- @Index @Getter @Setter private String packageName;
-
- /** Major Version. e.g. 1, 2. */
- @Getter @Setter private int majorVersion;
-
- /** Minor Version. e.g. 0. */
- @Getter @Setter private int minorVersion;
-
- /** Interface name. e.g. IFoo. */
- @Index @Getter @Setter private String interfaceName;
-
- /** API Name */
- @Index @Getter @Setter private String apiName;
-
- /** The reason comment for the excluded API */
- @Getter @Setter private String comment;
-
- /** When this record was created or updated */
- @Index @Getter @Setter private Date updated;
-
- /** Constructor function for ApiCoverageExcludedEntity Class */
- public ApiCoverageExcludedEntity(
- String packageName,
- String version,
- String interfaceName,
- String apiName,
- String comment) {
- this.id = this.getObjectifyId();
- this.packageName = packageName;
- this.interfaceName = interfaceName;
- this.apiName = apiName;
- this.comment = comment;
- this.updated = new Date();
-
- this.setVersions(version);
- }
-
- /** Setting major and minor version from version string */
- private void setVersions(String version) {
- String[] versionArray = version.split("[.]");
- if (versionArray.length == 0) {
- this.majorVersion = 0;
- this.minorVersion = 0;
- } else if (versionArray.length == 1) {
- this.majorVersion = Integer.parseInt(versionArray[0]);
- this.minorVersion = 0;
- } else {
- this.majorVersion = Integer.parseInt(versionArray[0]);
- this.minorVersion = Integer.parseInt(versionArray[1]);
- }
- }
-
- /** Getting objectify ID from the entity information */
- private String getObjectifyId() {
- return this.packageName
- + "."
- + this.majorVersion
- + "."
- + this.minorVersion
- + "."
- + this.interfaceName
- + "."
- + this.apiName;
- }
-
- /** Getting key from the entity */
- public Key<ApiCoverageExcludedEntity> getKey() {
- return Key.create(ApiCoverageExcludedEntity.class, this.getObjectifyId());
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<ApiCoverageExcludedEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- /** Get All Key List of ApiCoverageExcludedEntity */
- public static List<Key<ApiCoverageExcludedEntity>> getAllKeyList() {
- return ofy().load().type(ApiCoverageExcludedEntity.class).keys().list();
- }
-
-}
diff --git a/src/main/java/com/android/vts/entity/BranchEntity.java b/src/main/java/com/android/vts/entity/BranchEntity.java
deleted file mode 100644
index 1c9ea52..0000000
--- a/src/main/java/com/android/vts/entity/BranchEntity.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@com.googlecode.objectify.annotation.Entity(name = "Branch")
-@Cache
-@Data
-@NoArgsConstructor
-/** Entity describing a branch. */
-public class BranchEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(BranchEntity.class.getName());
-
- public static final String KIND = "Branch"; // The entity kind.
-
- @Id private String name;
-
- /**
- * Create a BranchEntity object.
- *
- * @param branchName The name of the branch.
- */
- public BranchEntity(String branchName) {
- this.name = branchName;
- }
-
- public Key getKey() {
- return KeyFactory.createKey(KIND, this.name);
- }
-
- /** find by branch name */
- public static List<String> getByBranch(String branchName) {
- if (branchName.equals("*")) {
- return ofy().load()
- .type(BranchEntity.class)
- .limit(100)
- .list()
- .stream()
- .map(b -> b.name)
- .collect(Collectors.toList());
- } else {
- com.googlecode.objectify.Key startKey =
- com.googlecode.objectify.Key.create(BranchEntity.class, branchName);
-
- int lastPosition = branchName.length() - 1;
- int lastCharValue = branchName.charAt(lastPosition);
- String nextChar = String.valueOf((char) (lastCharValue + 1));
-
- String nextBranchName = branchName.substring(0, lastPosition) + nextChar;
- com.googlecode.objectify.Key endKey =
- com.googlecode.objectify.Key.create(BranchEntity.class, nextBranchName);
- return ofy().load()
- .type(BranchEntity.class)
- .filterKey(">=", startKey)
- .filterKey("<", endKey)
- .list()
- .stream()
- .map(b -> b.name)
- .collect(Collectors.toList());
- }
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<BranchEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- /**
- * Convert an Entity object to a BranchEntity.
- *
- * @param e The entity to process.
- * @return BranchEntity object with the properties from e, or null if incompatible.
- */
- public static BranchEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND) || e.getKey().getName() == null) {
- logger.log(Level.WARNING, "Missing branch attributes in entity: " + e.toString());
- return null;
- }
- String branchName = e.getKey().getName();
- return new BranchEntity(branchName);
- }
-}
diff --git a/src/main/java/com/android/vts/entity/BuildTargetEntity.java b/src/main/java/com/android/vts/entity/BuildTargetEntity.java
deleted file mode 100644
index 4180213..0000000
--- a/src/main/java/com/android/vts/entity/BuildTargetEntity.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@com.googlecode.objectify.annotation.Entity(name = "BuildTarget")
-@Cache
-@Data
-@NoArgsConstructor
-/** Entity describing a build target. */
-public class BuildTargetEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(BuildTargetEntity.class.getName());
-
- public static final String KIND = "BuildTarget"; // The entity kind.
-
- @Id private String name;
-
- /**
- * Create a BuildTargetEntity object.
- *
- * @param targetName The name of the build target.
- */
- public BuildTargetEntity(String targetName) {
- this.name = targetName;
- }
-
- public Key getKey() {
- return KeyFactory.createKey(KIND, this.name);
- }
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<BuildTargetEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- /** find by Build Target Name */
- public static List<String> getByBuildTarget(String buildTargetName) {
- if (buildTargetName.equals("*")) {
- return ofy().load()
- .type(BuildTargetEntity.class)
- .limit(100)
- .list()
- .stream()
- .map(b -> b.name)
- .collect(Collectors.toList());
- } else {
- com.googlecode.objectify.Key startKey =
- com.googlecode.objectify.Key.create(BuildTargetEntity.class, buildTargetName);
-
- int lastPosition = buildTargetName.length() - 1;
- int lastCharValue = buildTargetName.charAt(lastPosition);
- String nextChar = String.valueOf((char) (lastCharValue + 1));
-
- String nextBuildTargetName = buildTargetName.substring(0, lastPosition) + nextChar;
- com.googlecode.objectify.Key endKey =
- com.googlecode.objectify.Key.create(
- BuildTargetEntity.class, nextBuildTargetName);
- return ofy().load()
- .type(BuildTargetEntity.class)
- .filterKey(">=", startKey)
- .filterKey("<", endKey)
- .list()
- .stream()
- .map(b -> b.name)
- .collect(Collectors.toList());
- }
- }
-
- /**
- * Convert an Entity object to a BuildTargetEntity.
- *
- * @param e The entity to process.
- * @return BuildTargetEntity object with the properties from e, or null if incompatible.
- */
- public static BuildTargetEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND) || e.getKey().getName() == null) {
- logger.log(Level.WARNING, "Missing build target attributes in entity: " + e.toString());
- return null;
- }
- String targetName = e.getKey().getName();
- return new BuildTargetEntity(targetName);
- }
-}
diff --git a/src/main/java/com/android/vts/entity/CodeCoverageEntity.java b/src/main/java/com/android/vts/entity/CodeCoverageEntity.java
deleted file mode 100644
index 2a46b1f..0000000
--- a/src/main/java/com/android/vts/entity/CodeCoverageEntity.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.googlecode.objectify.Key;
-
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Parent;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-import java.util.Date;
-import java.util.logging.Logger;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-/** Entity Class for CodeCoverageEntity */
-@Cache
-@Entity(name = "CodeCoverage")
-@EqualsAndHashCode(of = "id")
-@NoArgsConstructor
-@JsonAutoDetect(fieldVisibility = Visibility.ANY)
-@JsonIgnoreProperties({"id", "parent"})
-public class CodeCoverageEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(CodeCoverageEntity.class.getName());
-
- public static final String KIND = "CodeCoverage";
-
- public static final String COVERED_LINE_COUNT = "coveredLineCount";
- public static final String TOTAL_LINE_COUNT = "totalLineCount";
-
- /** CodeCoverageEntity id field */
- @Id @Getter @Setter Long id;
-
- @Parent @Getter Key<?> parent;
-
- @Index @Getter @Setter private long coveredLineCount;
-
- @Index @Getter @Setter private long totalLineCount;
-
- /** When this record was created or updated */
- @Index Date updated;
-
- /** Constructor function for ApiCoverageEntity Class */
- public CodeCoverageEntity(
- com.google.appengine.api.datastore.Key testRunKey,
- long coveredLineCount,
- long totalLineCount) {
-
- this.parent = getParentKey(testRunKey);
-
- this.coveredLineCount = coveredLineCount;
- this.totalLineCount = totalLineCount;
- }
-
- /** Constructor function for ApiCoverageEntity Class */
- public CodeCoverageEntity(
- long id,
- com.google.appengine.api.datastore.Key testRunKey,
- long coveredLineCount,
- long totalLineCount) {
- this.id = id;
-
- this.parent = getParentKey(testRunKey);
-
- this.coveredLineCount = coveredLineCount;
- this.totalLineCount = totalLineCount;
- }
-
- /** Constructor function for ApiCoverageEntity Class with objectify key*/
- public CodeCoverageEntity(Key testRunKey, long coveredLineCount, long totalLineCount) {
- this.parent = testRunKey;
- this.coveredLineCount = coveredLineCount;
- this.totalLineCount = totalLineCount;
- }
-
- /** Get objectify Key from datastore Key type */
- private Key getParentKey(com.google.appengine.api.datastore.Key testRunKey) {
- Key testParentKey = Key.create(TestEntity.class, testRunKey.getParent().getName());
- return Key.create(testParentKey, TestRunEntity.class, testRunKey.getId());
- }
-
- /** Get UrlSafeKey from ApiCoverageEntity Information */
- public String getUrlSafeKey() {
- Key uuidKey = Key.create(this.parent, CodeCoverageEntity.class, this.id);
- return uuidKey.toUrlSafe();
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<CodeCoverageEntity> save() {
- this.id = this.getParent().getId();
- this.updated = new Date();
- return ofy().save().entity(this).now();
- }
-
- public com.google.appengine.api.datastore.Entity toEntity() {
- com.google.appengine.api.datastore.Key testKey =
- KeyFactory.createKey(TestEntity.KIND, this.getParent().getParent().getName());
- com.google.appengine.api.datastore.Key testRunKey =
- KeyFactory.createKey(testKey, TestRunEntity.KIND, this.getParent().getId());
- com.google.appengine.api.datastore.Key codeCoverageKey =
- KeyFactory.createKey(testRunKey, KIND, this.getParent().getId());
-
- com.google.appengine.api.datastore.Entity codeCoverageEntity =
- new com.google.appengine.api.datastore.Entity(codeCoverageKey);
- codeCoverageEntity.setProperty(COVERED_LINE_COUNT, this.coveredLineCount);
- codeCoverageEntity.setProperty(TOTAL_LINE_COUNT, this.totalLineCount);
- codeCoverageEntity.setIndexedProperty("updated", new Date());
- return codeCoverageEntity;
- }
-}
diff --git a/src/main/java/com/android/vts/entity/CodeCoverageFileEntity.java b/src/main/java/com/android/vts/entity/CodeCoverageFileEntity.java
deleted file mode 100644
index fe4e8a0..0000000
--- a/src/main/java/com/android/vts/entity/CodeCoverageFileEntity.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.googlecode.objectify.Key;
-
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Parent;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-import java.util.List;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-/** Entity Class for CodeCoverageFile */
-@Cache
-@Entity(name = "CodeCoverageFile")
-@EqualsAndHashCode(of = "id")
-@NoArgsConstructor
-public class CodeCoverageFileEntity implements DashboardEntity {
-
- /** CodeCoverageFileEntity testName field */
- @Id @Getter @Setter Long id;
-
- @Parent
- @Getter @Setter private Key<?> coverageParent;
-
- /** CodeCoverageFileEntity filePath field */
- @Getter @Setter String filePath;
-
- /** CodeCoverageFileEntity group field */
- @Getter @Setter String group;
-
- /** CodeCoverageFileEntity lineCoverage field */
- @Getter @Setter List<Long> lineCoverage;
-
- /** CodeCoverageFileEntity coveredCount field */
- @Getter @Setter long coveredCount;
-
- /** CodeCoverageFileEntity totalCount field */
- @Getter @Setter long totalCount;
-
- /** CodeCoverageFileEntity projectName field */
- @Getter @Setter String projectName;
-
- /** CodeCoverageFileEntity projectVersion field */
- @Getter @Setter String projectVersion;
-
- /** CodeCoverageFileEntity isIgnored field */
- @Index
- @Getter @Setter Boolean isIgnored;
-
- /** Constructor function for CodeCoverageFileEntity Class */
- public CodeCoverageFileEntity(
- long id,
- Key<?> coverageParent,
- String filePath,
- String group,
- List<Long> lineCoverage,
- long coveredCount,
- long totalCount,
- String projectName,
- String projectVersion) {
- this.id = id;
- this.coverageParent = coverageParent;
- this.filePath = filePath;
- this.group = group;
- this.lineCoverage = lineCoverage;
- this.coveredCount = coveredCount;
- this.totalCount = totalCount;
- this.projectName = projectName;
- this.projectVersion = projectVersion;
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<CodeCoverageFileEntity> save() {
- this.isIgnored = false;
- return ofy().save().entity(this).now();
- }
-}
diff --git a/src/main/java/com/android/vts/entity/CoverageEntity.java b/src/main/java/com/android/vts/entity/CoverageEntity.java
deleted file mode 100644
index 50d2f4e..0000000
--- a/src/main/java/com/android/vts/entity/CoverageEntity.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-import com.android.vts.proto.VtsReportMessage.CoverageReportMessage;
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Parent;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import lombok.Data;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-@com.googlecode.objectify.annotation.Entity(name = "Coverage")
-@Cache
-@Data
-@NoArgsConstructor
-/** Object describing coverage data gathered for a file. */
-public class CoverageEntity implements DashboardEntity {
-
- protected static final Logger logger = Logger.getLogger(CoverageEntity.class.getName());
-
- public static final String KIND = "Coverage";
-
- public static String GERRIT_URI;
-
- // Property keys
- public static final String GROUP = "group";
- public static final String COVERED_LINE_COUNT = "coveredCount";
- public static final String TOTAL_LINE_COUNT = "totalCount";
- public static final String FILE_PATH = "filePath";
- public static final String PROJECT_NAME = "projectName";
- public static final String PROJECT_VERSION = "projectVersion";
- public static final String LINE_COVERAGE = "lineCoverage";
-
- @Ignore @Getter @Setter private Key parentKey;
-
- @Id @Getter @Setter private Long id;
-
- @Parent @Getter @Setter private com.googlecode.objectify.Key<?> testParent;
-
- @Index @Getter @Setter private String group;
-
- @Getter @Setter private long coveredCount;
-
- @Getter @Setter private long totalCount;
-
- @Index @Getter @Setter private String filePath;
-
- @Getter @Setter private String projectName;
-
- @Getter @Setter private String projectVersion;
-
- @Getter @Setter private List<Long> lineCoverage;
-
- /** CoverageEntity isIgnored field */
- @Index @Getter @Setter Boolean isIgnored;
-
- /**
- * Create a CoverageEntity object for a file.
- *
- * @param parentKey The key to the parent TestRunEntity object in the database.
- * @param group The group within the test run describing the coverage.
- * @param coveredLineCount The total number of covered lines in the file.
- * @param totalLineCount The total number of uncovered executable lines in the file.
- * @param filePath The path to the file.
- * @param projectName The name of the git project.
- * @param projectVersion The commit hash of the project at the time the test was executed.
- * @param lineCoverage List of coverage counts per executable line in the file.
- */
- public CoverageEntity(
- Key parentKey,
- String group,
- long coveredLineCount,
- long totalLineCount,
- String filePath,
- String projectName,
- String projectVersion,
- List<Long> lineCoverage) {
- this.parentKey = parentKey;
- this.group = group;
- this.coveredCount = coveredLineCount;
- this.totalCount = totalLineCount;
- this.filePath = filePath;
- this.projectName = projectName;
- this.projectVersion = projectVersion;
- this.lineCoverage = lineCoverage;
- }
-
- /**
- * Create a CoverageEntity object for a file.
- *
- * @param testParent The objectify key to the parent TestRunEntity object in the database.
- * @param group The group within the test run describing the coverage.
- * @param coveredLineCount The total number of covered lines in the file.
- * @param totalLineCount The total number of uncovered executable lines in the file.
- * @param filePath The path to the file.
- * @param projectName The name of the git project.
- * @param projectVersion The commit hash of the project at the time the test was executed.
- * @param lineCoverage List of coverage counts per executable line in the file.
- */
- public CoverageEntity(
- com.googlecode.objectify.Key testParent,
- String group,
- long coveredLineCount,
- long totalLineCount,
- String filePath,
- String projectName,
- String projectVersion,
- List<Long> lineCoverage) {
- this.testParent = testParent;
- this.group = group;
- this.coveredCount = coveredLineCount;
- this.totalCount = totalLineCount;
- this.filePath = filePath;
- this.projectName = projectName;
- this.projectVersion = projectVersion;
- this.lineCoverage = lineCoverage;
- }
-
- /** find coverage entity by ID */
- public static CoverageEntity findById(String testName, String testRunId, String id) {
- com.googlecode.objectify.Key testKey =
- com.googlecode.objectify.Key.create(TestEntity.class, testName);
- com.googlecode.objectify.Key testRunKey =
- com.googlecode.objectify.Key.create(
- testKey, TestRunEntity.class, Long.parseLong(testRunId));
- return ofy().load()
- .type(CoverageEntity.class)
- .parent(testRunKey)
- .id(Long.parseLong(id))
- .now();
- }
-
- public static void setPropertyValues(Properties newSystemConfigProp) {
- GERRIT_URI = newSystemConfigProp.getProperty("gerrit.uri");
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<CoverageEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- /** Get percentage from calculating coveredCount and totalCount values */
- public Double getPercentage() {
- return Math.round(coveredCount * 10000d / totalCount) / 100d;
- }
-
- /** Get Gerrit Url function from the attributes of this class */
- public String getGerritUrl() throws UnsupportedEncodingException {
- String gerritPath =
- GERRIT_URI
- + "/projects/"
- + URLEncoder.encode(projectName, "UTF-8")
- + "/commits/"
- + URLEncoder.encode(projectVersion, "UTF-8")
- + "/files/"
- + URLEncoder.encode(filePath, "UTF-8")
- + "/content";
- return gerritPath;
- }
-
- /* Comparator for sorting the list by isIgnored field */
- public static Comparator<CoverageEntity> isIgnoredComparator =
- new Comparator<CoverageEntity>() {
-
- public int compare(CoverageEntity coverageEntity1, CoverageEntity coverageEntity2) {
- Boolean isIgnored1 =
- Objects.isNull(coverageEntity1.getIsIgnored())
- ? false
- : coverageEntity1.getIsIgnored();
- Boolean isIgnored2 =
- Objects.isNull(coverageEntity2.getIsIgnored())
- ? false
- : coverageEntity2.getIsIgnored();
-
- // ascending order
- return isIgnored1.compareTo(isIgnored2);
- }
- };
-
- public Entity toEntity() {
- Entity coverageEntity = new Entity(KIND, parentKey);
- coverageEntity.setProperty(GROUP, group);
- coverageEntity.setUnindexedProperty(COVERED_LINE_COUNT, coveredCount);
- coverageEntity.setUnindexedProperty(TOTAL_LINE_COUNT, totalCount);
- coverageEntity.setProperty(FILE_PATH, filePath);
- coverageEntity.setUnindexedProperty(PROJECT_NAME, projectName);
- coverageEntity.setUnindexedProperty(PROJECT_VERSION, projectVersion);
- if (lineCoverage != null && lineCoverage.size() > 0) {
- coverageEntity.setUnindexedProperty(LINE_COVERAGE, lineCoverage);
- }
- return coverageEntity;
- }
-
- /**
- * Convert an Entity object to a CoverageEntity.
- *
- * @param e The entity to process.
- * @return CoverageEntity object with the properties from e, or null if incompatible.
- */
- @SuppressWarnings("unchecked")
- public static CoverageEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND)
- || !e.hasProperty(GROUP)
- || !e.hasProperty(COVERED_LINE_COUNT)
- || !e.hasProperty(TOTAL_LINE_COUNT)
- || !e.hasProperty(FILE_PATH)
- || !e.hasProperty(PROJECT_NAME)
- || !e.hasProperty(PROJECT_VERSION)) {
- logger.log(Level.WARNING, "Missing coverage attributes in entity: " + e.toString());
- return null;
- }
- try {
- String group = (String) e.getProperty(GROUP);
- long coveredLineCount = (long) e.getProperty(COVERED_LINE_COUNT);
- long totalLineCount = (long) e.getProperty(TOTAL_LINE_COUNT);
- String filePath = (String) e.getProperty(FILE_PATH);
- String projectName = (String) e.getProperty(PROJECT_NAME);
- String projectVersion = (String) e.getProperty(PROJECT_VERSION);
- List<Long> lineCoverage;
- if (e.hasProperty(LINE_COVERAGE)) {
- lineCoverage = (List<Long>) e.getProperty(LINE_COVERAGE);
- } else {
- lineCoverage = new ArrayList<>();
- }
- return new CoverageEntity(
- e.getKey().getParent(),
- group,
- coveredLineCount,
- totalLineCount,
- filePath,
- projectName,
- projectVersion,
- lineCoverage);
- } catch (ClassCastException exception) {
- // Invalid contents or null values
- logger.log(Level.WARNING, "Error parsing coverage entity.", exception);
- }
- return null;
- }
-
- /**
- * Convert a coverage report to a CoverageEntity.
- *
- * @param parentKey The ancestor key for the coverage entity.
- * @param group The group to display the coverage report with.
- * @param coverage The coverage report containing coverage data.
- * @return The CoverageEntity for the coverage report message, or null if not compatible.
- */
- public static CoverageEntity fromCoverageReport(
- com.googlecode.objectify.Key parentKey, String group, CoverageReportMessage coverage) {
- if (!coverage.hasFilePath()
- || !coverage.hasProjectName()
- || !coverage.hasRevision()
- || !coverage.hasTotalLineCount()
- || !coverage.hasCoveredLineCount()) {
- return null; // invalid coverage report;
- }
- long coveredLineCount = coverage.getCoveredLineCount();
- long totalLineCount = coverage.getTotalLineCount();
- String filePath = coverage.getFilePath().toStringUtf8();
- String projectName = coverage.getProjectName().toStringUtf8();
- String projectVersion = coverage.getRevision().toStringUtf8();
- List<Long> lineCoverage = null;
- if (coverage.getLineCoverageVectorCount() > 0) {
- lineCoverage = new ArrayList<>();
- for (long count : coverage.getLineCoverageVectorList()) {
- lineCoverage.add(count);
- }
- }
- return new CoverageEntity(
- parentKey,
- group,
- coveredLineCount,
- totalLineCount,
- filePath,
- projectName,
- projectVersion,
- lineCoverage);
- }
-}
diff --git a/src/main/java/com/android/vts/entity/DashboardEntity.java b/src/main/java/com/android/vts/entity/DashboardEntity.java
deleted file mode 100644
index a42c1eb..0000000
--- a/src/main/java/com/android/vts/entity/DashboardEntity.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.google.common.collect.Lists;
-import com.googlecode.objectify.Key;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-/** Interface for interacting with VTS Dashboard entities in Cloud Datastore. */
-public interface DashboardEntity extends Serializable {
- /**
- * Save the Entity to the datastore.
- *
- * @return The saved entity's key value.
- */
- <T> Key<T> save();
-
- /** Save List of entity through objectify entities method. */
- static <T> Map<Key<T>, T> saveAll(List<T> entityList, int maxEntitySize) {
- return ofy().transact(
- () -> {
- List<List<T>> partitionedList =
- Lists.partition(entityList, maxEntitySize);
- return partitionedList
- .stream()
- .map(
- subEntityList ->
- ofy().save().entities(subEntityList).now())
- .flatMap(m -> m.entrySet().stream())
- .collect(
- Collectors.toMap(
- entry -> entry.getKey(),
- entry -> entry.getValue()));
- });
- }
-}
diff --git a/src/main/java/com/android/vts/entity/DeviceInfoEntity.java b/src/main/java/com/android/vts/entity/DeviceInfoEntity.java
deleted file mode 100644
index 2b98355..0000000
--- a/src/main/java/com/android/vts/entity/DeviceInfoEntity.java
+++ /dev/null
@@ -1,320 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.android.vts.proto.VtsReportMessage.AndroidDeviceInfoMessage;
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.memcache.MemcacheService;
-import com.google.appengine.api.memcache.MemcacheServiceFactory;
-import com.google.apphosting.api.ApiProxy;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Parent;
-import java.util.List;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@com.googlecode.objectify.annotation.Entity(name = "DeviceInfo")
-@Cache
-@Data
-@NoArgsConstructor
-/** Class describing a device used for a test run. */
-public class DeviceInfoEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(DeviceInfoEntity.class.getName());
-
- /** This is the instance of App Engine memcache service java library */
- private static MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
-
- public static final String KIND = "DeviceInfo";
-
- // Property keys
- public static final String BRANCH = "branch";
- public static final String PRODUCT = "product";
- public static final String BUILD_FLAVOR = "buildFlavor";
- public static final String BUILD_ID = "buildId";
- public static final String ABI_BITNESS = "abiBitness";
- public static final String ABI_NAME = "abiName";
-
- @Ignore
- private Key parentKey;
-
- /** ID field using start timestamp */
- @Id private Long id;
-
- /** parent field based on Test and TestRun key */
- @Parent
- private com.googlecode.objectify.Key<?> parent;
-
- @Index
- private String branch;
-
- @Index
- private String product;
-
- @Index
- private String buildFlavor;
-
- @Index
- private String buildId;
-
- private String abiBitness;
-
- private String abiName;
-
- /**
- * Create a DeviceInfoEntity object.
- *
- * @param parentKey The key for the parent entity in the database.
- * @param branch The build branch.
- * @param product The device product.
- * @param buildFlavor The device build flavor.
- * @param buildID The device build ID.
- * @param abiBitness The abi bitness of the device.
- * @param abiName The name of the abi.
- */
- public DeviceInfoEntity(
- Key parentKey,
- String branch,
- String product,
- String buildFlavor,
- String buildID,
- String abiBitness,
- String abiName) {
- this.parentKey = parentKey;
- this.branch = branch;
- this.product = product;
- this.buildFlavor = buildFlavor;
- this.buildId = buildID;
- this.abiBitness = abiBitness;
- this.abiName = abiName;
- }
-
- /**
- * Create a DeviceInfoEntity object with objectify Key
- *
- * @param parent The objectify key for the parent entity in the database.
- * @param branch The build branch.
- * @param product The device product.
- * @param buildFlavor The device build flavor.
- * @param buildID The device build ID.
- * @param abiBitness The abi bitness of the device.
- * @param abiName The name of the abi.
- */
- public DeviceInfoEntity(
- com.googlecode.objectify.Key parent,
- String branch,
- String product,
- String buildFlavor,
- String buildID,
- String abiBitness,
- String abiName) {
- this.parent = parent;
- this.branch = branch;
- this.product = product;
- this.buildFlavor = buildFlavor;
- this.buildId = buildID;
- this.abiBitness = abiBitness;
- this.abiName = abiName;
- }
-
- /**
- * Get All Branch List from DeviceInfoEntity
- */
- public static List<String> getAllBranches() {
- try {
- List<String> branchList = (List<String>) syncCache.get("branchList");
- if (Objects.isNull(branchList)) {
- branchList =
- ofy().load()
- .type(DeviceInfoEntity.class)
- .project("branch")
- .distinct(true)
- .list()
- .stream()
- .map(device -> device.branch)
- .collect(Collectors.toList());
- syncCache.put("branchList", branchList);
- }
- return branchList;
- } catch (ApiProxy.CallNotFoundException e) {
- return ofy().load()
- .type(DeviceInfoEntity.class)
- .project("branch")
- .distinct(true)
- .list()
- .stream()
- .map(device -> device.branch)
- .collect(Collectors.toList());
- }
- }
-
- /**
- * Get All BuildFlavors List from DeviceInfoEntity
- */
- public static List<String> getAllBuildFlavors() {
- try {
- List<String> buildFlavorList = (List<String>) syncCache.get("buildFlavorList");
- if (Objects.isNull(buildFlavorList)) {
- buildFlavorList =
- ofy().load()
- .type(DeviceInfoEntity.class)
- .project("buildFlavor")
- .distinct(true)
- .list()
- .stream()
- .map(device -> device.buildFlavor)
- .collect(Collectors.toList());
- syncCache.put("buildFlavorList", buildFlavorList);
- }
- return buildFlavorList;
- } catch (ApiProxy.CallNotFoundException e) {
- return ofy().load()
- .type(DeviceInfoEntity.class)
- .project("buildFlavor")
- .distinct(true)
- .list()
- .stream()
- .map(device -> device.buildFlavor)
- .collect(Collectors.toList());
- }
- }
-
- /** Saving function for the instance of this class */
- public com.googlecode.objectify.Key<DeviceInfoEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public Entity toEntity() {
- Entity deviceEntity = new Entity(KIND, this.parentKey);
- deviceEntity.setProperty(BRANCH, this.branch.toLowerCase());
- deviceEntity.setProperty(PRODUCT, this.product.toLowerCase());
- deviceEntity.setProperty(BUILD_FLAVOR, this.buildFlavor.toLowerCase());
- deviceEntity.setProperty(BUILD_ID, this.buildId.toLowerCase());
- if (this.abiBitness != null && this.abiName != null) {
- deviceEntity.setUnindexedProperty(ABI_BITNESS, this.abiBitness.toLowerCase());
- deviceEntity.setUnindexedProperty(ABI_NAME, this.abiName.toLowerCase());
- }
-
- return deviceEntity;
- }
-
- /**
- * Convert an Entity object to a DeviceInfoEntity.
- *
- * @param e The entity to process.
- * @return DeviceInfoEntity object with the properties from e, or null if incompatible.
- */
- public static DeviceInfoEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND) || !e.hasProperty(BRANCH) || !e.hasProperty(PRODUCT)
- || !e.hasProperty(BUILD_FLAVOR) || !e.hasProperty(BUILD_ID)
- || !e.hasProperty(ABI_BITNESS) || !e.hasProperty(ABI_NAME)) {
- logger.log(Level.WARNING, "Missing device info attributes in entity: " + e.toString());
- return null;
- }
- try {
- Key parentKey = e.getKey().getParent();
- String branch = (String) e.getProperty(BRANCH);
- String product = (String) e.getProperty(PRODUCT);
- String buildFlavor = (String) e.getProperty(BUILD_FLAVOR);
- String buildId = (String) e.getProperty(BUILD_ID);
- String abiBitness = null;
- String abiName = null;
- if (e.hasProperty(ABI_BITNESS) && e.hasProperty(ABI_NAME)) {
- abiBitness = (String) e.getProperty(ABI_BITNESS);
- abiName = (String) e.getProperty(ABI_NAME);
- }
- return new DeviceInfoEntity(
- parentKey, branch, product, buildFlavor, buildId, abiBitness, abiName);
- } catch (ClassCastException exception) {
- // Invalid cast
- logger.log(Level.WARNING, "Error parsing device info entity.", exception);
- }
- return null;
- }
-
- /**
- * Convert a device info message to a DeviceInfoEntity.
- *
- * @param parent The ancestor key for the device entity.
- * @param device The device info report describing the target Android device.
- * @return The DeviceInfoEntity for the target device, or null if incompatible
- */
- public static DeviceInfoEntity fromDeviceInfoMessage(
- com.googlecode.objectify.Key parent, AndroidDeviceInfoMessage device) {
- if (!device.hasBuildAlias() || !device.hasBuildFlavor() || !device.hasProductVariant()
- || !device.hasBuildId()) {
- return null;
- }
- String branch = device.getBuildAlias().toStringUtf8();
- String buildFlavor = device.getBuildFlavor().toStringUtf8();
- String product = device.getProductVariant().toStringUtf8();
- String buildId = device.getBuildId().toStringUtf8();
- String abiBitness = device.getAbiBitness().toStringUtf8();
- String abiName = device.getAbiName().toStringUtf8();
- return new DeviceInfoEntity(
- parent, branch, product, buildFlavor, buildId, abiBitness, abiName);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof DeviceInfoEntity)) {
- return false;
- }
- DeviceInfoEntity device2 = (DeviceInfoEntity) obj;
- if (!this.branch.equals(device2.branch) || !this.product.equals(device2.product)
- || !this.buildFlavor.equals(device2.buildFlavor)
- || !this.buildId.equals(device2.buildId)) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- String deviceId = this.branch + this.product + this.buildFlavor + this.buildId;
- return deviceId.hashCode();
- }
-
- /**
- * Create a copy of the device info under a near parent.
- *
- * @param parentKey The new parent key.
- * @return A copy of the DeviceInfoEntity with the specified parent.
- */
- public DeviceInfoEntity copyWithParent(com.googlecode.objectify.Key parentKey) {
- return new DeviceInfoEntity(parentKey, this.branch, this.product, this.buildFlavor,
- this.buildId, this.abiBitness, this.abiName);
- }
-
- /**
- * Create a string representation of the device build information.
- * @return A String fingerprint of the format: branch/buildFlavor (build ID)
- */
- public String getFingerprint() {
- return this.branch + "/" + this.buildFlavor + " (" + this.buildId + ")";
- }
-}
diff --git a/src/main/java/com/android/vts/entity/HalApiEntity.java b/src/main/java/com/android/vts/entity/HalApiEntity.java
deleted file mode 100644
index 16b5d10..0000000
--- a/src/main/java/com/android/vts/entity/HalApiEntity.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect;
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.googlecode.objectify.Key;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Parent;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-/** Entity Class for HalApiEntity */
-@Cache
-@Entity(name = "HalApiEntity")
-@EqualsAndHashCode(of = "id")
-@NoArgsConstructor
-@JsonAutoDetect(fieldVisibility = Visibility.ANY)
-@JsonIgnoreProperties({"id", "parent"})
-public class HalApiEntity implements DashboardEntity {
-
- /** HalApiEntity id field */
- @Id @Getter @Setter String id;
-
- @Parent @Getter Key<?> parent;
-
- /** HAL Api Release Level. e.g. */
- @Index @Getter @Setter String halApiReleaseLevel;
-
- /** HAL package name. e.g. android.hardware.foo. */
- @Index @Getter @Setter String halPackageName;
-
- /** HAL (major) version. e.g. 1. */
- @Index @Getter @Setter int halMajorVersion;
-
- /** HAL (minor) version. e.g. 0. */
- @Index @Getter @Setter int halMinorVersion;
-
- /** HAL interface name. e.g. IFoo. */
- @Index @Getter @Setter String halInterfaceName;
-
- /** List of HAL API */
- @Getter @Setter List<String> halApi;
-
- /** List of HAL covered API */
- @Getter @Setter List<String> coveredHalApi;
-
- /** When this record was created or updated */
- @Index Date updated;
-
- /** Constructor function for HalApiEntity Class */
- public HalApiEntity(
- com.googlecode.objectify.Key testRunKey,
- String halApiReleaseLevel,
- String halPackageName,
- int halMajorVersion,
- int halMinorVersion,
- String halInterfaceName,
- List<String> halApi,
- List<String> coveredHalApi) {
-
- this.id = UUID.randomUUID().toString();
- this.parent = testRunKey;
-
- this.halApiReleaseLevel = halApiReleaseLevel;
- this.halPackageName = halPackageName;
- this.halMajorVersion = halMajorVersion;
- this.halMinorVersion = halMinorVersion;
- this.halInterfaceName = halInterfaceName;
- this.halApi = halApi;
- this.coveredHalApi = coveredHalApi;
- this.updated = new Date();
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<HalApiEntity> save() {
- return ofy().save().entity(this).now();
- }
-}
diff --git a/src/main/java/com/android/vts/entity/ProfilingPointEntity.java b/src/main/java/com/android/vts/entity/ProfilingPointEntity.java
deleted file mode 100644
index 9e2cae6..0000000
--- a/src/main/java/com/android/vts/entity/ProfilingPointEntity.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.android.vts.proto.VtsReportMessage.VtsProfilingRegressionMode;
-import com.android.vts.proto.VtsReportMessage.VtsProfilingType;
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import java.util.Date;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@com.googlecode.objectify.annotation.Entity(name = "ProfilingPoint")
-@Cache
-@Data
-@NoArgsConstructor
-/** Entity describing a profiling point. */
-public class ProfilingPointEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(ProfilingPointEntity.class.getName());
- protected static final String DELIMITER = "#";
-
- public static final String KIND = "ProfilingPoint";
-
- // Property keys
- public static final String TEST_NAME = "testName";
- public static final String PROFILING_POINT_NAME = "profilingPointName";
- public static final String TYPE = "type";
- public static final String REGRESSION_MODE = "regressionMode";
- public static final String X_LABEL = "xLabel";
- public static final String Y_LABEL = "yLabel";
-
- @Ignore
- private Key key;
-
- /** ProfilingPointEntity testName field */
- @Id
- private String name;
-
- /** ProfilingPointEntity profilingPointName field */
- @Index
- private String profilingPointName;
-
- /** ProfilingPointEntity testName field */
- @Index
- private String testName;
-
- /** ProfilingPointEntity type field */
- private int type;
-
- /** ProfilingPointEntity regressionMode field */
- private int regressionMode;
-
- /** ProfilingPointEntity xLabel field */
- private String xLabel;
-
- /** ProfilingPointEntity xLabel field */
- private String yLabel;
-
- /**
- * When this record was created or updated
- */
- @Index
- Date updated;
-
- /**
- * Create a ProfilingPointEntity object.
- *
- * @param testName The name of test containing the profiling point.
- * @param profilingPointName The name of the profiling point.
- * @param type The (number) type of the profiling point data.
- * @param regressionMode The (number) mode to use for detecting regression.
- * @param xLabel The x axis label.
- * @param yLabel The y axis label.
- */
- public ProfilingPointEntity(
- String testName,
- String profilingPointName,
- int type,
- int regressionMode,
- String xLabel,
- String yLabel) {
- this.key = createKey(testName, profilingPointName);
- this.testName = testName;
- this.profilingPointName = profilingPointName;
- this.type = type;
- this.regressionMode = regressionMode;
- this.xLabel = xLabel;
- this.yLabel = yLabel;
- this.updated = new Date();
- }
-
- /**
- * Get VtsProfilingType from int value.
- *
- * @return VtsProfilingType class.
- */
- public VtsProfilingType getVtsProfilingType(int type) {
- return VtsProfilingType.forNumber(type);
- }
-
- /**
- * Get VtsProfilingRegressionMode from int value.
- *
- * @return VtsProfilingType class.
- */
- public VtsProfilingRegressionMode getVtsProfilingRegressionMode(int regressionMode) {
- return VtsProfilingRegressionMode.forNumber(regressionMode);
- }
-
- /**
- * Create a key for a ProfilingPointEntity.
- *
- * @param testName The name of test containing the profiling point.
- * @param profilingPointName The name of the profiling point.
- * @return a Key object for the ProfilingEntity in the database.
- */
- public static Key createKey(String testName, String profilingPointName) {
- return KeyFactory.createKey(KIND, testName + DELIMITER + profilingPointName);
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<ProfilingPointEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public Entity toEntity() {
- Entity profilingPoint = new Entity(key);
- profilingPoint.setIndexedProperty(TEST_NAME, this.testName);
- profilingPoint.setIndexedProperty(PROFILING_POINT_NAME, this.profilingPointName);
- profilingPoint.setUnindexedProperty(TYPE, this.type);
- profilingPoint.setUnindexedProperty(REGRESSION_MODE, this.regressionMode);
- profilingPoint.setUnindexedProperty(X_LABEL, this.xLabel);
- profilingPoint.setUnindexedProperty(Y_LABEL, this.yLabel);
-
- return profilingPoint;
- }
-
- /**
- * Convert an Entity object to a ProfilingPointEntity.
- *
- * @param e The entity to process.
- * @return ProfilingPointEntity object with the properties from e, or null if incompatible.
- */
- @SuppressWarnings("unchecked")
- public static ProfilingPointEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND)
- || e.getKey().getName() == null
- || !e.hasProperty(TEST_NAME)
- || !e.hasProperty(PROFILING_POINT_NAME)
- || !e.hasProperty(TYPE)
- || !e.hasProperty(REGRESSION_MODE)
- || !e.hasProperty(X_LABEL)
- || !e.hasProperty(Y_LABEL)) {
- logger.log(
- Level.WARNING, "Missing profiling point attributes in entity: " + e.toString());
- return null;
- }
- try {
- String testName = (String) e.getProperty(TEST_NAME);
- String profilingPointName = (String) e.getProperty(PROFILING_POINT_NAME);
- int type = (int) (long) e.getProperty(TYPE);
- int regressionMode = (int) (long) e.getProperty(REGRESSION_MODE);
- String xLabel = (String) e.getProperty(X_LABEL);
- String yLabel = (String) e.getProperty(Y_LABEL);
-
- return new ProfilingPointEntity(
- testName, profilingPointName, type, regressionMode, xLabel, yLabel);
- } catch (ClassCastException exception) {
- // Invalid cast
- logger.log(Level.WARNING, "Error parsing profiling point entity.", exception);
- }
- return null;
- }
-}
diff --git a/src/main/java/com/android/vts/entity/ProfilingPointRunEntity.java b/src/main/java/com/android/vts/entity/ProfilingPointRunEntity.java
deleted file mode 100644
index 124b61d..0000000
--- a/src/main/java/com/android/vts/entity/ProfilingPointRunEntity.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.android.vts.proto.VtsReportMessage.ProfilingReportMessage;
-import com.android.vts.proto.VtsReportMessage.VtsProfilingRegressionMode;
-import com.android.vts.proto.VtsReportMessage.VtsProfilingType;
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.google.common.collect.Lists;
-import com.google.protobuf.ByteString;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Parent;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import lombok.extern.log4j.Log4j2;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@com.googlecode.objectify.annotation.Entity(name = "ProfilingPointRun")
-@Cache
-@Data
-@NoArgsConstructor
-@Log4j2
-/** Entity describing a profiling point execution. */
-public class ProfilingPointRunEntity implements DashboardEntity {
-
- public static final String KIND = "ProfilingPointRun";
-
- // Property keys
- public static final String TYPE = "type";
- public static final String REGRESSION_MODE = "regressionMode";
- public static final String LABELS = "labels";
- public static final String VALUES = "values";
- public static final String X_LABEL = "xLabel";
- public static final String Y_LABEL = "yLabel";
- public static final String OPTIONS = "options";
-
- /** This value will set the limit size of values array field */
- public static final int VALUE_SIZE_LIMIT = 50000;
-
- @Ignore
- private Key key;
-
- /** ID field using profilingPointName */
- @Id
- private String name;
-
- /** parent field based on Test and TestRun key */
- @Parent
- private com.googlecode.objectify.Key<?> parent;
-
- /** VtsProfilingType in ProfilingPointRunEntity class */
- private int type;
-
- /** VtsProfilingType in ProfilingPointRunEntity class */
- private int regressionMode;
-
- /** list of label name */
- private List<String> labels;
-
- /** list of values */
- private List<Long> values;
-
- /** X axis label name */
- private String xLabel;
-
- /** Y axis label name */
- private String yLabel;
-
- /** Test Suite file name field */
- private List<String> options;
-
- /** When this record was created or updated */
- @Index Date updated;
-
- /**
- * Create a ProfilingPointRunEntity object.
- *
- * @param parentKey The Key object for the parent TestRunEntity in datastore.
- * @param name The name of the profiling point.
- * @param type The (number) type of the profiling point data.
- * @param regressionMode The (number) mode to use for detecting regression.
- * @param labels List of data labels, or null if the data is unlabeled.
- * @param values List of data values.
- * @param xLabel The x axis label.
- * @param yLabel The y axis label.
- * @param options The list of key=value options for the profiling point run.
- */
- public ProfilingPointRunEntity(
- Key parentKey,
- String name,
- int type,
- int regressionMode,
- List<String> labels,
- List<Long> values,
- String xLabel,
- String yLabel,
- List<String> options) {
- this.key = KeyFactory.createKey(parentKey, KIND, name);
- this.name = name;
- this.type = type;
- this.regressionMode = regressionMode;
- this.labels = labels == null ? null : new ArrayList<>(labels);
- this.values = new ArrayList<>(values);
- this.xLabel = xLabel;
- this.yLabel = yLabel;
- this.options = options;
- this.updated = new Date();
- }
-
-
- /**
- * Create a ProfilingPointRunEntity object.
- *
- * @param parent The objectify Key for the parent TestRunEntity in datastore.
- * @param name The name of the profiling point.
- * @param type The (number) type of the profiling point data.
- * @param regressionMode The (number) mode to use for detecting regression.
- * @param labels List of data labels, or null if the data is unlabeled.
- * @param values List of data values.
- * @param xLabel The x axis label.
- * @param yLabel The y axis label.
- * @param options The list of key=value options for the profiling point run.
- */
- public ProfilingPointRunEntity(
- com.googlecode.objectify.Key parent,
- String name,
- int type,
- int regressionMode,
- List<String> labels,
- List<Long> values,
- String xLabel,
- String yLabel,
- List<String> options) {
- this.parent = parent;
- this.name = name;
- this.type = type;
- this.regressionMode = regressionMode;
- this.labels = labels == null ? null : new ArrayList<>(labels);
- this.values = new ArrayList<>(values);
- this.xLabel = xLabel;
- this.yLabel = yLabel;
- this.options = options;
- this.updated = new Date();
- }
-
- /**
- * Get VtsProfilingType from int value.
- *
- * @return VtsProfilingType class.
- */
- public VtsProfilingType getVtsProfilingType(int type) {
- return VtsProfilingType.forNumber(type);
- }
-
- /**
- * Get VtsProfilingRegressionMode from int value.
- *
- * @return VtsProfilingType class.
- */
- public VtsProfilingRegressionMode getVtsProfilingRegressionMode(int regressionMode) {
- return VtsProfilingRegressionMode.forNumber(regressionMode);
- }
-
- /**
- * Save multi rows function when the record exceed the limit which is 1MB.
- *
- * @return ProfilingPointRunEntity's key value.
- */
- public com.googlecode.objectify.Key<ProfilingPointRunEntity> saveMultiRow() {
- if (this.getValues().size() > VALUE_SIZE_LIMIT) {
-
- List<List<Long>> partitionedValueList =
- Lists.partition(this.getValues(), VALUE_SIZE_LIMIT);
- int partitionedValueListSize = partitionedValueList.size();
-
- List<List<String>> partitionedLabelList = new ArrayList<>();
- if (Objects.nonNull(this.getLabels()) && this.getLabels().size() > VALUE_SIZE_LIMIT) {
- partitionedLabelList = Lists.partition(this.getLabels(), VALUE_SIZE_LIMIT);
- }
-
- com.googlecode.objectify.Key<ProfilingPointRunEntity> profilingPointRunEntityKey = null;
- if (partitionedValueListSize < VALUE_SIZE_LIMIT) {
- for (int index = 0; index < partitionedValueListSize; index++) {
- if (index > 0) {
- this.values.addAll(partitionedValueList.get(index));
- if (index < partitionedLabelList.size()) {
- this.labels.addAll(partitionedLabelList.get(index));
- }
- } else {
- this.values = partitionedValueList.get(index);
- if (index < partitionedLabelList.size()) {
- this.labels = partitionedLabelList.get(index);
- }
- }
- profilingPointRunEntityKey = ofy().save().entity(this).now();
- }
- }
- return profilingPointRunEntityKey;
- } else {
- return ofy().save().entity(this).now();
- }
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<ProfilingPointRunEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public Entity toEntity() {
- Entity profilingRun = new Entity(this.key);
- profilingRun.setUnindexedProperty(TYPE, this.type);
- profilingRun.setUnindexedProperty(REGRESSION_MODE, this.regressionMode);
- if (this.labels != null) {
- profilingRun.setUnindexedProperty(LABELS, this.labels);
- }
- profilingRun.setUnindexedProperty(VALUES, this.values);
- profilingRun.setUnindexedProperty(X_LABEL, this.xLabel);
- profilingRun.setUnindexedProperty(Y_LABEL, this.yLabel);
- if (this.options != null) {
- profilingRun.setUnindexedProperty(OPTIONS, this.options);
- }
-
- return profilingRun;
- }
-
- /**
- * Convert an Entity object to a ProflilingPointRunEntity.
- *
- * @param e The entity to process.
- * @return ProfilingPointRunEntity object with the properties from e, or null if incompatible.
- */
- @SuppressWarnings("unchecked")
- public static ProfilingPointRunEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND)
- || e.getKey().getName() == null
- || !e.hasProperty(TYPE)
- || !e.hasProperty(REGRESSION_MODE)
- || !e.hasProperty(VALUES)
- || !e.hasProperty(X_LABEL)
- || !e.hasProperty(Y_LABEL)) {
- log.error("Missing profiling point attributes in entity: " + e.toString());
- return null;
- }
- try {
- Key parentKey = e.getParent();
- String name = e.getKey().getName();
- int type = (int) (long) e.getProperty(TYPE);
- int regressionMode = (int) (long) e.getProperty(REGRESSION_MODE);
- List<Long> values = (List<Long>) e.getProperty(VALUES);
- String xLabel = (String) e.getProperty(X_LABEL);
- String yLabel = (String) e.getProperty(Y_LABEL);
- List<String> labels = null;
- if (e.hasProperty(LABELS)) {
- labels = (List<String>) e.getProperty(LABELS);
- }
- List<String> options = null;
- if (e.hasProperty(OPTIONS)) {
- options = (List<String>) e.getProperty(OPTIONS);
- }
- return new ProfilingPointRunEntity(
- parentKey, name, type, regressionMode, labels, values, xLabel, yLabel, options);
- } catch (ClassCastException exception) {
- // Invalid cast
- log.warn("Error parsing profiling point run entity.", exception);
- }
- return null;
- }
-
- /**
- * Convert a coverage report to a CoverageEntity.
- *
- * @param parent The ancestor objectify key for the coverage entity.
- * @param profilingReport The profiling report containing profiling data.
- * @return The ProfilingPointRunEntity for the profiling report message, or null if incompatible
- */
- public static ProfilingPointRunEntity fromProfilingReport(
- com.googlecode.objectify.Key parent, ProfilingReportMessage profilingReport) {
- if (!profilingReport.hasName()
- || !profilingReport.hasType()
- || profilingReport.getType() == VtsProfilingType.UNKNOWN_VTS_PROFILING_TYPE
- || !profilingReport.hasRegressionMode()
- || !profilingReport.hasXAxisLabel()
- || !profilingReport.hasYAxisLabel()) {
- return null; // invalid profiling report;
- }
- String name = profilingReport.getName().toStringUtf8();
- VtsProfilingType type = profilingReport.getType();
- VtsProfilingRegressionMode regressionMode = profilingReport.getRegressionMode();
- String xLabel = profilingReport.getXAxisLabel().toStringUtf8();
- String yLabel = profilingReport.getYAxisLabel().toStringUtf8();
- List<Long> values;
- List<String> labels = null;
- switch (type) {
- case VTS_PROFILING_TYPE_TIMESTAMP:
- if (!profilingReport.hasStartTimestamp()
- || !profilingReport.hasEndTimestamp()
- || profilingReport.getEndTimestamp()
- < profilingReport.getStartTimestamp()) {
- return null; // missing timestamp
- }
- long value =
- profilingReport.getEndTimestamp() - profilingReport.getStartTimestamp();
- values = new ArrayList<>();
- values.add(value);
- break;
- case VTS_PROFILING_TYPE_LABELED_VECTOR:
- if (profilingReport.getValueCount() != profilingReport.getLabelCount()) {
- return null; // jagged data
- }
- labels = new ArrayList<>();
- for (ByteString label : profilingReport.getLabelList()) {
- labels.add(label.toStringUtf8());
- }
- values = profilingReport.getValueList();
- break;
- case VTS_PROFILING_TYPE_UNLABELED_VECTOR:
- values = profilingReport.getValueList();
- break;
- default: // should never happen
- return null;
- }
- if (values.size() > VALUE_SIZE_LIMIT) {
- values = values.subList(0, VALUE_SIZE_LIMIT);
- }
- List<String> options = null;
- if (profilingReport.getOptionsCount() > 0) {
- options = new ArrayList<>();
- for (ByteString optionBytes : profilingReport.getOptionsList()) {
- options.add(optionBytes.toStringUtf8());
- }
- }
- return new ProfilingPointRunEntity(
- parent,
- name,
- type.getNumber(),
- regressionMode.getNumber(),
- labels,
- values,
- xLabel,
- yLabel,
- options);
- }
-}
diff --git a/src/main/java/com/android/vts/entity/ProfilingPointSummaryEntity.java b/src/main/java/com/android/vts/entity/ProfilingPointSummaryEntity.java
deleted file mode 100644
index e4a1911..0000000
--- a/src/main/java/com/android/vts/entity/ProfilingPointSummaryEntity.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.android.vts.proto.VtsReportMessage.VtsProfilingRegressionMode;
-import com.android.vts.util.StatSummary;
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@com.googlecode.objectify.annotation.Entity(name = "ProfilingPointSummary")
-@Cache
-@Data
-@NoArgsConstructor
-/** Entity describing a profiling point summary. */
-public class ProfilingPointSummaryEntity implements DashboardEntity {
- protected static final Logger logger =
- Logger.getLogger(ProfilingPointSummaryEntity.class.getName());
- protected static final String DELIMITER = "#";
-
- public static final String KIND = "ProfilingPointSummary";
- public static final String ALL = "ALL";
-
- // Property keys
- public static final String START_TIME = "startTime";
- public static final String MEAN = "mean";
- public static final String SUMSQ = "sumSq";
- public static final String MIN = "min";
- public static final String MAX = "max";
- public static final String LABELS = "labels";
- public static final String LABEL_MEANS = "labelMeans";
- public static final String LABEL_SUMSQS = "labelSumSqs";
- public static final String LABEL_MINS = "labelMins";
- public static final String LABEL_MAXES = "labelMaxes";
- public static final String LABEL_COUNTS = "labelCounts";
- public static final String COUNT = "count";
- public static final String BRANCH = "branch";
- public static final String BUILD_FLAVOR = "buildFlavor";
- public static final String SERIES = "series";
-
- @Ignore
- private Key key;
-
- /** ID field */
- @Id private String name;
-
- /** branch field */
- @Index private String branch;
-
- /** build field */
- @Index private String buildFlavor;
-
- /** total count */
- @Index private int count;
-
- /** For each label count field */
- @Index private List<String> labelCounts;
-
- /** Maximum value for each label */
- private List<Integer> labelMaxes;
-
- /** Mean value for each label */
- private List<Integer> labelMeans;
-
- /** Minimum value for each label */
- private List<Integer> labelMins;
-
- /** Label name for each label point */
- private List<String> labels;
-
- /** Summation for sequence for each label */
- private List<Integer> labelSumSqs;
-
- /** Maximum value for total */
- private Long max;
-
- /** Mean value for total */
- private Long mean;
-
- /** Minimum value for total */
- private Long min;
-
- /** The list of series */
- private String series;
-
- /** The start time field of the test */
- private Long startTime;
-
- /** The summation of sequences */
- private Long sumSq;
-
- @Ignore private StatSummary globalStats;
-
- @Ignore private Map<String, StatSummary> labelStats;
-
- /*
- public final StatSummary globalStats;
- public final List<String> labels;
- public final Map<String, StatSummary> labelStats;
- public final String branch;
- public final String buildFlavor;
- public final String series;
- public final long startTime;
- */
-
- /**
- * Create a ProfilingPointSummaryEntity object.
- *
- * @param parentKey The Key object for the parent TestRunEntity in the database.
- * @param globalStats The StatSummary object recording global statistics about the profiling
- * point.
- * @param labels The list of data labels.
- * @param labelStats The map from data label to StatSummary object for the label.
- * @param branch The branch.
- * @param buildFlavor The device build flavor.
- * @param series The string describing the profiling point series (e.g. binder or passthrough).
- * @param startTime The timestamp indicating the beginning of the summary.
- */
- public ProfilingPointSummaryEntity(
- Key parentKey,
- StatSummary globalStats,
- List<String> labels,
- Map<String, StatSummary> labelStats,
- String branch,
- String buildFlavor,
- String series,
- long startTime) {
- this.globalStats = globalStats;
- this.labels = labels;
- this.labelStats = labelStats;
- this.buildFlavor = buildFlavor == null ? ALL : buildFlavor;
- this.branch = branch == null ? ALL : branch;
- this.series = series == null ? "" : series;
- this.startTime = startTime;
- this.key = createKey(parentKey, this.branch, this.buildFlavor, this.series, this.startTime);
- }
-
- /**
- * Create a new ProfilingPointSummaryEntity object.
- *
- * @param parentKey The Key object for the parent TestRunEntity in the database.
- * @param branch The branch.
- * @param buildFlavor The buildFlavor name.
- * @param series The string describing the profiling point series (e.g. binder or passthrough).
- * @param startTime The timestamp indicating the beginning of the summary.
- */
- public ProfilingPointSummaryEntity(
- Key parentKey, String branch, String buildFlavor, String series, long startTime) {
- this(
- parentKey,
- new StatSummary(null, VtsProfilingRegressionMode.UNKNOWN_REGRESSION_MODE),
- new ArrayList<>(),
- new HashMap<>(),
- branch,
- buildFlavor,
- series,
- startTime);
- }
-
- /**
- * Create a key for a ProfilingPointSummaryEntity.
- *
- * @param parentKey The Key object for the parent TestRunEntity in the database.
- * @param branch The branch.
- * @param buildFlavor The device build flavor.
- * @param series The string describing the profiling point series (e.g. binder or passthrough).
- * @param startTime The timestamp indicating the beginning of the summary.
- * @return a Key object for the ProfilingPointSummaryEntity in the database.
- */
- public static Key createKey(
- Key parentKey, String branch, String buildFlavor, String series, long startTime) {
- StringBuilder sb = new StringBuilder();
- sb.append(branch);
- sb.append(DELIMITER);
- sb.append(buildFlavor);
- sb.append(DELIMITER);
- sb.append(series);
- sb.append(DELIMITER);
- sb.append(startTime);
- return KeyFactory.createKey(parentKey, KIND, sb.toString());
- }
-
- /**
- * Updates the profiling summary with the data from a new profiling report.
- *
- * @param profilingRun The profiling point run entity object containing profiling data.
- */
- public void update(ProfilingPointRunEntity profilingRun) {
- if (profilingRun.getLabels() != null
- && profilingRun.getLabels().size() == profilingRun.getValues().size()) {
- for (int i = 0; i < profilingRun.getLabels().size(); i++) {
- String label = profilingRun.getLabels().get(i);
- if (!this.labelStats.containsKey(label)) {
- VtsProfilingRegressionMode vtsProfilingRegressionMode =
- profilingRun.getVtsProfilingRegressionMode(
- profilingRun.getRegressionMode());
- StatSummary summary = new StatSummary(label, vtsProfilingRegressionMode);
- this.labelStats.put(label, summary);
- }
- StatSummary summary = this.labelStats.get(label);
- summary.updateStats(profilingRun.getValues().get(i));
- }
- this.labels.clear();
- this.labels.addAll(profilingRun.getLabels());
- }
- for (long value : profilingRun.getValues()) {
- this.globalStats.updateStats(value);
- }
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<ProfilingPointSummaryEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public Entity toEntity() {
- Entity profilingSummary;
- profilingSummary = new Entity(this.key);
- profilingSummary.setUnindexedProperty(MEAN, this.globalStats.getMean());
- profilingSummary.setUnindexedProperty(SUMSQ, this.globalStats.getSumSq());
- profilingSummary.setUnindexedProperty(MIN, this.globalStats.getMin());
- profilingSummary.setUnindexedProperty(MAX, this.globalStats.getMax());
- profilingSummary.setUnindexedProperty(COUNT, this.globalStats.getCount());
- profilingSummary.setIndexedProperty(START_TIME, this.startTime);
- profilingSummary.setIndexedProperty(BRANCH, this.branch);
- profilingSummary.setIndexedProperty(BUILD_FLAVOR, this.buildFlavor);
- profilingSummary.setIndexedProperty(SERIES, this.series);
- if (this.labels.size() != 0) {
- List<Double> labelMeans = new ArrayList<>();
- List<Double> labelSumsqs = new ArrayList<>();
- List<Double> labelMins = new ArrayList<>();
- List<Double> labelMaxes = new ArrayList<>();
- List<Long> labelCounts = new ArrayList<>();
- for (String label : this.labels) {
- if (!this.labelStats.containsKey(label)) continue;
- StatSummary labelStat = this.labelStats.get(label);
- labelMeans.add(labelStat.getMean());
- labelSumsqs.add(labelStat.getSumSq());
- labelMins.add(labelStat.getMin());
- labelMaxes.add(labelStat.getMax());
- labelCounts.add(new Long(labelStat.getCount()));
- }
- profilingSummary.setUnindexedProperty(LABELS, this.labels);
- profilingSummary.setUnindexedProperty(LABEL_MEANS, labelMeans);
- profilingSummary.setUnindexedProperty(LABEL_SUMSQS, labelSumsqs);
- profilingSummary.setUnindexedProperty(LABEL_MINS, labelMins);
- profilingSummary.setUnindexedProperty(LABEL_MAXES, labelMaxes);
- profilingSummary.setUnindexedProperty(LABEL_COUNTS, labelCounts);
- }
-
- return profilingSummary;
- }
-
- /**
- * Convert an Entity object to a ProfilingPointSummaryEntity.
- *
- * @param e The entity to process.
- * @return ProfilingPointSummaryEntity object with the properties from e, or null if
- * incompatible.
- */
- @SuppressWarnings("unchecked")
- public static ProfilingPointSummaryEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND)
- || !e.hasProperty(MEAN)
- || !e.hasProperty(SUMSQ)
- || !e.hasProperty(MIN)
- || !e.hasProperty(MAX)
- || !e.hasProperty(COUNT)
- || !e.hasProperty(START_TIME)
- || !e.hasProperty(BRANCH)
- || !e.hasProperty(BUILD_FLAVOR)
- || !e.hasProperty(SERIES)) {
- logger.log(
- Level.WARNING, "Missing profiling point attributes in entity: " + e.toString());
- return null;
- }
- try {
- Key parentKey = e.getParent();
- double mean = (double) e.getProperty(MEAN);
- double sumsq = (double) e.getProperty(SUMSQ);
- double min = (double) e.getProperty(MIN);
- double max = (double) e.getProperty(MAX);
- int count = (int) (long) e.getProperty(COUNT);
- StatSummary globalStats =
- new StatSummary(
- null,
- min,
- max,
- mean,
- sumsq,
- count,
- VtsProfilingRegressionMode.UNKNOWN_REGRESSION_MODE);
- Map<String, StatSummary> labelStats = new HashMap<>();
- List<String> labels = new ArrayList<>();
- if (e.hasProperty(LABELS)) {
- labels = (List<String>) e.getProperty(LABELS);
- List<Double> labelMeans = (List<Double>) e.getProperty(LABEL_MEANS);
- List<Double> labelSumsqs = (List<Double>) e.getProperty(LABEL_SUMSQS);
- List<Double> labelMins = (List<Double>) e.getProperty(LABEL_MINS);
- List<Double> labelMaxes = (List<Double>) e.getProperty(LABEL_MAXES);
- List<Long> labelCounts = (List<Long>) e.getProperty(LABEL_COUNTS);
- if (labels.size() != labelMeans.size()
- || labels.size() != labelSumsqs.size()
- || labels.size() != labelMins.size()
- || labels.size() != labelMaxes.size()
- || labels.size() != labelCounts.size()) {
- logger.log(Level.WARNING, "Jagged label information for entity: " + e.getKey());
- return null;
- }
- for (int i = 0; i < labels.size(); ++i) {
- StatSummary labelStat =
- new StatSummary(
- labels.get(i),
- labelMins.get(i),
- labelMaxes.get(i),
- labelMeans.get(i),
- labelSumsqs.get(i),
- labelCounts.get(i).intValue(),
- VtsProfilingRegressionMode.UNKNOWN_REGRESSION_MODE);
- labelStats.put(labels.get(i), labelStat);
- }
- }
- String branch = (String) e.getProperty(BRANCH);
- String buildFlavor = (String) e.getProperty(BUILD_FLAVOR);
- String series = (String) e.getProperty(SERIES);
- long startTime = (long) e.getProperty(START_TIME);
- return new ProfilingPointSummaryEntity(
- parentKey,
- globalStats,
- labels,
- labelStats,
- branch,
- buildFlavor,
- series,
- startTime);
- } catch (ClassCastException exception) {
- // Invalid cast
- logger.log(Level.WARNING, "Error parsing profiling point summary entity.", exception);
- }
- return null;
- }
-}
diff --git a/src/main/java/com/android/vts/entity/RoleEntity.java b/src/main/java/com/android/vts/entity/RoleEntity.java
deleted file mode 100644
index 508a9ca..0000000
--- a/src/main/java/com/android/vts/entity/RoleEntity.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.android.vts.entity;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-import com.googlecode.objectify.Key;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import java.util.Date;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-
-@Cache
-@Entity
-@EqualsAndHashCode(of = "role")
-@NoArgsConstructor
-public class RoleEntity implements DashboardEntity {
-
- private static final long serialVersionUID = 1L;
-
- @Id private String role;
-
- /** When this record was created or updated */
- @Getter Date updated;
-
- /** Construction function for UserEntity Class */
- public RoleEntity(String roleName) {
- this.role = roleName;
- }
-
- /** Get role by email */
- public static RoleEntity getRole(String role) {
- return ofy().load().type(RoleEntity.class).id(role).now();
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<RoleEntity> save() {
- this.updated = new Date();
- return ofy().save().entity(this).now();
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestAcknowledgmentEntity.java b/src/main/java/com/android/vts/entity/TestAcknowledgmentEntity.java
deleted file mode 100644
index a594f85..0000000
--- a/src/main/java/com/android/vts/entity/TestAcknowledgmentEntity.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.google.appengine.api.datastore.Text;
-import com.google.appengine.api.users.User;
-import com.google.gson.Gson;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.reflect.TypeToken;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import lombok.Data;
-
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@com.googlecode.objectify.annotation.Entity(name = "TestAcknowledgment")
-@Cache
-@Data
-/** Entity describing a test failure acknowledgment. */
-public class TestAcknowledgmentEntity implements DashboardEntity {
- protected static final Logger logger =
- Logger.getLogger(TestAcknowledgmentEntity.class.getName());
-
- public static final String KIND = "TestAcknowledgment";
- public static final String KEY = "key";
- public static final String TEST_KEY = "testKey";
- public static final String TEST_NAME = "testName";
- public static final String USER_OBJ = "userObj";
- public static final String CREATED = "created";
- public static final String BRANCHES = "branches";
- public static final String DEVICES = "devices";
- public static final String TEST_CASE_NAMES = "testCaseNames";
- public static final String NOTE = "note";
-
- @Ignore private final Key key;
- @Ignore public final Key test;
- @Ignore public final User userObj;
-
- @Id private Long id;
-
- private com.googlecode.objectify.Key testKey;
- private Set<String> branches;
- private Set<String> devices;
- private Set<String> testCaseNames;
- private String note;
- private String user;
-
- @Index private final long created;
-
- /**
- * Create a AcknowledgmentEntity object.
- *
- * @param key The key of the AcknowledgmentEntity in the database.
- * @param created The timestamp when the entity was created (in microseconds).
- * @param test The key of the test.
- * @param userObj The user who created or last modified the entity.
- * @param branches The list of branch names for which the acknowledgment applies (or null if
- * all).
- * @param devices The list of device build flavors for which the acknowledgment applies (or null
- * if all).
- * @param testCaseNames The list of test case names known to fail (or null if all).
- * @param note A text blob with details about the failure (or null if all).
- */
- private TestAcknowledgmentEntity(
- Key key,
- long created,
- Key test,
- User userObj,
- List<String> branches,
- List<String> devices,
- List<String> testCaseNames,
- Text note) {
- this.test = test;
- this.userObj = userObj;
- if (branches != null) this.branches = new HashSet(branches);
- else this.branches = new HashSet<>();
-
- if (devices != null) this.devices = new HashSet(devices);
- else this.devices = new HashSet<>();
-
- if (testCaseNames != null) this.testCaseNames = new HashSet(testCaseNames);
- else this.testCaseNames = new HashSet<>();
-
- if (note != null) this.note = note.getValue();
- else this.note = null;
-
- this.key = key;
- this.created = created;
- }
-
- /**
- * Create a AcknowledgmentEntity object.
- *
- * @param test The key of the test.
- * @param userObj The user who created or last modified the entity.
- * @param branches The list of branch names for which the acknowledgment applies (or null if
- * all).
- * @param devices The list of device build flavors for which the acknowledgment applies (or null
- * if all).
- * @param testCaseNames The list of test case names known to fail (or null if all).
- * @param note A text blob with details about the failure (or null if all).
- */
- public TestAcknowledgmentEntity(
- Key test,
- User userObj,
- List<String> branches,
- List<String> devices,
- List<String> testCaseNames,
- Text note) {
- this(null, -1, test, userObj, branches, devices, testCaseNames, note);
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<TestAcknowledgmentEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public Entity toEntity() {
- Entity ackEntity;
- if (this.key == null) ackEntity = new Entity(KIND);
- else ackEntity = new Entity(key);
-
- ackEntity.setProperty(TEST_KEY, this.test);
- ackEntity.setProperty(USER_OBJ, this.userObj);
-
- long created = this.created;
- if (created < 0) created = TimeUnit.MILLISECONDS.toMicros(System.currentTimeMillis());
- ackEntity.setProperty(CREATED, created);
-
- if (this.branches != null && this.branches.size() > 0)
- ackEntity.setUnindexedProperty(BRANCHES, new ArrayList<>(this.branches));
-
- if (this.devices != null && this.devices.size() > 0)
- ackEntity.setUnindexedProperty(DEVICES, new ArrayList<>(this.devices));
-
- if (this.testCaseNames != null && this.testCaseNames.size() > 0)
- ackEntity.setUnindexedProperty(TEST_CASE_NAMES, new ArrayList<>(this.testCaseNames));
-
- if (this.note != null) ackEntity.setUnindexedProperty(NOTE, new Text(this.note));
- return ackEntity;
- }
-
- /**
- * Convert an Entity object to a TestAcknowledgmentEntity.
- *
- * @param e The entity to process.
- * @return TestEntity object with the properties from e processed, or null if incompatible.
- */
- @SuppressWarnings("unchecked")
- public static TestAcknowledgmentEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND)
- || !e.hasProperty(TEST_KEY)
- || !e.hasProperty(USER_OBJ)
- || !e.hasProperty(CREATED)) {
- logger.log(
- Level.WARNING, "Missing attributes in acknowledgment entity: " + e.toString());
- return null;
- }
- try {
- Key test = (Key) e.getProperty(TEST_KEY);
- User user = (User) e.getProperty(USER_OBJ);
- long created = (long) e.getProperty(CREATED);
-
- List<String> branches;
- if (e.hasProperty(BRANCHES)) branches = (List<String>) e.getProperty(BRANCHES);
- else branches = null;
-
- List<String> devices;
- if (e.hasProperty(DEVICES)) devices = (List<String>) e.getProperty(DEVICES);
- else devices = null;
-
- List<String> testCaseNames;
- if (e.hasProperty(TEST_CASE_NAMES))
- testCaseNames = (List<String>) e.getProperty(TEST_CASE_NAMES);
- else testCaseNames = null;
-
- Text note = null;
- if (e.hasProperty(NOTE)) note = (Text) e.getProperty(NOTE);
- return new TestAcknowledgmentEntity(
- e.getKey(), created, test, user, branches, devices, testCaseNames, note);
- } catch (ClassCastException exception) {
- logger.log(Level.WARNING, "Corrupted data in entity: " + e.getKey());
- return null;
- }
- }
-
- /**
- * Convert a JSON object to a TestAcknowledgmentEntity.
- *
- * @param user The user requesting the conversion.
- * @param json The json object to convert.
- * @return TestAcknowledgmentEntity with the data from the json object.
- */
- public static TestAcknowledgmentEntity fromJson(User user, JsonObject json) {
- try {
- if (!json.has(TEST_NAME)) return null;
- String testName = json.get(TEST_NAME).getAsString();
- Key testKey = KeyFactory.createKey(TestEntity.KIND, testName);
- List<String> branches = null;
-
- Type listType = new TypeToken<List<String>>() {}.getType();
- if (json.has(BRANCHES)) {
- branches = new Gson().fromJson(json.get(BRANCHES), listType);
- }
-
- List<String> devices = null;
- if (json.has(DEVICES)) {
- devices = new Gson().fromJson(json.get(DEVICES), listType);
- }
-
- List<String> testCaseNames = null;
- if (json.has(TEST_CASE_NAMES)) {
- testCaseNames = new Gson().fromJson(json.get(TEST_CASE_NAMES), listType);
- }
-
- Text note = null;
- if (json.has(NOTE)) {
- note = new Text(json.get(NOTE).getAsString());
- }
-
- Key key = null;
- if (json.has(KEY)) {
- key = KeyFactory.stringToKey(json.get(KEY).getAsString());
- }
- return new TestAcknowledgmentEntity(
- key, -1l, testKey, user, branches, devices, testCaseNames, note);
- } catch (ClassCastException | IllegalStateException e) {
- return null;
- }
- }
-
- /**
- * Convert the entity to a json object.
- *
- * @return The entity serialized in JSON format.
- */
- public JsonObject toJson() {
- JsonObject json = new JsonObject();
- json.add(KEY, new JsonPrimitive(KeyFactory.keyToString(this.key)));
- json.add(TEST_NAME, new JsonPrimitive(this.test.getName()));
- json.add(USER_OBJ, new JsonPrimitive(this.userObj.getEmail()));
- json.add(CREATED, new JsonPrimitive(this.created));
-
- List<JsonElement> branches = new ArrayList<>();
- if (this.branches != null) {
- for (String branch : this.branches) {
- branches.add(new JsonPrimitive(branch));
- }
- }
- json.add(BRANCHES, new Gson().toJsonTree(branches));
-
- List<JsonElement> devices = new ArrayList<>();
- if (this.devices != null) {
- for (String device : this.devices) {
- devices.add(new JsonPrimitive(device));
- }
- }
- json.add(DEVICES, new Gson().toJsonTree(devices));
-
- List<JsonElement> testCaseNames = new ArrayList<>();
- if (this.testCaseNames != null) {
- for (String testCaseName : this.testCaseNames) {
- testCaseNames.add(new JsonPrimitive(testCaseName));
- }
- }
- json.add(TEST_CASE_NAMES, new Gson().toJsonTree(testCaseNames));
-
- String note = "";
- if (this.note != null) note = this.note;
- json.add(NOTE, new JsonPrimitive(note));
- return json;
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestCaseRunEntity.java b/src/main/java/com/android/vts/entity/TestCaseRunEntity.java
deleted file mode 100644
index 85a6c43..0000000
--- a/src/main/java/com/android/vts/entity/TestCaseRunEntity.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.OnLoad;
-import java.util.ArrayList;
-import java.util.List;
-import lombok.Data;
-import lombok.extern.slf4j.Slf4j;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@com.googlecode.objectify.annotation.Entity(name = "TestCaseRun")
-@Cache
-@Data
-@Slf4j
-/** Entity describing the execution of a test case. */
-public class TestCaseRunEntity implements DashboardEntity {
-
- public static final String KIND = "TestCaseRun";
-
- // Property keys
- public static final String TEST_CASE_NAME = "testCaseName";
- public static final String RESULT = "result";
- public static final String TEST_CASE_NAMES = "testCaseNames";
- public static final String RESULTS = "results";
- public static final String SYSTRACE_URL = "systraceUrl";
-
- // Maximum number of test cases in the entity.
- private static final int SIZE_LIMIT = 500;
-
- @Id
- private Long id;
-
- private List<Integer> results;
-
- private List<String> testCaseNames;
-
- @Ignore
- public final List<TestCase> testCases;
-
- @Ignore
- private String systraceUrl;
-
- /**
- * Class describing an individual test case run.
- */
- public static class TestCase {
- public final long parentId;
- public final int offset;
- public final String name;
- public final int result;
-
- /**
- * Create a test case run.
- * @param parentId The ID of the TestCaseRunEntity containing the test case.
- * @param offset The offset of the TestCase into the TestCaseRunEntity.
- * @param name The name of the test case.
- * @param result The result of the test case.
- */
- public TestCase(long parentId, int offset, String name, int result) {
- this.parentId = parentId;
- this.offset = offset;
- this.name = name;
- this.result = result;
- }
- }
-
- /**
- * Create a TestCaseRunEntity.
- */
- public TestCaseRunEntity() {
- this.results = new ArrayList<>();
- this.testCaseNames = new ArrayList<>();
- this.testCases = new ArrayList<>();
- this.systraceUrl = null;
- }
-
- /**
- * Create a TestCaseRunEntity with the specified id.
- * @param id The entity id.
- */
- public TestCaseRunEntity(long id) {
- this.id = id;
- this.results = new ArrayList<>();
- this.testCaseNames = new ArrayList<>();
- this.testCases = new ArrayList<>();
- this.systraceUrl = null;
- }
-
- /**
- * Determine if the TestCaseRunEntity is full.
- * @return True if the entity is full, false otherwise.
- */
- public boolean isFull() {
- return this.testCases.size() >= SIZE_LIMIT;
- }
-
- /**
- * Set the systrace url.
- * @param url The systrace url, or null.
- */
- private void setSystraceUrl(String url) {
- this.systraceUrl = url;
- }
-
- /**
- * Get the systrace url.
- * returns The systrace url, or null.
- */
- public String getSystraceUrl() {
- return this.systraceUrl;
- }
-
- /**
- * Called after the POJO is populated with data through objecitfy library
- */
- @OnLoad
- private void onLoad() {
- if (testCaseNames.size() == results.size()) {
- for (int index = 0; index < testCaseNames.size(); index++) {
- String name = testCaseNames.get(index);
- int result = results.get(index).intValue();
- this.testCases.add(new TestCase(this.id, this.testCases.size(), name, result));
- }
- }
- }
-
- /**
- * Add a test case to the test case run entity.
- * @param name The name of the test case.
- * @param result The result of the test case.
- * @return true if added, false otherwise.
- */
- public boolean addTestCase(String name, int result) {
- if (this.isFull()) {
- return false;
- } else {
- this.testCaseNames.add(name);
- this.results.add(result);
- return true;
- }
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<TestCaseRunEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public Entity toEntity() {
- Entity testCaseRunEntity;
- if (this.id >= 0) {
- testCaseRunEntity = new Entity(KeyFactory.createKey(KIND, id));
- } else {
- testCaseRunEntity = new Entity(KIND);
- }
-
- if (this.testCases.size() > 0) {
- List<String> testCaseNames = new ArrayList<>();
- List<Integer> results = new ArrayList<>();
- for (TestCase testCase : this.testCases) {
- testCaseNames.add(testCase.name);
- results.add(testCase.result);
- }
- testCaseRunEntity.setUnindexedProperty(TEST_CASE_NAMES, testCaseNames);
- testCaseRunEntity.setUnindexedProperty(RESULTS, results);
- }
- if (systraceUrl != null) {
- testCaseRunEntity.setUnindexedProperty(SYSTRACE_URL, this.systraceUrl);
- }
-
- return testCaseRunEntity;
- }
-
- /**
- * Convert an Entity object to a TestCaseRunEntity.
- *
- * @param e The entity to process.
- * @return TestCaseRunEntity object with the properties from e, or null if incompatible.
- */
- @SuppressWarnings("unchecked")
- public static TestCaseRunEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND)) {
- log.warn("Wrong kind: " + e.getKey());
- return null;
- }
- try {
- TestCaseRunEntity testCaseRun = new TestCaseRunEntity(e.getKey().getId());
- if (e.hasProperty(TEST_CASE_NAMES) && e.hasProperty(RESULTS)) {
- List<String> testCaseNames = (List<String>) e.getProperty(TEST_CASE_NAMES);
- List<Long> results = (List<Long>) e.getProperty(RESULTS);
- if (testCaseNames.size() == results.size()) {
- for (int i = 0; i < testCaseNames.size(); i++) {
- testCaseRun.addTestCase(testCaseNames.get(i), results.get(i).intValue());
- }
- }
- }
- if (e.hasProperty(TEST_CASE_NAME) && e.hasProperty(RESULT)) {
- testCaseRun.addTestCase(
- (String) e.getProperty(TEST_CASE_NAME), (int) (long) e.getProperty(RESULT));
- }
- if (e.hasProperty(SYSTRACE_URL)) {
- String systraceUrl = (String) e.getProperty(SYSTRACE_URL);
- testCaseRun.setSystraceUrl(systraceUrl);
- }
- return testCaseRun;
- } catch (ClassCastException exception) {
- // Invalid cast
- log.warn("Error parsing test case run entity.", exception);
- }
- return null;
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestCoverageStatusEntity.java b/src/main/java/com/android/vts/entity/TestCoverageStatusEntity.java
deleted file mode 100644
index 1156cc7..0000000
--- a/src/main/java/com/android/vts/entity/TestCoverageStatusEntity.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-import com.google.appengine.api.datastore.Entity;
-import com.googlecode.objectify.Key;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Index;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-@com.googlecode.objectify.annotation.Entity(name = "TestCoverageStatus")
-@EqualsAndHashCode(of = "testName")
-@Cache
-@NoArgsConstructor
-/** Entity describing test coverage status. */
-public class TestCoverageStatusEntity implements DashboardEntity {
-
- protected static final Logger logger =
- Logger.getLogger(TestCoverageStatusEntity.class.getName());
-
- public static final String KIND = "TestCoverageStatus";
-
- // Property keys
- public static final String TOTAL_LINE_COUNT = "totalLineCount";
- public static final String COVERED_LINE_COUNT = "coveredLineCount";
- public static final String UPDATED_TIMESTAMP = "updatedTimestamp";
- public static final String DEVICE_INFO_ID = "deviceInfoId";
-
- /** TestCoverageStatusEntity name field */
- @Id @Getter @Setter String testName;
-
- /** TestCoverageStatusEntity coveredLineCount field */
- @Index @Getter @Setter long coveredLineCount;
-
- /** TestCoverageStatusEntity totalLineCount field */
- @Index @Getter @Setter long totalLineCount;
-
- /** TestCoverageStatusEntity updatedTimestamp field */
- @Index @Getter @Setter long updatedTimestamp;
-
- /** TestCoverageStatusEntity DeviceInfo Entity ID reference field */
- @Index @Getter @Setter long deviceInfoId;
-
- /** TestCoverageStatusEntity updatedCoveredLineCount field */
- @Index @Getter @Setter long updatedCoveredLineCount;
-
- /** TestCoverageStatusEntity updatedTotalLineCount field */
- @Index @Getter @Setter long updatedTotalLineCount;
-
- /** TestCoverageStatusEntity updatedDate field */
- @Index @Getter @Setter Date updatedDate;
-
- /**
- * Create a TestCoverageStatusEntity object with status metadata.
- *
- * @param testName The name of the test.
- * @param timestamp The timestamp indicating the most recent test run event in the test state.
- * @param coveredLineCount The number of lines covered.
- * @param totalLineCount The total number of lines.
- */
- public TestCoverageStatusEntity(
- String testName,
- long timestamp,
- long coveredLineCount,
- long totalLineCount,
- long deviceInfoId) {
- this.testName = testName;
- this.updatedTimestamp = timestamp;
- this.coveredLineCount = coveredLineCount;
- this.totalLineCount = totalLineCount;
- this.deviceInfoId = deviceInfoId;
- }
-
- /** find TestCoverageStatus entity by ID */
- public static TestCoverageStatusEntity findById(String testName) {
- return ofy().load().type(TestCoverageStatusEntity.class).id(testName).now();
- }
-
- /** Get all TestCoverageStatusEntity List */
- public static Map<String, TestCoverageStatusEntity> getTestCoverageStatusMap() {
- List<TestCoverageStatusEntity> testCoverageStatusEntityList = getAllTestCoverage();
-
- Map<String, TestCoverageStatusEntity> testCoverageStatusMap =
- testCoverageStatusEntityList.stream()
- .collect(Collectors.toMap(t -> t.getTestName(), t -> t));
- return testCoverageStatusMap;
- }
-
- /** Get all DeviceInfoEntity List by TestCoverageStatusEntities' key list */
- public static List<Key<DeviceInfoEntity>> getDeviceInfoEntityKeyList(
- List<TestCoverageStatusEntity> testCoverageStatusEntityList) {
- return testCoverageStatusEntityList
- .stream()
- .map(
- testCoverageStatusEntity -> {
- com.googlecode.objectify.Key testKey =
- com.googlecode.objectify.Key.create(
- TestEntity.class,
- testCoverageStatusEntity.getTestName());
- com.googlecode.objectify.Key testRunKey =
- com.googlecode.objectify.Key.create(
- testKey,
- TestRunEntity.class,
- testCoverageStatusEntity.getUpdatedTimestamp());
- return com.googlecode.objectify.Key.create(
- testRunKey,
- DeviceInfoEntity.class,
- testCoverageStatusEntity.getDeviceInfoId());
- })
- .collect(Collectors.toList());
- }
-
- /** Get all TestCoverageStatusEntity List */
- public static List<TestCoverageStatusEntity> getAllTestCoverage() {
- return ofy().load().type(TestCoverageStatusEntity.class).list();
- }
-
- /** Get all TestCoverageStatusEntities' Branch List */
- public static Set<String> getBranchSet(
- List<TestCoverageStatusEntity> testCoverageStatusEntityList) {
- List<com.googlecode.objectify.Key<DeviceInfoEntity>> deviceInfoEntityKeyList =
- getDeviceInfoEntityKeyList(testCoverageStatusEntityList);
-
- Collection<DeviceInfoEntity> deviceInfoEntityList =
- ofy().load().keys(() -> deviceInfoEntityKeyList.iterator()).values();
-
- Set<String> branchSet =
- deviceInfoEntityList
- .stream()
- .map(deviceInfoEntity -> deviceInfoEntity.getBranch())
- .collect(Collectors.toSet());
- return branchSet;
- }
-
- /** Get all TestCoverageStatusEntities' Device List */
- public static Set<String> getDeviceSet(
- List<TestCoverageStatusEntity> testCoverageStatusEntityList) {
- List<com.googlecode.objectify.Key<DeviceInfoEntity>> deviceInfoEntityKeyList =
- getDeviceInfoEntityKeyList(testCoverageStatusEntityList);
-
- Collection<DeviceInfoEntity> deviceInfoEntityList =
- ofy().load().keys(() -> deviceInfoEntityKeyList.iterator()).values();
-
- Set<String> deviceSet =
- deviceInfoEntityList
- .stream()
- .map(deviceInfoEntity -> deviceInfoEntity.getBuildFlavor())
- .collect(Collectors.toSet());
- return deviceSet;
- }
-
- /** TestRunEntity function to get the related TestRunEntity from id value */
- public TestRunEntity getTestRunEntity() {
- com.googlecode.objectify.Key testKey =
- com.googlecode.objectify.Key.create(TestEntity.class, this.testName);
- return ofy().load()
- .type(TestRunEntity.class)
- .parent(testKey)
- .id(this.updatedTimestamp)
- .now();
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<TestCoverageStatusEntity> save() {
- this.updatedDate = new Date();
- return ofy().save().entity(this).now();
- }
-
- public Entity toEntity() {
- Entity testEntity = new Entity(KIND, this.testName);
- testEntity.setProperty(UPDATED_TIMESTAMP, this.updatedTimestamp);
- testEntity.setProperty(COVERED_LINE_COUNT, this.coveredLineCount);
- testEntity.setProperty(TOTAL_LINE_COUNT, this.totalLineCount);
- return testEntity;
- }
-
- /**
- * Convert an Entity object to a TestCoverageStatusEntity.
- *
- * @param e The entity to process.
- * @return TestCoverageStatusEntity object with the properties from e processed, or null if
- * incompatible.
- */
- @SuppressWarnings("unchecked")
- public static TestCoverageStatusEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND)
- || e.getKey().getName() == null
- || !e.hasProperty(UPDATED_TIMESTAMP)
- || !e.hasProperty(COVERED_LINE_COUNT)
- || !e.hasProperty(TOTAL_LINE_COUNT)
- || !e.hasProperty(DEVICE_INFO_ID)) {
- logger.log(Level.WARNING, "Missing test attributes in entity: " + e.toString());
- return null;
- }
- String testName = e.getKey().getName();
- long timestamp = 0;
- long coveredLineCount = -1;
- long totalLineCount = -1;
- long deviceInfoId = 0;
- try {
- timestamp = (long) e.getProperty(UPDATED_TIMESTAMP);
- coveredLineCount = (Long) e.getProperty(COVERED_LINE_COUNT);
- totalLineCount = (Long) e.getProperty(TOTAL_LINE_COUNT);
- deviceInfoId = (Long) e.getProperty(DEVICE_INFO_ID);
- } catch (ClassCastException exception) {
- // Invalid contents or null values
- logger.log(Level.WARNING, "Error parsing test entity.", exception);
- return null;
- }
- return new TestCoverageStatusEntity(
- testName, timestamp, coveredLineCount, totalLineCount, deviceInfoId);
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestEntity.java b/src/main/java/com/android/vts/entity/TestEntity.java
deleted file mode 100644
index 4df7fb0..0000000
--- a/src/main/java/com/android/vts/entity/TestEntity.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Index;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-import lombok.Data;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-@Entity(name = "Test")
-@Cache
-@Data
-@NoArgsConstructor
-/** Entity describing test metadata. */
-public class TestEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(TestEntity.class.getName());
-
- public static final String KIND = "Test";
- public static final String HAS_PROFILING_DATA = "hasProfilingData";
-
- @Id
- @Getter
- @Setter
- private String testName;
-
- @Index
- @Getter
- @Setter
- private boolean hasProfilingData;
-
- /**
- * Create a TestEntity object.
- *
- * @param testName The name of the test.
- * @param hasProfilingData True if the test includes profiling data.
- */
- public TestEntity(String testName, boolean hasProfilingData) {
- this.testName = testName;
- this.hasProfilingData = hasProfilingData;
- }
-
- /**
- * Create a TestEntity object.
- *
- * @param testName The name of the test.
- */
- public TestEntity(String testName) {
- this(testName, false);
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<TestEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public com.google.appengine.api.datastore.Entity toEntity() {
- com.google.appengine.api.datastore.Entity testEntity = new com.google.appengine.api.datastore.Entity(this.getOldKey());
- testEntity.setProperty(HAS_PROFILING_DATA, this.hasProfilingData);
- return testEntity;
- }
-
- /**
- * Get objectify TestRun Entity's key.
- *
- * @param startTimestamp test start timestamp
- */
- public com.googlecode.objectify.Key getTestRunKey(long startTimestamp) {
- com.googlecode.objectify.Key testKey =
- com.googlecode.objectify.Key.create(TestEntity.class, this.getTestName());
- com.googlecode.objectify.Key testRunKey =
- com.googlecode.objectify.Key.create(testKey, TestRunEntity.class, startTimestamp);
- return testRunKey;
- }
-
- /**
- * Get key info from appengine based library.
- */
- public Key getOldKey() {
- return KeyFactory.createKey(KIND, testName);
- }
-
- public static List<String> getAllTestNames() {
- List<TestEntity> testEntityList = getAllTest();
-
- List<String> allTestNames = testEntityList.stream()
- .map(te -> te.getTestName()).collect(Collectors.toList());
- return allTestNames;
- }
-
- public static List<TestEntity> getAllTest() {
- return ofy().load().type(TestEntity.class).list();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null || !TestEntity.class.isAssignableFrom(obj.getClass())) {
- return false;
- }
- TestEntity test2 = (TestEntity) obj;
- return (
- this.testName.equals(test2.testName) &&
- this.hasProfilingData == test2.hasProfilingData);
- }
-
- /**
- * Convert an Entity object to a TestEntity.
- *
- * @param e The entity to process.
- * @return TestEntity object with the properties from e processed, or null if incompatible.
- */
- @SuppressWarnings("unchecked")
- public static TestEntity fromEntity(com.google.appengine.api.datastore.Entity e) {
- if (!e.getKind().equals(KIND) || e.getKey().getName() == null) {
- logger.log(Level.WARNING, "Missing test attributes in entity: " + e.toString());
- return null;
- }
- String testName = e.getKey().getName();
- boolean hasProfilingData = false;
- if (e.hasProperty(HAS_PROFILING_DATA)) {
- hasProfilingData = (boolean) e.getProperty(HAS_PROFILING_DATA);
- }
- return new TestEntity(testName, hasProfilingData);
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestPlanEntity.java b/src/main/java/com/android/vts/entity/TestPlanEntity.java
deleted file mode 100644
index 590db46..0000000
--- a/src/main/java/com/android/vts/entity/TestPlanEntity.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-import com.google.appengine.api.datastore.Entity;
-import com.googlecode.objectify.Key;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@com.googlecode.objectify.annotation.Entity(name = "TestPlan")
-@Cache
-@Data
-@NoArgsConstructor
-/** Entity describing test plan metadata. */
-public class TestPlanEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(TestPlanEntity.class.getName());
-
- public static final String KIND = "TestPlan";
-
- // Property keys
- public static final String TEST_PLAN_NAME = "testPlanName";
-
- @Id
- public String testPlanName;
-
- /**
- * Create a TestPlanEntity object.
- *
- * @param testPlanName The name of the test plan.
- */
- public TestPlanEntity(String testPlanName) {
- this.testPlanName = testPlanName;
- }
-
- public Entity toEntity() {
- Entity planEntity = new Entity(KIND, this.testPlanName);
- return planEntity;
- }
-
- public Key getKey() {
- Key key = Key.create(TestPlanEntity.class, this.testPlanName);
- return key;
- }
-
- /**
- * Convert an Entity object to a TestEntity.
- *
- * @param e The entity to process.
- * @return TestEntity object with the properties from e processed, or null if incompatible.
- */
- @SuppressWarnings("unchecked")
- public static TestPlanEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND) || e.getKey().getName() == null
- || !e.hasProperty(TEST_PLAN_NAME)) {
- logger.log(Level.WARNING, "Missing test plan attributes in entity: " + e.toString());
- return null;
- }
- String testPlanName = e.getKey().getName();
- return new TestPlanEntity(testPlanName);
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<TestPlanEntity> save() {
- return ofy().save().entity(this).now();
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestPlanRunEntity.java b/src/main/java/com/android/vts/entity/TestPlanRunEntity.java
deleted file mode 100644
index de2e505..0000000
--- a/src/main/java/com/android/vts/entity/TestPlanRunEntity.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.google.appengine.api.taskqueue.Queue;
-import com.google.appengine.api.taskqueue.QueueFactory;
-import com.google.appengine.api.taskqueue.TaskOptions;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Parent;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-@com.googlecode.objectify.annotation.Entity(name = "TestPlanRun")
-@Cache
-@Data
-@NoArgsConstructor
-/** Entity describing test plan run information. */
-public class TestPlanRunEntity implements DashboardEntity {
-
- protected static final Logger logger = Logger.getLogger(TestPlanRunEntity.class.getName());
-
- private final String QUEUE_NAME = "coverageApiQueue";
-
- public static final String KIND = "TestPlanRun";
-
- private static final String COVERAGE_API_URL = "/api/coverage/api/sum";
-
- // Property keys
- public static final String TEST_PLAN_NAME = "testPlanName";
- public static final String TYPE = "type";
- public static final String START_TIMESTAMP = "startTimestamp";
- public static final String END_TIMESTAMP = "endTimestamp";
- public static final String TEST_BUILD_ID = "testBuildId";
- public static final String PASS_COUNT = "passCount";
- public static final String FAIL_COUNT = "failCount";
- public static final String TOTAL_API_COUNT = "totalApiCount";
- public static final String TOTAL_COVERED_API_COUNT = "coveredApiCount";
- public static final String TEST_RUNS = "testRuns";
-
- @Ignore public Key key;
-
- @Id private Long id;
-
- @Parent private com.googlecode.objectify.Key<TestPlanEntity> parent;
-
- @Index private String testPlanName;
-
- @Index private long type;
-
- @Index private long startTimestamp;
-
- @Index private long endTimestamp;
-
- @Index private String testBuildId;
-
- @Index private long passCount;
-
- @Index private long failCount;
-
- @Index private long totalApiCount;
-
- @Index private long coveredApiCount;
-
- @Ignore private List<Key> oldTestRuns;
-
- private List<com.googlecode.objectify.Key<TestRunEntity>> testRuns;
-
- /** When this record was created or updated */
- @Index Date updated;
-
- /**
- * Create a TestPlanRunEntity object describing a test plan run.
- *
- * @param testPlanKey The key for the parent entity in the database.
- * @param type The test run type (e.g. presubmit, postsubmit, other)
- * @param startTimestamp The time in microseconds when the test plan run started.
- * @param endTimestamp The time in microseconds when the test plan run ended.
- * @param testBuildId The build ID of the VTS test build.
- * @param passCount The number of passing test cases in the run.
- * @param failCount The number of failing test cases in the run.
- * @param testRuns A list of keys to the TestRunEntity objects for the plan run run.
- */
- public TestPlanRunEntity(
- Key testPlanKey,
- String testPlanName,
- long type,
- long startTimestamp,
- long endTimestamp,
- String testBuildId,
- long passCount,
- long failCount,
- long totalApiCount,
- long coveredApiCount,
- List<Key> testRuns) {
- this.id = startTimestamp;
- this.key = KeyFactory.createKey(testPlanKey, KIND, startTimestamp);
- this.testPlanName = testPlanName;
- this.type = type;
- this.startTimestamp = startTimestamp;
- this.endTimestamp = endTimestamp;
- this.testBuildId = testBuildId;
- this.passCount = passCount;
- this.failCount = failCount;
- this.totalApiCount = totalApiCount;
- this.coveredApiCount = coveredApiCount;
- this.oldTestRuns = testRuns;
- this.testRuns =
- testRuns.stream()
- .map(
- testRun -> {
- com.googlecode.objectify.Key testParentKey =
- com.googlecode.objectify.Key.create(
- TestEntity.class,
- testRun.getParent().getName());
- return com.googlecode.objectify.Key.create(
- testParentKey, TestRunEntity.class, testRun.getId());
- })
- .collect(Collectors.toList());
- }
-
- /**
- * Create a TestPlanRunEntity object describing a test plan run.
- *
- * @param testPlanKey The key for the parent entity in the database.
- * @param type The test run type (e.g. presubmit, postsubmit, other)
- * @param startTimestamp The time in microseconds when the test plan run started.
- * @param endTimestamp The time in microseconds when the test plan run ended.
- * @param testBuildId The build ID of the VTS test build.
- * @param passCount The number of passing test cases in the run.
- * @param failCount The number of failing test cases in the run.
- * @param testRuns A list of keys to the TestRunEntity objects for the plan run run.
- */
- public TestPlanRunEntity(
- com.googlecode.objectify.Key<TestPlanEntity> testPlanKey,
- String testPlanName,
- long type,
- long startTimestamp,
- long endTimestamp,
- String testBuildId,
- long passCount,
- long failCount,
- long totalApiCount,
- long coveredApiCount,
- List<com.googlecode.objectify.Key<TestRunEntity>> testRuns) {
- this.id = startTimestamp;
- this.parent = testPlanKey;
- this.testPlanName = testPlanName;
- this.type = type;
- this.startTimestamp = startTimestamp;
- this.endTimestamp = endTimestamp;
- this.testBuildId = testBuildId;
- this.passCount = passCount;
- this.failCount = failCount;
- this.totalApiCount = totalApiCount;
- this.coveredApiCount = coveredApiCount;
- this.testRuns = testRuns;
- }
-
- public Entity toEntity() {
- Entity planRun = new Entity(this.key);
- planRun.setProperty(TEST_PLAN_NAME, this.testPlanName);
- planRun.setProperty(TYPE, this.type);
- planRun.setProperty(START_TIMESTAMP, this.startTimestamp);
- planRun.setProperty(END_TIMESTAMP, this.endTimestamp);
- planRun.setProperty(TEST_BUILD_ID, this.testBuildId.toLowerCase());
- planRun.setProperty(PASS_COUNT, this.passCount);
- planRun.setProperty(FAIL_COUNT, this.failCount);
- if (this.oldTestRuns != null && this.oldTestRuns.size() > 0) {
- planRun.setUnindexedProperty(TEST_RUNS, this.oldTestRuns);
- }
- return planRun;
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<TestPlanRunEntity> save() {
- this.updated = new Date();
- return ofy().save().entity(this).now();
- }
-
- /** Get UrlSafeKey from this class */
- public String getUrlSafeKey() {
- return this.getOfyKey().toUrlSafe();
- }
-
- /** Add a task to calculate the total number of coverage API */
- public void addCoverageApiTask() {
- if (Objects.isNull(this.testRuns)) {
- logger.log(Level.WARNING, "testRuns is null so adding task to the queue is skipped!");
- } else {
- Queue queue = QueueFactory.getQueue(QUEUE_NAME);
- queue.add(
- TaskOptions.Builder.withUrl(COVERAGE_API_URL)
- .param("urlSafeKey", this.getUrlSafeKey())
- .method(TaskOptions.Method.POST));
- }
- }
-
- /**
- * Get key info from appengine based library.
- *
- * @param parentKey parent key.
- */
- public Key getOldKey(Key parentKey) {
- return KeyFactory.createKey(parentKey, KIND, startTimestamp);
- }
-
- /** Get key info from objecitfy library. */
- public com.googlecode.objectify.Key getOfyKey() {
- return com.googlecode.objectify.Key.create(
- this.parent, TestPlanRunEntity.class, this.startTimestamp);
- }
-
- /**
- * Convert an Entity object to a TestPlanRunEntity.
- *
- * @param e The entity to process.
- * @return TestPlanRunEntity object with the properties from e processed, or null if
- * incompatible.
- */
- @SuppressWarnings("unchecked")
- public static TestPlanRunEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND)
- || !e.hasProperty(TEST_PLAN_NAME)
- || !e.hasProperty(TYPE)
- || !e.hasProperty(START_TIMESTAMP)
- || !e.hasProperty(END_TIMESTAMP)
- || !e.hasProperty(TEST_BUILD_ID)
- || !e.hasProperty(PASS_COUNT)
- || !e.hasProperty(FAIL_COUNT)
- || !e.hasProperty(TEST_RUNS)) {
- logger.log(Level.WARNING, "Missing test run attributes in entity: " + e.toString());
- return null;
- }
- try {
- String testPlanName = (String) e.getProperty(TEST_PLAN_NAME);
- long type = (long) e.getProperty(TYPE);
- long startTimestamp = (long) e.getProperty(START_TIMESTAMP);
- long endTimestamp = (long) e.getProperty(END_TIMESTAMP);
- String testBuildId = (String) e.getProperty(TEST_BUILD_ID);
- long passCount = (long) e.getProperty(PASS_COUNT);
- long failCount = (long) e.getProperty(FAIL_COUNT);
-
- long totalApiCount =
- e.hasProperty(TOTAL_API_COUNT) ? (long) e.getProperty(TOTAL_API_COUNT) : 0L;
- long coveredApiCount =
- e.hasProperty(TOTAL_COVERED_API_COUNT)
- ? (long) e.getProperty(TOTAL_COVERED_API_COUNT)
- : 0L;
- List<Key> oldTestRuns = (List<Key>) e.getProperty(TEST_RUNS);
- return new TestPlanRunEntity(
- e.getKey().getParent(),
- testPlanName,
- type,
- startTimestamp,
- endTimestamp,
- testBuildId,
- passCount,
- failCount,
- totalApiCount,
- coveredApiCount,
- oldTestRuns);
- } catch (ClassCastException exception) {
- // Invalid cast
- logger.log(Level.WARNING, "Error parsing test plan run entity.", exception);
- }
- return null;
- }
-
- public JsonObject toJson() {
- JsonObject json = new JsonObject();
- json.add(TEST_PLAN_NAME, new JsonPrimitive(this.testPlanName));
- json.add(TEST_BUILD_ID, new JsonPrimitive(this.testBuildId));
- json.add(PASS_COUNT, new JsonPrimitive(this.passCount));
- json.add(FAIL_COUNT, new JsonPrimitive(this.failCount));
- json.add(START_TIMESTAMP, new JsonPrimitive(this.startTimestamp));
- json.add(END_TIMESTAMP, new JsonPrimitive(this.endTimestamp));
- return json;
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestRunEntity.java b/src/main/java/com/android/vts/entity/TestRunEntity.java
deleted file mode 100644
index 0d5f1ec..0000000
--- a/src/main/java/com/android/vts/entity/TestRunEntity.java
+++ /dev/null
@@ -1,497 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-import com.android.vts.util.TimeUtil;
-import com.android.vts.util.UrlUtil;
-import com.android.vts.util.UrlUtil.LinkDisplay;
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.datastore.KeyFactory;
-import com.google.gson.Gson;
-import com.google.gson.JsonArray;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonPrimitive;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.OnLoad;
-import com.googlecode.objectify.annotation.Parent;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.function.Supplier;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.stream.Stream;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import org.apache.commons.lang3.math.NumberUtils;
-
-@com.googlecode.objectify.annotation.Entity(name = "TestRun")
-@Cache
-@NoArgsConstructor
-/** Entity describing test run information. */
-public class TestRunEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(TestRunEntity.class.getName());
-
- /** Enum for classifying test run types. */
- public enum TestRunType {
- OTHER(0),
- PRESUBMIT(1),
- POSTSUBMIT(2);
-
- private final int value;
-
- private TestRunType(int value) {
- this.value = value;
- }
-
- /**
- * Get the ordinal representation of the type.
- *
- * @return The value associated with the test run type.
- */
- public int getNumber() {
- return value;
- }
-
- /**
- * Convert an ordinal value to a TestRunType.
- *
- * @param value The orginal value to parse.
- * @return a TestRunType value.
- */
- public static TestRunType fromNumber(int value) {
- if (value == 1) {
- return TestRunType.PRESUBMIT;
- } else if (value == 2) {
- return TestRunType.POSTSUBMIT;
- } else {
- return TestRunType.OTHER;
- }
- }
-
- /**
- * Determine the test run type based on the build ID.
- *
- * <p>Postsubmit runs are expected to have integer build IDs, while presubmit runs are
- * integers prefixed by the character P. All other runs (e.g. local builds) are classified
- * as OTHER.
- *
- * @param buildId The build ID.
- * @return the TestRunType.
- */
- public static TestRunType fromBuildId(String buildId) {
- if (buildId.toLowerCase().startsWith("p")) {
- if (NumberUtils.isParsable(buildId.substring(1))) {
- return TestRunType.PRESUBMIT;
- } else {
- return TestRunType.OTHER;
- }
- } else if (NumberUtils.isParsable(buildId)) {
- return TestRunType.POSTSUBMIT;
- } else {
- return TestRunType.OTHER;
- }
- }
- }
-
- public static final String KIND = "TestRun";
-
- // Property keys
- public static final String TEST_NAME = "testName";
- public static final String TYPE = "type";
- public static final String START_TIMESTAMP = "startTimestamp";
- public static final String END_TIMESTAMP = "endTimestamp";
- public static final String TEST_BUILD_ID = "testBuildId";
- public static final String HOST_NAME = "hostName";
- public static final String PASS_COUNT = "passCount";
- public static final String FAIL_COUNT = "failCount";
- public static final String HAS_CODE_COVERAGE = "hasCodeCoverage";
- public static final String HAS_COVERAGE = "hasCoverage";
- public static final String TEST_CASE_IDS = "testCaseIds";
- public static final String LOG_LINKS = "logLinks";
- public static final String API_COVERAGE_KEY_LIST = "apiCoverageKeyList";
- public static final String TOTAL_API_COUNT = "totalApiCount";
- public static final String COVERED_API_COUNT = "coveredApiCount";
-
- @Ignore private Key key;
-
- @Id @Getter @Setter private Long id;
-
- @Parent @Getter @Setter private com.googlecode.objectify.Key<?> testRunParent;
-
- @Index @Getter @Setter private long type;
-
- @Index @Getter @Setter private long startTimestamp;
-
- @Index @Getter @Setter private long endTimestamp;
-
- @Index @Getter @Setter private String testBuildId;
-
- @Index @Getter @Setter private String testName;
-
- @Index @Getter @Setter private String hostName;
-
- @Index @Getter @Setter private long passCount;
-
- @Index @Getter @Setter private long failCount;
-
- @Index private boolean hasCoverage;
-
- @Index @Getter @Setter private boolean hasCodeCoverage;
-
- @Ignore private com.googlecode.objectify.Key<CodeCoverageEntity> codeCoverageEntityKey;
-
- @Index @Getter @Setter private long coveredLineCount;
-
- @Index @Getter @Setter private long totalLineCount;
-
- @Getter @Setter private List<Long> testCaseIds;
-
- @Getter @Setter private List<String> logLinks;
-
- /**
- * Create a TestRunEntity object describing a test run.
- *
- * @param parentKey The key to the parent TestEntity.
- * @param type The test run type (e.g. presubmit, postsubmit, other)
- * @param startTimestamp The time in microseconds when the test run started.
- * @param endTimestamp The time in microseconds when the test run ended.
- * @param testBuildId The build ID of the VTS test build.
- * @param hostName The name of host machine.
- * @param passCount The number of passing test cases in the run.
- * @param failCount The number of failing test cases in the run.
- */
- public TestRunEntity(
- Key parentKey,
- long type,
- long startTimestamp,
- long endTimestamp,
- String testBuildId,
- String hostName,
- long passCount,
- long failCount,
- boolean hasCodeCoverage,
- List<Long> testCaseIds,
- List<String> logLinks) {
- this.id = startTimestamp;
- this.key = KeyFactory.createKey(parentKey, KIND, startTimestamp);
- this.type = type;
- this.startTimestamp = startTimestamp;
- this.endTimestamp = endTimestamp;
- this.testBuildId = testBuildId;
- this.hostName = hostName;
- this.passCount = passCount;
- this.failCount = failCount;
- this.hasCodeCoverage = hasCodeCoverage;
- this.testName = parentKey.getName();
- this.testCaseIds = testCaseIds;
- this.logLinks = logLinks;
-
- this.testRunParent = com.googlecode.objectify.Key.create(TestEntity.class, testName);
- this.codeCoverageEntityKey = getCodeCoverageEntityKey();
- }
-
- /**
- * Called after the POJO is populated with data through objecitfy library
- */
- @OnLoad
- private void onLoad() {
- if (Objects.isNull(this.hasCodeCoverage)) {
- this.hasCodeCoverage = this.hasCoverage;
- this.save();
- }
- }
-
- public Entity toEntity() {
- Entity testRunEntity = new Entity(this.key);
- testRunEntity.setProperty(TEST_NAME, this.testName);
- testRunEntity.setProperty(TYPE, this.type);
- testRunEntity.setProperty(START_TIMESTAMP, this.startTimestamp);
- testRunEntity.setUnindexedProperty(END_TIMESTAMP, this.endTimestamp);
- testRunEntity.setProperty(TEST_BUILD_ID, this.testBuildId.toLowerCase());
- testRunEntity.setProperty(HOST_NAME, this.hostName.toLowerCase());
- testRunEntity.setProperty(PASS_COUNT, this.passCount);
- testRunEntity.setProperty(FAIL_COUNT, this.failCount);
- testRunEntity.setProperty(HAS_CODE_COVERAGE, this.hasCodeCoverage);
- testRunEntity.setUnindexedProperty(TEST_CASE_IDS, this.testCaseIds);
- if (this.logLinks != null && this.logLinks.size() > 0) {
- testRunEntity.setUnindexedProperty(LOG_LINKS, this.logLinks);
- }
- return testRunEntity;
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<TestRunEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- /**
- * Get key info from appengine based library.
- */
- public Key getKey() {
- Key parentKey = KeyFactory.createKey(TestEntity.KIND, testName);
- return KeyFactory.createKey(parentKey, KIND, startTimestamp);
- }
-
- /** Getter hasCodeCoverage value */
- public boolean getHasCodeCoverage() {
- return this.hasCodeCoverage;
- }
-
- /** Getter DateTime string from startTimestamp */
- public String getStartDateTime() {
- return TimeUtil.getDateTimeString(this.startTimestamp);
- }
-
- /** Getter DateTime string from startTimestamp */
- public String getEndDateTime() {
- return TimeUtil.getDateTimeString(this.endTimestamp);
- }
-
- /** find TestRun entity by ID and test name */
- public static TestRunEntity getByTestNameId(String testName, long id) {
- com.googlecode.objectify.Key testKey =
- com.googlecode.objectify.Key.create(TestEntity.class, testName);
- return ofy().load().type(TestRunEntity.class).parent(testKey).id(id).now();
- }
-
- /** Get CodeCoverageEntity Key to generate Key by combining key info */
- private com.googlecode.objectify.Key getCodeCoverageEntityKey() {
- com.googlecode.objectify.Key testRunKey = this.getOfyKey();
- return com.googlecode.objectify.Key.create(
- testRunKey, CodeCoverageEntity.class, this.startTimestamp);
- }
-
- /** Get ApiCoverageEntity Key from the parent key */
- public com.googlecode.objectify.Key getOfyKey() {
- com.googlecode.objectify.Key testKey =
- com.googlecode.objectify.Key.create(
- TestEntity.class, this.testName);
- com.googlecode.objectify.Key testRunKey =
- com.googlecode.objectify.Key.create(
- testKey, TestRunEntity.class, this.startTimestamp);
- return testRunKey;
- }
-
- /** Get ApiCoverageEntity from key info */
- public Optional<List<ApiCoverageEntity>> getApiCoverageEntityList() {
- com.googlecode.objectify.Key testRunKey = this.getOfyKey();
- List<ApiCoverageEntity> apiCoverageEntityList =
- ofy().load().type(ApiCoverageEntity.class).ancestor(testRunKey).list();
- return Optional.ofNullable(apiCoverageEntityList);
- }
-
- /**
- * Get CodeCoverageEntity instance from codeCoverageEntityKey value.
- */
- public CodeCoverageEntity getCodeCoverageEntity() {
- if (this.hasCodeCoverage) {
- CodeCoverageEntity codeCoverageEntity =
- ofy().load()
- .type(CodeCoverageEntity.class)
- .filterKey(this.codeCoverageEntityKey)
- .first()
- .now();
- if (Objects.isNull(codeCoverageEntity)) {
- codeCoverageEntity =
- new CodeCoverageEntity(
- this.getKey(), coveredLineCount, totalLineCount);
- codeCoverageEntity.save();
- return codeCoverageEntity;
- } else {
- return codeCoverageEntity;
- }
- } else {
- logger.log(
- Level.WARNING,
- "The hasCodeCoverage value is false. Please check the code coverage entity key");
- return null;
- }
- }
-
- /**
- * Convert an Entity object to a TestRunEntity.
- *
- * @param e The entity to process.
- * @return TestRunEntity object with the properties from e processed, or null if incompatible.
- */
- @SuppressWarnings("unchecked")
- public static TestRunEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND)
- || !e.hasProperty(TYPE)
- || !e.hasProperty(START_TIMESTAMP)
- || !e.hasProperty(END_TIMESTAMP)
- || !e.hasProperty(TEST_BUILD_ID)
- || !e.hasProperty(HOST_NAME)
- || !e.hasProperty(PASS_COUNT)
- || !e.hasProperty(FAIL_COUNT)) {
- logger.log(Level.WARNING, "Missing test run attributes in entity: " + e.toString());
- return null;
- }
- try {
- long type = (long) e.getProperty(TYPE);
- long startTimestamp = (long) e.getProperty(START_TIMESTAMP);
- long endTimestamp = (long) e.getProperty(END_TIMESTAMP);
- String testBuildId = (String) e.getProperty(TEST_BUILD_ID);
- String hostName = (String) e.getProperty(HOST_NAME);
- long passCount = (long) e.getProperty(PASS_COUNT);
- long failCount = (long) e.getProperty(FAIL_COUNT);
- boolean hasCodeCoverage = false;
- if (e.hasProperty(HAS_CODE_COVERAGE)) {
- hasCodeCoverage = (boolean) e.getProperty(HAS_CODE_COVERAGE);
- } else {
- hasCodeCoverage = (boolean) e.getProperty(HAS_COVERAGE);
- }
- List<Long> testCaseIds = (List<Long>) e.getProperty(TEST_CASE_IDS);
- if (Objects.isNull(testCaseIds)) {
- testCaseIds = new ArrayList<>();
- }
- List<String> links = new ArrayList<>();
- if (e.hasProperty(LOG_LINKS)) {
- links = (List<String>) e.getProperty(LOG_LINKS);
- }
- return new TestRunEntity(
- e.getKey().getParent(),
- type,
- startTimestamp,
- endTimestamp,
- testBuildId,
- hostName,
- passCount,
- failCount,
- hasCodeCoverage,
- testCaseIds,
- links);
- } catch (ClassCastException exception) {
- // Invalid cast
- logger.log(Level.WARNING, "Error parsing test run entity.", exception);
- }
- return null;
- }
-
- /** Get JsonFormat logLinks */
- public JsonElement getJsonLogLinks() {
- List<String> logLinks = this.getLogLinks();
- List<JsonElement> links = new ArrayList<>();
- if (logLinks != null && logLinks.size() > 0) {
- for (String rawUrl : logLinks) {
- UrlUtil.LinkDisplay validatedLink = UrlUtil.processUrl(rawUrl);
- if (validatedLink == null) {
- logger.log(Level.WARNING, "Invalid logging URL : " + rawUrl);
- continue;
- }
- String[] logInfo = new String[] {validatedLink.name, validatedLink.url};
- links.add(new Gson().toJsonTree(logInfo));
- }
- }
- return new Gson().toJsonTree(links);
- }
-
- public JsonObject toJson() {
- Map<String, TestCoverageStatusEntity> testCoverageStatusMap = TestCoverageStatusEntity
- .getTestCoverageStatusMap();
-
- JsonObject json = new JsonObject();
- json.add(TEST_NAME, new JsonPrimitive(this.testName));
- json.add(TEST_BUILD_ID, new JsonPrimitive(this.testBuildId));
- json.add(HOST_NAME, new JsonPrimitive(this.hostName));
- json.add(PASS_COUNT, new JsonPrimitive(this.passCount));
- json.add(FAIL_COUNT, new JsonPrimitive(this.failCount));
- json.add(START_TIMESTAMP, new JsonPrimitive(this.startTimestamp));
- json.add(END_TIMESTAMP, new JsonPrimitive(this.endTimestamp));
-
- // Overwrite the coverage value with newly update value from user decision
- if (this.hasCodeCoverage) {
- CodeCoverageEntity codeCoverageEntity = this.getCodeCoverageEntity();
- if (testCoverageStatusMap.containsKey(this.testName)) {
- TestCoverageStatusEntity testCoverageStatusEntity =
- testCoverageStatusMap.get(this.testName);
-
- if (testCoverageStatusEntity.getUpdatedCoveredLineCount() > 0) {
- codeCoverageEntity.setCoveredLineCount(
- testCoverageStatusEntity.getUpdatedCoveredLineCount());
- }
- if (testCoverageStatusEntity.getUpdatedTotalLineCount() > 0) {
- codeCoverageEntity.setTotalLineCount(
- testCoverageStatusEntity.getUpdatedTotalLineCount());
- }
- }
-
- long totalLineCount = codeCoverageEntity.getTotalLineCount();
- long coveredLineCount = codeCoverageEntity.getCoveredLineCount();
- if (totalLineCount > 0 && coveredLineCount >= 0) {
- json.add(CodeCoverageEntity.COVERED_LINE_COUNT, new JsonPrimitive(coveredLineCount));
- json.add(CodeCoverageEntity.TOTAL_LINE_COUNT, new JsonPrimitive(totalLineCount));
- }
- }
-
- Optional<List<ApiCoverageEntity>> apiCoverageEntityOptionList =
- this.getApiCoverageEntityList();
- if (apiCoverageEntityOptionList.isPresent()) {
- List<ApiCoverageEntity> apiCoverageEntityList = apiCoverageEntityOptionList.get();
- Supplier<Stream<ApiCoverageEntity>> apiCoverageStreamSupplier =
- () -> apiCoverageEntityList.stream();
- int totalHalApi =
- apiCoverageStreamSupplier.get().mapToInt(data -> data.getHalApi().size()).sum();
- if (totalHalApi > 0) {
- int coveredHalApi =
- apiCoverageStreamSupplier
- .get()
- .mapToInt(data -> data.getCoveredHalApi().size())
- .sum();
- JsonArray apiCoverageKeyArray =
- apiCoverageStreamSupplier
- .get()
- .map(data -> new JsonPrimitive(data.getUrlSafeKey()))
- .collect(JsonArray::new, JsonArray::add, JsonArray::addAll);
-
- json.add(API_COVERAGE_KEY_LIST, apiCoverageKeyArray);
- json.add(COVERED_API_COUNT, new JsonPrimitive(coveredHalApi));
- json.add(TOTAL_API_COUNT, new JsonPrimitive(totalHalApi));
- }
- }
-
- List<String> logLinks = this.getLogLinks();
- if (logLinks != null && logLinks.size() > 0) {
- List<JsonElement> links = new ArrayList<>();
- for (String rawUrl : logLinks) {
- LinkDisplay validatedLink = UrlUtil.processUrl(rawUrl);
- if (validatedLink == null) {
- logger.log(Level.WARNING, "Invalid logging URL : " + rawUrl);
- continue;
- }
- String[] logInfo = new String[] {validatedLink.name, validatedLink.url};
- links.add(new Gson().toJsonTree(logInfo));
- }
- if (links.size() > 0) {
- json.add(this.LOG_LINKS, new Gson().toJsonTree(links));
- }
- }
- return json;
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestStatusEntity.java b/src/main/java/com/android/vts/entity/TestStatusEntity.java
deleted file mode 100644
index b703c64..0000000
--- a/src/main/java/com/android/vts/entity/TestStatusEntity.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.android.vts.entity.TestCaseRunEntity.TestCase;
-import com.google.appengine.api.datastore.Entity;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@com.googlecode.objectify.annotation.Entity(name = "TestStatus")
-@Cache
-@Data
-@NoArgsConstructor
-/** Entity describing test status. */
-public class TestStatusEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(TestStatusEntity.class.getName());
-
- public static final String KIND = "TestStatus";
-
- // Property keys
- public static final String PASS_COUNT = "passCount";
- public static final String FAIL_COUNT = "failCount";
- public static final String UPDATED_TIMESTAMP = "updatedTimestamp";
-
- protected static final String FAILING_IDS = "failingTestcaseIds";
- protected static final String FAILING_OFFSETS = "failingTestcaseOffsets";
-
- /** ID field */
- @Id private String testName;
-
- /** Failing Testcase ID List field */
- private List<Long> failingTestcaseIds;
-
- /** Failing Testcase Offsets List field */
- private List<Integer> failingTestcaseOffsets;
-
- /** pass count field */
- @Index private int passCount;
-
- /** fail count field */
- @Index private int failCount;
-
- /** updated timestamp field */
- @Index private long updatedTimestamp;
-
- @Ignore private List<TestCaseReference> failingTestCases;
-
- /** Object representing a reference to a test case. */
- public static class TestCaseReference {
- public final long parentId;
- public final int offset;
-
- /**
- * Create a test case reference.
- *
- * @param parentId The ID of the TestCaseRunEntity containing the test case.
- * @param offset The offset of the test case into the TestCaseRunEntity.
- */
- public TestCaseReference(long parentId, int offset) {
- this.parentId = parentId;
- this.offset = offset;
- }
-
- /**
- * Create a test case reference.
- *
- * @param testCase The TestCase to reference.
- */
- public TestCaseReference(TestCase testCase) {
- this(testCase.parentId, testCase.offset);
- }
- }
-
- /**
- * Create a TestEntity object with status metadata.
- *
- * @param testName The name of the test.
- * @param timestamp The timestamp indicating the most recent test run event in the test state.
- * @param passCount The number of tests passing up to the timestamp specified.
- * @param failCount The number of tests failing up to the timestamp specified.
- * @param failingTestCases The TestCaseReferences of the last observed failing test cases.
- */
- public TestStatusEntity(
- String testName,
- long timestamp,
- int passCount,
- int failCount,
- List<TestCaseReference> failingTestCases) {
- this.testName = testName;
- this.updatedTimestamp = timestamp;
- this.passCount = passCount;
- this.failCount = failCount;
- this.failingTestCases = failingTestCases;
- }
-
- /**
- * Create a TestEntity object without metadata.
- *
- * @param testName The name of the test.
- */
- public TestStatusEntity(String testName) {
- this(testName, 0, -1, -1, new ArrayList<TestCaseReference>());
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<TestStatusEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public Entity toEntity() {
- Entity testEntity = new Entity(KIND, this.testName);
- if (this.updatedTimestamp >= 0 && this.passCount >= 0 && this.failCount >= 0) {
- testEntity.setProperty(UPDATED_TIMESTAMP, this.updatedTimestamp);
- testEntity.setProperty(PASS_COUNT, this.passCount);
- testEntity.setProperty(FAIL_COUNT, this.failCount);
- if (this.failingTestCases.size() > 0) {
- List<Long> failingTestcaseIds = new ArrayList<>();
- List<Integer> failingTestcaseOffsets = new ArrayList<>();
- for (TestCaseReference testCase : this.failingTestCases) {
- failingTestcaseIds.add(testCase.parentId);
- failingTestcaseOffsets.add(testCase.offset);
- }
- testEntity.setUnindexedProperty(FAILING_IDS, failingTestcaseIds);
- testEntity.setUnindexedProperty(FAILING_OFFSETS, failingTestcaseOffsets);
- }
- }
- return testEntity;
- }
-
- /**
- * Convert an Entity object to a TestEntity.
- *
- * @param e The entity to process.
- * @return TestEntity object with the properties from e processed, or null if incompatible.
- */
- @SuppressWarnings("unchecked")
- public static TestStatusEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND) || e.getKey().getName() == null) {
- logger.log(Level.WARNING, "Missing test attributes in entity: " + e.toString());
- return null;
- }
- String testName = e.getKey().getName();
- long timestamp = 0;
- int passCount = -1;
- int failCount = -1;
- List<TestCaseReference> failingTestCases = new ArrayList<>();
- try {
- if (e.hasProperty(UPDATED_TIMESTAMP)) {
- timestamp = (long) e.getProperty(UPDATED_TIMESTAMP);
- }
- if (e.hasProperty(PASS_COUNT)) {
- passCount = ((Long) e.getProperty(PASS_COUNT)).intValue();
- }
- if (e.hasProperty(FAIL_COUNT)) {
- failCount = ((Long) e.getProperty(FAIL_COUNT)).intValue();
- }
- if (e.hasProperty(FAILING_IDS) && e.hasProperty(FAILING_OFFSETS)) {
- List<Long> ids = (List<Long>) e.getProperty(FAILING_IDS);
- List<Long> offsets = (List<Long>) e.getProperty(FAILING_OFFSETS);
- if (ids.size() == offsets.size()) {
- for (int i = 0; i < ids.size(); i++) {
- failingTestCases.add(
- new TestCaseReference(ids.get(i), offsets.get(i).intValue()));
- }
- }
- }
- } catch (ClassCastException exception) {
- // Invalid contents or null values
- logger.log(Level.WARNING, "Error parsing test entity.", exception);
- }
- return new TestStatusEntity(testName, timestamp, passCount, failCount, failingTestCases);
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestSuiteFileEntity.java b/src/main/java/com/android/vts/entity/TestSuiteFileEntity.java
deleted file mode 100644
index c68f2ec..0000000
--- a/src/main/java/com/android/vts/entity/TestSuiteFileEntity.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.googlecode.objectify.Key;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Index;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Date;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-/** Entity Class for Suite Test File Info */
-@Cache
-@Entity
-@EqualsAndHashCode(of = "id")
-@NoArgsConstructor
-public class TestSuiteFileEntity implements DashboardEntity {
-
- /** Test Suite full file path field */
- @Id @Getter @Setter String filePath;
-
- /** Test Suite year field in the filePath */
- @Index @Getter @Setter int year;
-
- /** Test Suite month field in the filePath */
- @Index @Getter @Setter int month;
-
- /** Test Suite day field in the filePath */
- @Index @Getter @Setter int day;
-
- /** Test Suite file name field */
- @Index @Getter @Setter String fileName;
-
- /** When this record was created or updated */
- @Index @Getter Date updated;
-
- /** Construction function for TestSuiteResultEntity Class */
- public TestSuiteFileEntity(String filePath) {
- this.filePath = filePath;
- Path pathInfo = Paths.get(filePath);
- if (pathInfo.getNameCount() > 3) {
- this.year = Integer.valueOf(pathInfo.getName(1).toString());
- this.month = Integer.valueOf(pathInfo.getName(2).toString());
- this.day = Integer.valueOf(pathInfo.getName(3).toString());
- this.fileName = pathInfo.getFileName().toString();
- }
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<TestSuiteFileEntity> save() {
- this.updated = new Date();
- return ofy().save().entity(this).now();
- }
-}
diff --git a/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java b/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java
deleted file mode 100644
index 95ba5c8..0000000
--- a/src/main/java/com/android/vts/entity/TestSuiteResultEntity.java
+++ /dev/null
@@ -1,555 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.google.common.base.Strings;
-import com.googlecode.objectify.Key;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Ignore;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Parent;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.text.StrSubstitutor;
-import org.apache.http.NameValuePair;
-import org.apache.http.ParseException;
-import org.apache.http.client.utils.URIUtils;
-import org.apache.http.client.utils.URLEncodedUtils;
-import org.apache.http.message.BasicNameValuePair;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import java.util.stream.Stream;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-/** Embeded TestType Class for determining testType and search function */
-@Index
-@NoArgsConstructor
-class TestTypeIndex {
-
- /** Embeded TOT field, search field name "testTypeIndex.TOT" */
- private Boolean TOT;
-
- /** Embeded OTA field, search field name "testTypeIndex.OTA" */
- private Boolean OTA;
-
- /** Embeded SIGNED field, search field name "testTypeIndex.SIGNED" */
- private Boolean SIGNED;
-
- /** Maximum bit size */
- @Ignore private int bitSize = 6;
-
- @Ignore
- private List<Integer> totTypeList = this.getTypeList(TestSuiteResultEntity.TestType.TOT.value);
-
- @Ignore
- private List<Integer> otaTypeList = this.getTypeList(TestSuiteResultEntity.TestType.OTA.value);
-
- @Ignore
- private List<Integer> signedTypeList =
- this.getTypeList(TestSuiteResultEntity.TestType.SIGNED.value);
-
- /** Retrieving the list of integers for each category type */
- private List<Integer> getTypeList(int typeNum) {
- return IntStream.range(0, (1 << (bitSize - 1)))
- .filter(i -> (i & typeNum) > 0)
- .boxed()
- .collect(Collectors.toList());
- }
-
- public TestTypeIndex(int testType) {
- if (totTypeList.contains(testType)) {
- this.TOT = true;
- } else {
- this.TOT = false;
- }
-
- if (otaTypeList.contains(testType)) {
- this.OTA = true;
- } else {
- this.OTA = false;
- }
-
- if (signedTypeList.contains(testType)) {
- this.SIGNED = true;
- } else {
- this.SIGNED = false;
- }
- }
-}
-
-/** Entity Class for saving Test Log Summary */
-@Cache
-@Entity
-@EqualsAndHashCode(of = "id")
-@NoArgsConstructor
-public class TestSuiteResultEntity implements DashboardEntity {
-
- private static final Logger logger = Logger.getLogger(TestSuiteResultEntity.class.getName());
-
- /** Bug Tracking System Property class */
- private static Properties bugTrackingSystemProp = new Properties();
-
- /** System Configuration Property class */
- private static Properties systemConfigProp = new Properties();
-
- public enum TestType {
- UNKNOWN(0),
- TOT(1),
- OTA(1 << 1),
- SIGNED(1 << 2),
- PRESUBMIT(1 << 3),
- MANUAL(1 << 5);
-
- public int value;
-
- TestType(int value) {
- this.value = value;
- }
-
- public int value() {
- return value;
- }
- }
-
- @Parent @Getter Key<TestSuiteFileEntity> testSuiteFileEntityKey;
-
- /** Test Suite start time field */
- @Id @Getter @Setter Long startTime;
-
- /** Test Suite end time field */
- @Getter @Setter Long endTime;
-
- /** Test Suite test type field */
- @Getter @Setter int testType;
-
- /** Embeded test type field */
- @Index @Getter @Setter TestTypeIndex testTypeIndex;
-
- /** Test Suite bootup error field */
- @Getter @Setter Boolean bootSuccess;
-
- /** Test Suite result path field */
- @Getter @Setter String resultPath;
-
- /** Test Suite infra log path field */
- @Getter @Setter String infraLogPath;
-
- /** Test Suite device name field */
- @Index @Getter @Setter String deviceName;
-
- /** Test Suite host name field */
- @Index @Getter @Setter String hostName;
-
- /** Test Suite plan field */
- @Index @Getter @Setter String suitePlan;
-
- /** Test Suite version field */
- @Getter @Setter String suiteVersion;
-
- /** Test Suite name field */
- @Getter @Setter String suiteName;
-
- /** Test Suite build number field */
- @Getter @Setter String suiteBuildNumber;
-
- /** Test Suite test finished module count field */
- @Getter @Setter int modulesDone;
-
- /** Test Suite total number of module field */
- @Getter @Setter int modulesTotal;
-
- /** Test Suite branch field */
- @Index @Getter @Setter String branch;
-
- /** Test Suite build target field */
- @Index @Getter @Setter String target;
-
- /** Test Suite build ID field */
- @Index @Getter @Setter String buildId;
-
- /** Test Suite system fingerprint field */
- @Getter @Setter String buildSystemFingerprint;
-
- /** Test Suite vendor fingerprint field */
- @Getter @Setter String buildVendorFingerprint;
-
- /** Test Suite test count for success field */
- @Index @Getter @Setter int passedTestCaseCount;
-
- /** Test Suite test count for failure field */
- @Index @Getter @Setter int failedTestCaseCount;
-
- /** Test Suite ratio of success to find candidate build */
- @Index @Getter @Setter float passedTestCaseRatio;
-
- /** When this record was created or updated */
- @Index @Getter Date updated;
-
- /** Construction function for TestSuiteResultEntity Class */
- public TestSuiteResultEntity(
- Key<TestSuiteFileEntity> testSuiteFileEntityKey,
- Long startTime,
- Long endTime,
- int testType,
- Boolean bootSuccess,
- String resultPath,
- String infraLogPath,
- String hostName,
- String suitePlan,
- String suiteVersion,
- String suiteName,
- String suiteBuildNumber,
- int modulesDone,
- int modulesTotal,
- String branch,
- String target,
- String buildId,
- String buildSystemFingerprint,
- String buildVendorFingerprint,
- int passedTestCaseCount,
- int failedTestCaseCount) {
- this.testSuiteFileEntityKey = testSuiteFileEntityKey;
- this.startTime = startTime;
- this.endTime = endTime;
- this.bootSuccess = bootSuccess;
- this.resultPath = resultPath;
- this.infraLogPath = infraLogPath;
- this.hostName = hostName;
- this.suitePlan = suitePlan;
- this.suiteVersion = suiteVersion;
- this.suiteName = suiteName;
- this.suiteBuildNumber = suiteBuildNumber;
- this.modulesDone = modulesDone;
- this.modulesTotal = modulesTotal;
- this.branch = branch;
- this.target = target;
- this.buildId = buildId;
- this.buildSystemFingerprint = buildSystemFingerprint;
- this.buildVendorFingerprint = buildVendorFingerprint;
- this.passedTestCaseCount = passedTestCaseCount;
- this.failedTestCaseCount = failedTestCaseCount;
-
- BigDecimal totalTestCaseCount = new BigDecimal(passedTestCaseCount + failedTestCaseCount);
- if (totalTestCaseCount.intValue() <= 0) {
- this.passedTestCaseRatio = 0;
- } else {
- BigDecimal passedTestCaseCountDecimal = new BigDecimal(passedTestCaseCount);
- BigDecimal result =
- passedTestCaseCountDecimal.divide(
- totalTestCaseCount, 10, BigDecimal.ROUND_FLOOR);
- this.passedTestCaseRatio = result.floatValue() * 100;
- }
-
- if (!this.buildVendorFingerprint.isEmpty()) {
- this.deviceName = this.getDeviceNameFromVendorFpt();
- }
-
- this.testType = this.getSuiteResultTestType(testType);
- this.testTypeIndex = new TestTypeIndex(this.testType);
- }
-
- /** Saving function for the instance of this class */
- public void save(TestSuiteFileEntity newTestSuiteFileEntity) {
- List<String> checkList =
- Arrays.asList(
- this.hostName,
- this.suitePlan,
- this.suiteName,
- this.suiteBuildNumber,
- this.branch,
- this.target,
- this.buildId);
- boolean isAllTrue = checkList.stream().allMatch(val -> Strings.isNullOrEmpty(val));
-
- if (isAllTrue) {
- logger.log(Level.WARNING, "There is null or empty string among required fields!");
- } else {
- this.updated = new Date();
- ofy().transact(() -> {
- newTestSuiteFileEntity.save();
- ofy().save().entity(this).now();
- });
- }
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<TestSuiteResultEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public static void setPropertyValues(Properties newSystemConfigProp) {
- systemConfigProp = newSystemConfigProp;
- bugTrackingSystemProp = getBugTrackingSystemProp(newSystemConfigProp);
- }
-
- private static Properties getBugTrackingSystemProp(Properties newSystemConfigProp) {
- Properties newBugTrackingSystemProp = new Properties();
- try {
- String bugTrackingSystem = newSystemConfigProp.getProperty("bug.tracking.system");
-
- if (!bugTrackingSystem.isEmpty()) {
- InputStream btsInputStream =
- TestSuiteResultEntity.class
- .getClassLoader()
- .getResourceAsStream(
- "bug_tracking_system/"
- + bugTrackingSystem
- + "/config.properties");
- newBugTrackingSystemProp.load(btsInputStream);
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- return newBugTrackingSystemProp;
- }
- }
-
- public static List<TestSuiteResultEntity> getTestSuitePlans() {
- return ofy().load()
- .type(TestSuiteResultEntity.class)
- .project("suitePlan")
- .distinct(true)
- .list();
- }
-
- public static List<TestSuiteResultEntity> getBranchDistinctList() {
- return ofy().load()
- .type(TestSuiteResultEntity.class)
- .project("branch")
- .distinct(true)
- .list();
- }
-
- public static List<TestSuiteResultEntity> getBuildIdDistinctList() {
- return ofy().load()
- .type(TestSuiteResultEntity.class)
- .project("buildId")
- .distinct(true)
- .list();
- }
-
- public static List<TestSuiteResultEntity> getTargetDistinctList() {
- return ofy().load()
- .type(TestSuiteResultEntity.class)
- .project("target")
- .distinct(true)
- .list();
- }
-
- public static List<TestSuiteResultEntity> getHostNameDistinctList() {
- return ofy().load()
- .type(TestSuiteResultEntity.class)
- .project("hostName")
- .distinct(true)
- .list();
- }
-
- public String getDeviceNameFromVendorFpt() {
- String deviceName =
- Stream.of(this.buildVendorFingerprint.split("/")).skip(1).findFirst().orElse("");
- return deviceName;
- }
-
- public String getScreenResultLogPath() {
- String gcsBucketName = systemConfigProp.getProperty("gcs.bucketName");
- return resultPath.replace("gs://" + gcsBucketName + "/", "");
- }
-
- public String getScreenInfraLogPath() {
- String gcsInfraLogBucketName = systemConfigProp.getProperty("gcs.infraLogBucketName");
- return infraLogPath.replace("gs://" + gcsInfraLogBucketName + "/", "");
- }
-
- private String getNormalizedVersion(String fingerprint) {
- Map<String, Pattern> partternMap =
- new HashMap<String, Pattern>() {
- {
- put(
- "9",
- Pattern.compile(
- "(:9(\\.\\d\\.\\d|\\.\\d|)|:P\\w*/)",
- Pattern.CASE_INSENSITIVE));
- put(
- "8.1",
- Pattern.compile(
- "(:8\\.1\\.\\d\\/|:O\\w+-MR1/)", Pattern.CASE_INSENSITIVE));
- put(
- "8",
- Pattern.compile(
- "(:8\\.0\\.\\d\\/|:O\\w*/)", Pattern.CASE_INSENSITIVE));
- }
- };
-
- for (Map.Entry<String, Pattern> entry : partternMap.entrySet()) {
- Matcher systemMatcher = entry.getValue().matcher(fingerprint);
- if (systemMatcher.find()) {
- return entry.getKey();
- }
- }
- return "unknown-version";
- }
-
- public int getSuiteResultTestType(int testType) {
- if (testType == TestType.UNKNOWN.value()) {
- if (this.getNormalizedVersion(this.buildSystemFingerprint)
- != this.getNormalizedVersion(this.buildVendorFingerprint)) {
- return TestType.OTA.value();
- } else if (this.buildVendorFingerprint.endsWith("release-keys")) {
- return TestType.SIGNED.value();
- } else {
- return TestType.TOT.value();
- }
- } else {
- return testType;
- }
- }
-
- private String getLabInfraIssueDescription() throws IOException {
-
- String bugTrackingSystem = systemConfigProp.getProperty("bug.tracking.system");
-
- String templateName =
- bugTrackingSystemProp.getProperty(
- bugTrackingSystem + ".labInfraIssue.template.name");
-
- InputStream inputStream =
- this.getClass()
- .getClassLoader()
- .getResourceAsStream(
- "bug_tracking_system/" + bugTrackingSystem + "/" + templateName);
-
- String templateDescription = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
-
- Map<String, String> valuesMap = new HashMap<>();
- valuesMap.put("suiteBuildNumber", suiteBuildNumber);
- valuesMap.put("buildId", buildId);
- valuesMap.put("modulesDone", Integer.toString(modulesDone));
- valuesMap.put("modulesTotal", Integer.toString(modulesTotal));
- valuesMap.put("hostName", hostName);
- valuesMap.put("resultPath", resultPath);
- valuesMap.put("buildVendorFingerprint", buildVendorFingerprint);
- valuesMap.put("buildSystemFingerprint", buildSystemFingerprint);
-
- StrSubstitutor sub = new StrSubstitutor(valuesMap);
- String resolvedDescription = sub.replace(templateDescription);
-
- return resolvedDescription;
- }
-
- private String getCrashSecurityDescription() throws IOException {
-
- String bugTrackingSystem = systemConfigProp.getProperty("bug.tracking.system");
-
- String templateName =
- bugTrackingSystemProp.getProperty(
- bugTrackingSystem + ".crashSecurity.template.name");
-
- InputStream inputStream =
- this.getClass()
- .getClassLoader()
- .getResourceAsStream(
- "bug_tracking_system/" + bugTrackingSystem + "/" + templateName);
-
- String templateDescription = IOUtils.toString(inputStream, StandardCharsets.UTF_8.name());
-
- Map<String, String> valuesMap = new HashMap<>();
- valuesMap.put("suiteBuildNumber", suiteBuildNumber);
- valuesMap.put("branch", branch);
- valuesMap.put("target", target);
- valuesMap.put("deviceName", deviceName);
- valuesMap.put("buildId", buildId);
- valuesMap.put("suiteName", suiteName);
- valuesMap.put("suitePlan", suitePlan);
- valuesMap.put("hostName", hostName);
- valuesMap.put("resultPath", resultPath);
-
- StrSubstitutor sub = new StrSubstitutor(valuesMap);
- String resolvedDescription = sub.replace(templateDescription);
-
- return resolvedDescription;
- }
-
- public String getBuganizerLink() throws IOException, ParseException, URISyntaxException {
-
- String bugTrackingSystem = systemConfigProp.getProperty("bug.tracking.system");
-
- List<NameValuePair> qparams = new ArrayList<NameValuePair>();
- if (!this.bootSuccess || (this.passedTestCaseCount == 0 && this.failedTestCaseCount == 0)) {
- qparams.add(
- new BasicNameValuePair(
- "component",
- this.bugTrackingSystemProp.getProperty(
- bugTrackingSystem + ".labInfraIssue.component.id")));
- qparams.add(
- new BasicNameValuePair(
- "template",
- this.bugTrackingSystemProp.getProperty(
- bugTrackingSystem + ".labInfraIssue.template.id")));
- qparams.add(new BasicNameValuePair("description", this.getLabInfraIssueDescription()));
- } else {
- qparams.add(
- new BasicNameValuePair(
- "component",
- this.bugTrackingSystemProp.getProperty(
- bugTrackingSystem + ".crashSecurity.component.id")));
- qparams.add(
- new BasicNameValuePair(
- "template",
- this.bugTrackingSystemProp.getProperty(
- bugTrackingSystem + ".crashSecurity.template.id")));
- qparams.add(new BasicNameValuePair("description", this.getCrashSecurityDescription()));
- }
-
- URI uri =
- URIUtils.createURI(
- this.bugTrackingSystemProp.getProperty(bugTrackingSystem + ".uri.scheme"),
- this.bugTrackingSystemProp.getProperty(bugTrackingSystem + ".uri.host"),
- -1,
- this.bugTrackingSystemProp.getProperty(bugTrackingSystem + ".uri.path"),
- URLEncodedUtils.format(qparams, StandardCharsets.UTF_8.name()),
- null);
- return uri.toString();
- }
-}
diff --git a/src/main/java/com/android/vts/entity/UserEntity.java b/src/main/java/com/android/vts/entity/UserEntity.java
deleted file mode 100644
index 43b5edd..0000000
--- a/src/main/java/com/android/vts/entity/UserEntity.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.googlecode.objectify.Key;
-import com.googlecode.objectify.Ref;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Entity;
-import com.googlecode.objectify.annotation.Id;
-import com.googlecode.objectify.annotation.Index;
-import com.googlecode.objectify.annotation.Load;
-import java.util.ArrayList;
-import java.util.List;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-import java.util.Date;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-/** Entity Class for User */
-@Cache
-@Entity
-@EqualsAndHashCode(of = "email")
-@NoArgsConstructor
-public class UserEntity implements DashboardEntity {
-
- /** User email field */
- @Id @Getter @Setter String email;
-
- /** User name field */
- @Getter @Setter String name;
-
- /** User name field */
- @Getter @Setter String company;
-
- /** User enable or disable field */
- @Index @Getter @Setter Boolean enable;
-
- /** User admin flag field */
- @Index @Getter @Setter Boolean isAdmin;
-
- /** When this record was created or updated */
- @Index @Getter Date updated;
-
- @Load
- @Getter
- List<Ref<RoleEntity>> roles = new ArrayList<>();
-
- /** Constructor function for UserEntity Class */
- public UserEntity(
- String email,
- String name,
- String company,
- String roleName) {
-
- this.email = email;
- this.name = name;
- this.enable = true;
- this.isAdmin = false;
- this.company = company;
- RoleEntity roleEntity = RoleEntity.getRole(roleName);
- this.roles.add(Ref.create(roleEntity));
- }
-
- /** Saving function for the instance of this class */
- @Override
- public Key<UserEntity> save() {
- this.updated = new Date();
- return ofy().save().entity(this).now();
- }
-
- /** Get admin user list by admin email */
- public static UserEntity getAdminUser(String adminEmail) {
- Key key = Key.create(UserEntity.class, adminEmail);
- return ofy().load()
- .type(UserEntity.class)
- .filterKey(key)
- .filter("enable", true)
- .filter("isAdmin", true)
- .first()
- .now();
- }
-
- /** Get all admin user list */
- public static List<UserEntity> getAdminUserList() {
- return ofy().load()
- .type(UserEntity.class)
- .filter("enable", true)
- .filter("isAdmin", true)
- .list();
- }
-
- /** Get normal user list */
- public static List<UserEntity> getUserList() {
- return ofy().load()
- .type(UserEntity.class)
- .filter("enable", true)
- .filter("isAdmin", false)
- .list();
- }
-
- /** Get user by email */
- public static UserEntity getUser(String email) {
- Key key = Key.create(UserEntity.class, email);
- return ofy().load()
- .type(UserEntity.class)
- .filterKey(key)
- .filter("enable", true)
- .first()
- .now();
- }
-}
diff --git a/src/main/java/com/android/vts/entity/UserFavoriteEntity.java b/src/main/java/com/android/vts/entity/UserFavoriteEntity.java
deleted file mode 100644
index 2548042..0000000
--- a/src/main/java/com/android/vts/entity/UserFavoriteEntity.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2017 Google Inc. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you
- * may not use this file except in compliance with the License. You may
- * obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.vts.entity;
-
-import com.google.appengine.api.datastore.Entity;
-import com.google.appengine.api.datastore.Key;
-import com.google.appengine.api.users.User;
-import com.googlecode.objectify.annotation.Cache;
-import com.googlecode.objectify.annotation.Ignore;
-import lombok.EqualsAndHashCode;
-import lombok.Getter;
-import lombok.NoArgsConstructor;
-import lombok.Setter;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static com.googlecode.objectify.ObjectifyService.ofy;
-
-@Cache
-@com.googlecode.objectify.annotation.Entity(name = "UserFavorite")
-@EqualsAndHashCode(of = "email")
-@NoArgsConstructor
-/** Entity describing subscriptions between a user and a test. */
-public class UserFavoriteEntity implements DashboardEntity {
- protected static final Logger logger = Logger.getLogger(UserFavoriteEntity.class.getName());
-
- public static final String KIND = "UserFavorite";
-
- // Property keys
- public static final String USER = "user";
- public static final String TEST_KEY = "testKey";
- public static final String MUTE_NOTIFICATIONS = "muteNotifications";
-
- @Ignore private Key key = null;
-
- @Ignore public User user = null;
-
- @Ignore public Key testKey = null;
-
- @Getter @Setter private com.googlecode.objectify.Key<TestEntity> test;
-
- @Getter @Setter private String userEmail;
-
- @Getter @Setter public boolean muteNotifications;
-
- /**
- * Create a user favorite relationship.
- *
- * @param key The key of the entity in the database.
- * @param user The User object for the subscribing user.
- * @param testKey The key of the TestEntity object describing the test.
- * @param muteNotifications True if the subscriber has muted notifications, false otherwise.
- */
- private UserFavoriteEntity(Key key, User user, Key testKey, boolean muteNotifications) {
- this.key = key;
- this.user = user;
- this.testKey = testKey;
- this.muteNotifications = muteNotifications;
- }
-
- /**
- * Create a user favorite relationship.
- *
- * @param user The User object for the subscribing user.
- * @param testKey The key of the TestEntity object describing the test.
- * @param muteNotifications True if the subscriber has muted notifications, false otherwise.
- */
- public UserFavoriteEntity(User user, Key testKey, boolean muteNotifications) {
- this(null, user, testKey, muteNotifications);
- }
-
- /** Saving function for the instance of this class */
- @Override
- public com.googlecode.objectify.Key<UserFavoriteEntity> save() {
- return ofy().save().entity(this).now();
- }
-
- public Entity toEntity() {
- Entity favoriteEntity;
- if (this.key != null) {
- favoriteEntity = new Entity(key);
- } else {
- favoriteEntity = new Entity(KIND);
- }
- favoriteEntity.setProperty(USER, this.user);
- favoriteEntity.setProperty(TEST_KEY, this.testKey);
- favoriteEntity.setProperty(MUTE_NOTIFICATIONS, this.muteNotifications);
- return favoriteEntity;
- }
-
- /**
- * Convert an Entity object to a UserFavoriteEntity.
- *
- * @param e The entity to process.
- * @return UserFavoriteEntity object with the properties from e, or null if incompatible.
- */
- public static UserFavoriteEntity fromEntity(Entity e) {
- if (!e.getKind().equals(KIND) || !e.hasProperty(USER) || !e.hasProperty(TEST_KEY)) {
- logger.log(
- Level.WARNING, "Missing user favorite attributes in entity: " + e.toString());
- return null;
- }
- try {
- User user = (User) e.getProperty(USER);
- Key testKey = (Key) e.getProperty(TEST_KEY);
- boolean muteNotifications = false;
- if (e.hasProperty(MUTE_NOTIFICATIONS)) {
- muteNotifications = (boolean) e.getProperty(MUTE_NOTIFICATIONS);
- }
- return new UserFavoriteEntity(e.getKey(), user, testKey, muteNotifications);
- } catch (ClassCastException exception) {
- // Invalid cast
- logger.log(Level.WARNING, "Error parsing user favorite entity.", exception);
- }
- return null;
- }
-}