use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class ConsoleTest method captureAllConsole.
@Test
public void captureAllConsole() {
TestingConsole delegate = new TestingConsole().respondYes();
CapturingConsole console = CapturingConsole.captureAllConsole(delegate);
console.error("This is error!");
console.warn("This is warning");
console.info("This is info");
console.progress("This is progress");
console.promptConfirmation("Do you want to continue?");
assertThat(console.getMessages()).containsExactly(new Message(MessageType.ERROR, "This is error!"), new Message(MessageType.WARNING, "This is warning"), new Message(MessageType.INFO, "This is info"), new Message(MessageType.PROGRESS, "This is progress"));
delegate.assertThat().matchesNext(MessageType.ERROR, "This is error!").matchesNext(MessageType.WARNING, "This is warning").matchesNext(MessageType.INFO, "This is info").matchesNext(MessageType.PROGRESS, "This is progress").matchesNext(MessageType.WARNING, "Do you want to continue[?]").containsNoMoreMessages();
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class ConsoleTest method testVerbose.
@Test
public void testVerbose() {
TestingConsole verboseDelegate = new TestingConsole();
CapturingConsole verboseConsole = CapturingConsole.captureAllConsole(verboseDelegate);
verboseConsole.verboseFmt("This is %s", "verbose!");
verboseConsole.verboseFmt("This is also verbose");
verboseConsole.info("This is info");
assertThat(verboseConsole.getMessages()).containsExactly(new Message(MessageType.VERBOSE, "This is verbose!"), new Message(MessageType.VERBOSE, "This is also verbose"), new Message(MessageType.INFO, "This is info"));
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class MultiplexingConsoleTest method testConsole.
@Test
public void testConsole() {
TestingConsole delegate1 = new TestingConsole();
TestingConsole delegate2 = new TestingConsole();
MultiplexingConsole underTest = new MultiplexingConsole(delegate1, delegate2);
underTest.startupMessage("v1");
underTest.info("This is info");
underTest.warn("This is warning");
underTest.error("This is error");
underTest.verbose("This is verbose");
underTest.progress("This is progress");
delegate1.assertThat().matchesNext(MessageType.INFO, "Copybara source mover [(]Version: v1[)]").matchesNext(MessageType.INFO, "This is info").matchesNext(MessageType.WARNING, "This is warning").matchesNext(MessageType.ERROR, "This is error").matchesNext(MessageType.VERBOSE, "This is verbose").matchesNext(MessageType.PROGRESS, "This is progress");
delegate2.assertThat().matchesNext(MessageType.INFO, "Copybara source mover [(]Version: v1[)]").matchesNext(MessageType.INFO, "This is info").matchesNext(MessageType.WARNING, "This is warning").matchesNext(MessageType.ERROR, "This is error").matchesNext(MessageType.VERBOSE, "This is verbose").matchesNext(MessageType.PROGRESS, "This is progress");
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class RevisionMigratorTest method setUp.
@Before
public void setUp() throws Exception {
FileSystem fs = Jimfs.newFileSystem();
checkoutDir = fs.getPath("/test-checkoutDir");
origin = new DummyOrigin();
destinationReader = new MockReader();
location = Location.fromFileLineColumn("file", 1, 2);
referenceMigrator = ReferenceMigrator.create("http://internalReviews.com/${reference}", "http://externalreviews.com/view?${reference}", Pattern.compile("[0-9]+"), Pattern.compile("[0-9a-f]+"), ImmutableList.of(), location);
OptionsBuilder options = new OptionsBuilder();
console = new TestingConsole();
options.setConsole(console);
skylark = new SkylarkTestExecutor(options);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GlobTest method setup.
@Before
public void setup() throws IOException, RepoException {
workdir = Files.createTempDirectory("workdir");
OptionsBuilder options = new OptionsBuilder().setWorkdirToRealTempDir().setConsole(new TestingConsole());
skylark = new SkylarkTestExecutor(options);
}
Aggregations