1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you
5  * may not use this file except in compliance with the License. You may
6  * obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13  * implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16 
17 package com.android.vts.entity;
18 
19 import com.android.vts.util.ObjectifyTestBase;
20 import org.junit.jupiter.api.Test;
21 
22 import java.util.Arrays;
23 import java.util.List;
24 
25 import static com.googlecode.objectify.ObjectifyService.factory;
26 import static org.junit.Assert.assertEquals;
27 
28 public class TestCaseRunEntityTest extends ObjectifyTestBase {
29 
30     @Test
saveTest()31     public void saveTest() {
32 
33         factory().register(TestCaseRunEntity.class);
34 
35         List<Integer> results = Arrays.asList(1, 1, 1, 1, 1, 1, 1);
36         List<String> testCaseNames =
37                 Arrays.asList(
38                         "AudioEffectsFactoryTest.EnumerateEffects(default)_32bit",
39                         "AudioEffectsFactoryTest.CreateEffect(default)_32bit",
40                         "AudioEffectsFactoryTest.GetDescriptor(default)_32bit",
41                         "AudioEffectsFactoryTest.DebugDumpArgument(default)_32bit",
42                         "AudioEffectTest.Close(default)_32bit",
43                         "AudioEffectTest.GetDescriptor(default)_32bit",
44                         "AudioEffectTest.GetSetConfig(default)_32bit");
45 
46         TestCaseRunEntity testCaseRunEntity = new TestCaseRunEntity();
47         for (int index = 0; index < results.size(); index++) {
48             String testCaseName = testCaseNames.get(index);
49             int result = results.get(index);
50             testCaseRunEntity.addTestCase(testCaseName, result);
51         }
52         TestCaseRunEntity loadedTestCaseRunEntity = saveClearLoad(testCaseRunEntity);
53 
54         assertEquals(loadedTestCaseRunEntity.getTestCases().size(), results.size());
55         assertEquals(
56                 (Integer) loadedTestCaseRunEntity.getTestCases().get(0).result, results.get(0));
57         assertEquals(loadedTestCaseRunEntity.getTestCases().get(0).name, testCaseNames.get(0));
58     }
59 }
60