use of com.google.copybara.util.console.Console in project copybara by google.
the class SkylarkConsoleTest method testColorize.
@Test
public void testColorize() {
Console delegate = mock(Console.class);
when(delegate.colorize(any(), any())).thenReturn("colorized!");
assertThat(new SkylarkConsole(delegate).colorize(AnsiColor.BLUE, "aaaa")).isEqualTo("colorized!");
}
use of com.google.copybara.util.console.Console in project copybara by google.
the class GithubArchiveTest method setup.
@Before
public void setup() throws IOException {
httpTransport = new MockHttpTransport() {
@Override
public LowLevelHttpRequest buildRequest(String method, String url) {
String requestString = method + " " + url;
MockLowLevelHttpRequest request = new MockLowLevelHttpRequest();
MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
request.setResponse(response);
response.setStatusCode(200);
response.setContent(responseContent);
if (!url.equals(expectedRequest)) {
response.setStatusCode(404);
response.setContent(String.format("UNEXPECTED REQUEST (Returning 404) REQUEST: %s, expected: %s", requestString, expectedRequest));
}
return request;
}
};
RemoteFileOptions options = new RemoteFileOptions();
options.transport = () -> new GclientHttpStreamFactory(httpTransport, Duration.ofSeconds(20));
Console console = new TestingConsole();
OptionsBuilder optionsBuilder = new OptionsBuilder().setConsole(console);
optionsBuilder.remoteFile = options;
skylark = new SkylarkTestExecutor(optionsBuilder);
}
use of com.google.copybara.util.console.Console in project copybara by google.
the class TestingConsoleTest method testPredicateCausesAssertionError.
@Test
public void testPredicateCausesAssertionError() throws Exception {
Console console = new TestingConsole().respondWithString("Lorem Ipsum!");
assertThrows(IOException.class, () -> console.ask("Have anything to say?", "foo", x -> x.equals("Hello world!")));
}
use of com.google.copybara.util.console.Console in project copybara by google.
the class TestingConsoleTest method testProgrammedStringResponses.
@Test
public void testProgrammedStringResponses() throws Exception {
Console console = new TestingConsole().respondWithString("Hello world!");
assertThat(console.ask("Have anything to say?", "foo", Objects::nonNull)).isEqualTo("Hello world!");
}
use of com.google.copybara.util.console.Console in project copybara by google.
the class TestingConsoleTest method testProgrammedResponses.
@Test
public void testProgrammedResponses() throws Exception {
Console console = new TestingConsole().respondYes().respondNo();
assertThat(console.promptConfirmation("Proceed?")).isTrue();
assertThat(console.promptConfirmation("Proceed?")).isFalse();
}
Aggregations