|
15 | 15 | import java.io.File;
|
16 | 16 | import java.io.IOException;
|
17 | 17 | import java.io.PrintStream;
|
| 18 | +import java.util.UUID; |
18 | 19 |
|
19 | 20 | import static org.hamcrest.MatcherAssert.assertThat;
|
20 | 21 | import static org.hamcrest.core.StringContains.containsString;
|
@@ -159,6 +160,32 @@ public void testExportHRSchemaDefault() throws Exception {
|
159 | 160 |
|
160 | 161 | }
|
161 | 162 |
|
| 163 | + @Test |
| 164 | + public void testFilterAndReplaceSeqValue() throws Exception { |
| 165 | + File tempOutput = FileUtils.getFile(FileUtils.getTempDirectoryPath(), |
| 166 | + "scheme2ddl-test-" + UUID.randomUUID().toString().substring(0,8)); |
| 167 | + String outputPath = tempOutput.getAbsolutePath(); |
| 168 | + |
| 169 | + String[] args = {"-url", url, "-f", "LOCATIONS_SEQ", "-o", outputPath}; |
| 170 | + Main.main(args); |
| 171 | + |
| 172 | + String out = outContent.toString(); |
| 173 | + assertThat(out, containsString("Found 1 items for processing in schema HR")); |
| 174 | + |
| 175 | + assertEqualsFileContent(outputPath + "/sequences/locations_seq.sql", "CREATE SEQUENCE \"HR\".\"LOCATIONS_SEQ\"" + |
| 176 | + " MINVALUE 1 MAXVALUE 9900 INCREMENT BY 100 START WITH 3300 NOCACHE NOORDER NOCYCLE ;"); |
| 177 | + |
| 178 | + |
| 179 | + String[] args2 = {"-url", url, "--filter", "LOCATIONS_SEQ", "--output", outputPath, "--replace-sequence-values"}; |
| 180 | + Main.main(args2); |
| 181 | + out = outContent.toString(); |
| 182 | + assertThat(out, containsString("Found 1 items for processing in schema HR")); |
| 183 | + |
| 184 | + assertEqualsFileContent(outputPath + "/sequences/locations_seq.sql", "CREATE SEQUENCE \"HR\".\"LOCATIONS_SEQ\" MINVALUE 1 MAXVALUE 9900 INCREMENT BY 100 START WITH 1 NOCACHE NOORDER NOCYCLE ;\n" + |
| 185 | + "/* -- actual sequence value was replaced by scheme2ddl to 1 */"); |
| 186 | + |
| 187 | + } |
| 188 | + |
162 | 189 |
|
163 | 190 | private static void assertEqualsFileContent(String path, String content) throws IOException {
|
164 | 191 | File file = new File(path);
|
|
0 commit comments