Search in sources :

Example 46 with ValidationException

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

the class GerritDestinationTest method testSubmitAndDisableNotifications.

@Test
public void testSubmitAndDisableNotifications() {
    ValidationException expected = assertThrows(ValidationException.class, () -> destination("submit = True", "notify = 'OWNER'"));
    assertThat(expected).hasMessageThat().contains("Cannot set 'notify' with 'submit = True' in git.gerrit_destination()");
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) Test(org.junit.Test)

Example 47 with ValidationException

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

the class GerritDestinationTest method testChangeIdPolicyFailIfPresent.

@Test
public void testChangeIdPolicyFailIfPresent() throws Exception {
    options.gerrit.gerritChangeId = null;
    options.gitDestination.nonFastForwardPush = true;
    String changeId = runChangeIdPolicy("Test message", "change_id_policy = 'FAIL_IF_PRESENT'");
    assertThat(changeId).isNotNull();
    ValidationException e = assertThrows(ValidationException.class, () -> runChangeIdPolicy("Test message\n\nChange-Id: " + CONSTANT_CHANGE_ID + "\n", "change_id_policy = 'FAIL_IF_PRESENT'"));
    assertThat(e).hasMessageThat().contains("label found in message");
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) Test(org.junit.Test)

Example 48 with ValidationException

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

the class GerritDestinationTest method testSubmitAndTopic.

@Test
public void testSubmitAndTopic() {
    ValidationException expected = assertThrows(ValidationException.class, () -> destination("submit = True", "topic = 'test_${CONTEXT_REFERENCE}'"));
    assertThat(expected).hasMessageThat().contains("Cannot set 'topic' with 'submit = True' in git.gerrit_destination()");
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) Test(org.junit.Test)

Example 49 with ValidationException

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

the class FolderOriginTest method testAbsolutePaths.

@Test
public void testAbsolutePaths() throws Exception {
    ValidationException thrown = assertThrows(ValidationException.class, () -> runAbsolutePaths("folder.origin()"));
    assertThat(thrown).hasMessageThat().contains("Some symlinks refer to locations outside of the folder and" + " 'materialize_outside_symlinks' config option was not used");
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) Test(org.junit.Test)

Example 50 with ValidationException

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

the class GerritEndpointTest method testFeedbackGetChange_malformedJson.

@Test
public void testFeedbackGetChange_malformedJson() throws Exception {
    gitUtil.mockApi(anyString(), anyString(), mockResponse("foo   bar"));
    Feedback feedback = notifyChangeToOriginFeedback();
    ValidationException expected = assertThrows(ValidationException.class, () -> feedback.run(workdir, ImmutableList.of("12345")));
    assertThat(expected).hasMessageThat().contains("Error while executing the skylark transformation test_action");
    Throwable cause = expected.getCause();
    assertThat(cause).isInstanceOf(IllegalArgumentException.class);
    assertThat(dummyTrigger.messages).isEmpty();
}
Also used : ValidationException(com.google.copybara.exception.ValidationException) Feedback(com.google.copybara.feedback.Feedback) 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