Search in sources :

Example 76 with ValidationException

use of com.google.copybara.exception.ValidationException in project copybara by google.

the class HgRepositoryTest method testPullHttp.

@Test
public void testPullHttp() throws Exception {
    ValidationException e = assertThrows(ValidationException.class, () -> repository.pullAll("http://copybara.com"));
    assertThat(e).hasMessageThat().contains("URL 'http://copybara.com' is not valid - should be using https.");
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) Test(org.junit.Test)

Example 77 with ValidationException

use of com.google.copybara.exception.ValidationException in project copybara by google.

the class GerritApiTest method testCreateProject_invalid.

@Test
public void testCreateProject_invalid() throws Exception {
    ValidationException e = assertThrows(ValidationException.class, () -> gerritApi.createProject("some project"));
    assertThat(e).hasMessageThat().contains("has spaces");
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) Test(org.junit.Test)

Example 78 with ValidationException

use of com.google.copybara.exception.ValidationException in project copybara by google.

the class HgOriginTest method testUnknownChange.

@Test
public void testUnknownChange() throws Exception {
    ValidationException expected = assertThrows(ValidationException.class, () -> newReader().change(origin.resolve("7")));
    assertThat(expected.getMessage()).contains("Unknown revision");
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) Test(org.junit.Test)

Example 79 with ValidationException

use of com.google.copybara.exception.ValidationException in project copybara by google.

the class CopyOrMoveTest method testCannotMoveWithPathGlobsSpecificFile.

@Test
public void testCannotMoveWithPathGlobsSpecificFile() throws Exception {
    CopyOrMove t = skylark.eval("m", "m = core.move('foo', '' , paths = glob(['foo.txt']))");
    touch("foo/foo.txt");
    touch("foo.txt");
    ValidationException e = assertThrows(ValidationException.class, () -> transform(t));
    assertThat(e).hasMessageThat().contains("Cannot move file to '" + checkoutDir + "/foo.txt' because it already exists");
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) NonReversibleValidationException(com.google.copybara.exception.NonReversibleValidationException) Test(org.junit.Test)

Example 80 with ValidationException

use of com.google.copybara.exception.ValidationException in project copybara by google.

the class CopyOrMoveTest method testFailMoveToCheckoutDirRoot.

@Test
public void testFailMoveToCheckoutDirRoot() throws Exception {
    CopyOrMove mover = skylark.eval("m", "m = core.move(before = 'third_party/java/one.java', after = '')\n");
    touch("third_party/java/one.java");
    ValidationException e = assertThrows(ValidationException.class, () -> transform(mover));
    assertThat(e).hasMessageThat().contains("Can only move a path to the root when the path is a " + "folder. But 'third_party/java/one.java' is a file. Use instead " + "core.move('third_party/java/one.java', 'one.java')");
    assertThatPath(checkoutDir).containsFiles("third_party/java/one.java").containsNoMoreFiles();
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) NonReversibleValidationException(com.google.copybara.exception.NonReversibleValidationException) Test(org.junit.Test)

Aggregations

ValidationException (com.google.copybara.exception.ValidationException)178 Test (org.junit.Test)125 Path (java.nio.file.Path)33 RepoException (com.google.copybara.exception.RepoException)29 NonReversibleValidationException (com.google.copybara.exception.NonReversibleValidationException)26 ImmutableList (com.google.common.collect.ImmutableList)21 IOException (java.io.IOException)19 Console (com.google.copybara.util.console.Console)16 EmptyChangeException (com.google.copybara.exception.EmptyChangeException)14 DummyRevision (com.google.copybara.testing.DummyRevision)14 Glob (com.google.copybara.util.Glob)14 ProfilerTask (com.google.copybara.profiler.Profiler.ProfilerTask)13 Nullable (javax.annotation.Nullable)13 Migration (com.google.copybara.config.Migration)11 TestingConsole (com.google.copybara.util.console.testing.TestingConsole)11 Iterables (com.google.common.collect.Iterables)10 Change (com.google.copybara.Change)10 CannotResolveRevisionException (com.google.copybara.exception.CannotResolveRevisionException)10 Collectors (java.util.stream.Collectors)10 WriterContext (com.google.copybara.WriterContext)9