diff options
Diffstat (limited to 'src/main/java/com/android/vts/entity/TestCaseRunEntity.java')
-rw-r--r-- | src/main/java/com/android/vts/entity/TestCaseRunEntity.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/main/java/com/android/vts/entity/TestCaseRunEntity.java b/src/main/java/com/android/vts/entity/TestCaseRunEntity.java index 6d3ba83..30776d4 100644 --- a/src/main/java/com/android/vts/entity/TestCaseRunEntity.java +++ b/src/main/java/com/android/vts/entity/TestCaseRunEntity.java @@ -24,17 +24,17 @@ import com.googlecode.objectify.annotation.Ignore; import com.googlecode.objectify.annotation.OnLoad; 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 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 { - protected static final Logger logger = Logger.getLogger(TestCaseRunEntity.class.getName()); public static final String KIND = "TestCaseRun"; @@ -89,7 +89,8 @@ public class TestCaseRunEntity implements DashboardEntity { * Create a TestCaseRunEntity. */ public TestCaseRunEntity() { - this.id = -1L; + this.results = new ArrayList<>(); + this.testCaseNames = new ArrayList<>(); this.testCases = new ArrayList<>(); this.systraceUrl = null; } @@ -100,6 +101,8 @@ public class TestCaseRunEntity implements DashboardEntity { */ public TestCaseRunEntity(long id) { this.id = id; + this.results = new ArrayList<>(); + this.testCaseNames = new ArrayList<>(); this.testCases = new ArrayList<>(); this.systraceUrl = null; } @@ -147,13 +150,21 @@ public class TestCaseRunEntity implements DashboardEntity { * @return true if added, false otherwise. */ public boolean addTestCase(String name, int result) { - if (isFull()) + if (this.isFull()) { return false; - this.testCases.add(new TestCase(this.id, this.testCases.size(), name, result)); - return true; + } 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) { @@ -188,7 +199,7 @@ public class TestCaseRunEntity implements DashboardEntity { @SuppressWarnings("unchecked") public static TestCaseRunEntity fromEntity(Entity e) { if (!e.getKind().equals(KIND)) { - logger.log(Level.WARNING, "Wrong kind: " + e.getKey()); + log.warn("Wrong kind: " + e.getKey()); return null; } try { @@ -213,7 +224,7 @@ public class TestCaseRunEntity implements DashboardEntity { return testCaseRun; } catch (ClassCastException exception) { // Invalid cast - logger.log(Level.WARNING, "Error parsing test case run entity.", exception); + log.warn("Error parsing test case run entity.", exception); } return null; } |