Line data Source code
1 : // Copyright (C) 2017 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.testing; 16 : 17 : import static java.util.stream.Collectors.joining; 18 : 19 : import com.google.common.collect.ImmutableList; 20 : import com.google.gerrit.server.schema.UpdateUI; 21 : import java.util.ArrayList; 22 : import java.util.List; 23 : import java.util.Set; 24 : 25 2 : public class TestUpdateUI implements UpdateUI { 26 2 : private final List<String> messages = new ArrayList<>(); 27 : 28 : @Override 29 : public void message(String message) { 30 1 : messages.add(message); 31 1 : } 32 : 33 : public ImmutableList<String> getMessages() { 34 0 : return ImmutableList.copyOf(messages); 35 : } 36 : 37 : public String getOutput() { 38 1 : return messages.stream().collect(joining("\n")); 39 : } 40 : 41 : @Override 42 : public boolean yesno(boolean defaultValue, String message) { 43 0 : return defaultValue; 44 : } 45 : 46 : @Override 47 0 : public void waitForUser() {} 48 : 49 : @Override 50 : public String readString(String defaultValue, Set<String> allowedValues, String message) { 51 0 : return defaultValue; 52 : } 53 : 54 : @Override 55 : public boolean isBatch() { 56 0 : return true; 57 : } 58 : }