|
15 | 15 | *******************************************************************************/ |
16 | 16 | package org.pgcodekeeper.core; |
17 | 17 |
|
18 | | -import org.eclipse.core.runtime.FileLocator; |
19 | | -import org.eclipse.core.runtime.URIUtil; |
20 | 18 | import org.junit.jupiter.api.Assertions; |
21 | 19 | import org.pgcodekeeper.core.loader.DatabaseLoader; |
22 | 20 | import org.pgcodekeeper.core.loader.PgDumpLoader; |
23 | | -import org.pgcodekeeper.core.localizations.Messages; |
24 | 21 | import org.pgcodekeeper.core.model.difftree.DbObjType; |
25 | 22 | import org.pgcodekeeper.core.model.difftree.DiffTree; |
26 | 23 | import org.pgcodekeeper.core.model.difftree.TreeElement; |
@@ -80,7 +77,6 @@ public static AbstractDatabase createDumpDB(DatabaseType dbType) { |
80 | 77 | case PG -> new PgSchema(Consts.PUBLIC); |
81 | 78 | case MS -> new MsSchema(Consts.DBO); |
82 | 79 | case CH -> new ChSchema(Consts.CH_DEFAULT_DB); |
83 | | - default -> throw new IllegalArgumentException(Messages.DatabaseType_unsupported_type + dbType); |
84 | 80 | }; |
85 | 81 | db.addSchema(schema); |
86 | 82 | db.setDefaultSchema(schema.getName()); |
@@ -126,9 +122,9 @@ public static void createIgnoreListFile(Path dir) throws IOException { |
126 | 122 | Files.writeString(dir.resolve(".pgcodekeeperignore"), rule); |
127 | 123 | } |
128 | 124 |
|
129 | | - public static Path getPathToResource(String resourceName, Class<?> clazz) throws URISyntaxException, IOException { |
| 125 | + public static Path getPathToResource(String resourceName, Class<?> clazz) throws URISyntaxException { |
130 | 126 | URL url = clazz.getResource(resourceName); |
131 | | - return Paths.get(URIUtil.toURI("file".equals(url.getProtocol()) ? url : FileLocator.toFileURL(url))); |
| 127 | + return Paths.get(url.toURI()); |
132 | 128 | } |
133 | 129 |
|
134 | 130 | static void runDiff(String fileNameTemplate, DatabaseType dbType, Class<?> clazz) throws IOException, InterruptedException { |
@@ -173,24 +169,22 @@ public static void testDepcy(String dbTemplate, String userTemplateName, Map<Str |
173 | 169 |
|
174 | 170 | /** |
175 | 171 | * In this method we simulate user behavior where he selected some objects, all |
176 | | - * or noone. |
| 172 | + * or none. |
177 | 173 | * |
178 | | - * @param selectedObjs - {@link Map} selected objects, where key - name of |
179 | | - * object, value - {@link DbObjType} of object. If is null |
180 | | - * user select all objects |
181 | | - * @param tree - {@link TreeElement} after diff old and new database |
182 | | - * state |
183 | | - * @param oldDbFull - old state of {@link AbstractDatabase} |
184 | | - * @param newDbFull - new state of {@link AbstractDatabase} |
| 174 | + * @param selectedObjects - {@link Map} selected objects, where key - name of object, value - {@link DbObjType} of |
| 175 | + * object. If is null user select all objects |
| 176 | + * @param tree - {@link TreeElement} after diff old and new database state |
| 177 | + * @param oldDbFull - old state of {@link AbstractDatabase} |
| 178 | + * @param newDbFull - new state of {@link AbstractDatabase} |
185 | 179 | */ |
186 | | - private static void setSelected(Map<String, DbObjType> selectedObjs, TreeElement tree, AbstractDatabase oldDbFull, |
| 180 | + private static void setSelected(Map<String, DbObjType> selectedObjects, TreeElement tree, AbstractDatabase oldDbFull, |
187 | 181 | AbstractDatabase newDbFull) { |
188 | | - if (null == selectedObjs) { |
| 182 | + if (null == selectedObjects) { |
189 | 183 | tree.setAllChecked(); |
190 | 184 | return; |
191 | 185 | } |
192 | 186 |
|
193 | | - for (var sel : selectedObjs.entrySet()) { |
| 187 | + for (var sel : selectedObjects.entrySet()) { |
194 | 188 | String[] arr = Arrays.copyOf(sel.getKey().split("-"), 3); |
195 | 189 | var col = new GenericColumn(arr[0], arr[1], arr[2], sel.getValue()); |
196 | 190 | var stmt = newDbFull.getStatement(col); |
|
0 commit comments