use of com.google.copybara.authoring.Author in project copybara by google.
the class MetadataModuleTest method testMapAuthor_noop_reversal.
@Test
public void testMapAuthor_noop_reversal() throws Exception {
Transformation m = skylark.eval("m", "m = " + "metadata.map_author({\n" + " 'a' : 'b <b@example.com>',\n" + "}," + "noop_reverse = True)");
TransformWork work = TransformWorks.of(workdir, "test", testingConsole);
work.setAuthor(new Author("a", "foo@foo"));
m.transform(work);
assertThat(work.getAuthor().getEmail()).isEqualTo("b@example.com");
m.reverse().transform(work);
assertThat(work.getAuthor().getEmail()).isEqualTo("b@example.com");
}
use of com.google.copybara.authoring.Author in project copybara by google.
the class MetadataModuleTest method testMapAuthor_reverseFaiIfNotFound.
@Test
public void testMapAuthor_reverseFaiIfNotFound() throws Exception {
Transformation m = skylark.eval("m", "m = " + "metadata.map_author({\n" + " 'a <a@example.com>' : 'b <b@example.com>',\n" + "}," + "reversible = True, reverse_fail_if_not_found = True)");
TransformWork work = TransformWorks.of(workdir, "test", testingConsole);
work.setAuthor(new Author("x", "x@example.com"));
// normal workflow works:
m.transform(work);
ValidationException thrown = assertThrows(ValidationException.class, () -> m.reverse().transform(work));
assertThat(thrown).hasMessageThat().contains("Cannot find a mapping for author 'x <x@example.com>'");
}
Aggregations