1 /* 2 * Copyright (C) 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may 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 implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tradefed.testtype.mobly; 18 19 import java.util.Map; 20 21 /** Mobly yaml result 'Summary' element handler. */ 22 public class MoblyYamlResultSummaryHandler implements IMoblyYamlResultHandler { 23 24 private static final String EXECUTED = "Executed"; 25 26 @Override handle(Map<String, Object> docMap)27 public Summary handle(Map<String, Object> docMap) { 28 Summary.Builder builder = Summary.builder(); 29 builder.setExecuted(String.valueOf(docMap.get(EXECUTED))); 30 return builder.build(); 31 } 32 33 public static class Summary implements ITestResult { 34 private int mExecuted; 35 Summary(String executed)36 private Summary(String executed) { 37 mExecuted = Integer.parseInt(executed); 38 } 39 40 @Override getType()41 public MoblyYamlResultHandlerFactory.Type getType() { 42 return MoblyYamlResultHandlerFactory.Type.SUMMARY; 43 } 44 getExecuted()45 public int getExecuted() { 46 return mExecuted; 47 } 48 builder()49 public static Builder builder() { 50 return new Builder(); 51 } 52 53 public static class Builder { 54 private String mExecuted; 55 setExecuted(String executed)56 public Builder setExecuted(String executed) { 57 mExecuted = executed; 58 return this; 59 } 60 build()61 public Summary build() { 62 return new Summary(mExecuted); 63 } 64 } 65 } 66 } 67