@Factory public static <T extends Throwable> Matcher<T> hasMessage(final Matcher<String> matcher) { return new ThrowableMessageMatcher<T>(matcher); } }
@Factory public static <T extends Throwable> Matcher<T> hasMessage(final Matcher<String> matcher) { return new ThrowableMessageMatcher<T>(matcher); } }
@Factory public static <T extends Throwable> Matcher<T> hasMessage(final Matcher<String> matcher) { return new ThrowableMessageMatcher<T>(matcher); } }
@Factory public static <T extends Throwable> Matcher<T> hasMessage(final Matcher<String> matcher) { return new ThrowableMessageMatcher<T>(matcher); } }
@Factory public static <T extends Throwable> Matcher<T> hasMessage(final Matcher<String> matcher) { return new ThrowableMessageMatcher<T>(matcher); } }
@Factory public static <T extends Throwable> Matcher<T> hasMessage(final Matcher<String> matcher) { return new ThrowableMessageMatcher<T>(matcher); } }
@Factory public static <T extends Throwable> Matcher<T> hasMessage(final Matcher<String> matcher) { return new ThrowableMessageMatcher<T>(matcher); } }
@Test public void noChangeSectionAllowed1() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these disallowed sections"))); RerunnableChangeParser parser = new RerunnableChangeParser(); String fileContent = "\n" + "//// METADATA\n" + "//// CHANGE name=abc"; parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null); }
@Test public void noContentInPrologue() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("Improper section ordering: METADATA section must come before the content section"))); RerunnableChangeParser parser = new RerunnableChangeParser(); String fileContent = "\n" + "prologueContentBeforeSections" + "//// METADATA\n" + ""; parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null); }
@Test public void noMultipleMetadataSections1() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these extra sections instances: [METADATA"))); RerunnableChangeParser parser = new RerunnableChangeParser(); String fileContent = "\n" + "//// METADATA\n" + "//// DROP\n" + "//// METADATA\n" + ""; parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null); }
@Test public void noChangeSectionAllowed2() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these disallowed sections"))); RerunnableChangeParser parser = new RerunnableChangeParser(); String fileContent = "\n" + "//// CHANGE name=abc"; parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null); }
@Test public void noMultipleMetadataSections2() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these extra sections instances: [METADATA"))); RerunnableChangeParser parser = new RerunnableChangeParser(); String fileContent = "\n" + "//// METADATA\n" + "//// METADATA\n" + ""; parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null); }
@Test public void noMultipleDropSections() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("found these extra sections instances: [DROP_COMMAND"))); RerunnableChangeParser parser = new RerunnableChangeParser(); String fileContent = "\n" + "//// METADATA\n" + "//// DROP_COMMAND\n" + "//// DROP_COMMAND\n" + ""; parser.value(mock(ChangeType.class), null, fileContent, objectName, "schema", null); } }
@Test public void invalidNoContentAllowedInPrologue1() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("First content of the file must be the"))); TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType); String fileContent = "contentNotAllowedHere\n" + "//// METADATA\n" + "//// CHANGE name=chng1\n" + "CREATE TABLE;\n" + ""; parser.value(tableChangeType, null, fileContent, objectName, "schema", null); }
@Test public void invalidNoContentAllowedInPrologue2() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("First content of the file must be the"))); TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType); String fileContent = "contentNotAllowedHere\n" + "//// CHANGE name=chng1\n" + "CREATE TABLE;\n" + ""; parser.value(tableChangeType, null, fileContent, objectName, "schema", null); }
@Test public void noContentAtAll1() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("No //// " + TextMarkupDocumentReader.TAG_CHANGE + " sections found; at least one is required"))); TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType); String fileContent = ""; parser.value(tableChangeType, null, fileContent, objectName, "schema", null); }
@Test public void invalidNoContentAllowedInPrologue3() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("No //// CHANGE sections found"))); TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType); String fileContent = "contentNotAllowedHere\n" + "CREATE TABLE;\n" + ""; parser.value(tableChangeType, null, fileContent, objectName, "schema", null); }
@Test public void noMetadataContentAllowedAfterFirstLine2() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("Instead, found this section in between"))); TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType); String fileContent = "\n" + "//// CHANGE name=chng1\n" + "CREATE TABLE;\n" + "//// METADATA\n" + ""; parser.value(tableChangeType, null, fileContent, objectName, "schema", null); }
@Test public void noContentAtAll2() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("No //// " + TextMarkupDocumentReader.TAG_CHANGE + " sections found; at least one is required"))); TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType); String fileContent = "\n" + "//// METADATA\n" + ""; parser.value(tableChangeType, null, fileContent, objectName, "schema", null); }
@Test public void invalidNoContentAllowedInMetadata() throws Exception { thrown.expect(IllegalArgumentException.class); thrown.expect(new ThrowableMessageMatcher<Throwable>(containsString("First content of the file must be the"))); TableChangeParser parser = new TableChangeParser(new EmptyContentHashStrategy(), getChangeType); String fileContent = "contentNotAllowedHere\n" + "//// METADATA\n" + "invalid content\n" + "//// CHANGE name=chng1\n" + "CREATE TABLE;\n" + ""; parser.value(tableChangeType, null, fileContent, objectName, "schema", null); }