From 73863ff819af6c6a6fc26e7376e9f482a87d0cb0 Mon Sep 17 00:00:00 2001 From: Mitsunori Komatsu Date: Thu, 12 Jun 2025 14:29:24 +0900 Subject: [PATCH 1/3] Add old methods for backward compatibility --- .../scalar/db/schemaloader/SchemaLoader.java | 266 ++++++++ .../db/schemaloader/SchemaLoaderTest.java | 610 ++++++++++++++++++ 2 files changed, 876 insertions(+) diff --git a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java index 32d179ec1b..b3f8aa0481 100644 --- a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java +++ b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java @@ -453,6 +453,272 @@ private static void repairAll( } } + // For backward compatibility. + + /** + * Creates tables defined in the schema file. See {@link #load(Properties, Path, Map, boolean, + * boolean)} for details. + * + * @param configProperties ScalarDB config properties. + * @param schemaFilePath path to schema file. + * @param options specific options for creating tables. + * @param createCoordinatorTables create coordinator tables or not. + * @throws SchemaLoaderException thrown when creating tables fails. + */ + public static void load( + Properties configProperties, + @Nullable Path schemaFilePath, + Map options, + boolean createCoordinatorTables) + throws SchemaLoaderException { + load(configProperties, schemaFilePath, options, createCoordinatorTables, false); + } + + /** + * Creates tables defined in the schema file. See {@link #load(Path, Path, Map, boolean, boolean)} + * for details. + * + * @param configFilePath path to ScalarDB config file. + * @param schemaFilePath path to schema file. + * @param options specific options for creating tables. + * @param createCoordinatorTables create coordinator tables or not. + * @throws SchemaLoaderException thrown when creating tables fails. + */ + public static void load( + Path configFilePath, + @Nullable Path schemaFilePath, + Map options, + boolean createCoordinatorTables) + throws SchemaLoaderException { + load(configFilePath, schemaFilePath, options, createCoordinatorTables, false); + } + + /** + * Creates tables defined in the schema. See {@link #load(Properties, String, Map, boolean, + * boolean)} for details. + * + * @param configProperties ScalarDB config properties. + * @param serializedSchemaJson serialized json string schema. + * @param options specific options for creating tables. + * @param createCoordinatorTables create coordinator tables or not. + * @throws SchemaLoaderException thrown when creating tables fails. + */ + public static void load( + Properties configProperties, + @Nullable String serializedSchemaJson, + Map options, + boolean createCoordinatorTables) + throws SchemaLoaderException { + load(configProperties, serializedSchemaJson, options, createCoordinatorTables, false); + } + + /** + * Creates tables defined in the schema. See {@link #load(Path, String, Map, boolean, boolean)} + * for details. + * + * @param configFilePath path to ScalarDB config file. + * @param serializedSchemaJson serialized json string schema. + * @param options specific options for creating tables. + * @param createCoordinatorTables create coordinator tables or not. + * @throws SchemaLoaderException thrown when creating tables fails. + */ + public static void load( + Path configFilePath, + @Nullable String serializedSchemaJson, + Map options, + boolean createCoordinatorTables) + throws SchemaLoaderException { + load(configFilePath, serializedSchemaJson, options, createCoordinatorTables, false); + } + + /** + * Creates tables defined in the schema file. See {@link #load(Either, Either, Map, boolean, + * boolean)} for details. + * + * @param config ScalarDB config. + * @param schema schema definition. + * @param options specific options for creating tables. + * @param createCoordinatorTables create coordinator tables or not. + * @throws SchemaLoaderException thrown when creating tables fails. + */ + private static void load( + Either config, + Either schema, + Map options, + boolean createCoordinatorTables) + throws SchemaLoaderException { + load(config, schema, options, createCoordinatorTables, false); + } + + /** + * Delete tables defined in the schema file. See {@link #unload(Properties, Path, boolean, + * boolean)} for details. + * + * @param configProperties ScalarDB config properties. + * @param schemaFilePath path to schema file. + * @param deleteCoordinatorTables delete coordinator tables or not. + * @throws SchemaLoaderException thrown when deleting tables fails. + */ + public static void unload( + Properties configProperties, @Nullable Path schemaFilePath, boolean deleteCoordinatorTables) + throws SchemaLoaderException { + unload(configProperties, schemaFilePath, deleteCoordinatorTables, false); + } + + /** + * Delete tables defined in the schema file. See {@link #unload(Path, Path, boolean, boolean)} for + * details. + * + * @param configFilePath path to ScalarDB config file. + * @param schemaFilePath path to schema file. + * @param deleteCoordinatorTables delete coordinator tables or not. + * @throws SchemaLoaderException thrown when deleting tables fails. + */ + public static void unload( + Path configFilePath, @Nullable Path schemaFilePath, boolean deleteCoordinatorTables) + throws SchemaLoaderException { + unload(configFilePath, schemaFilePath, deleteCoordinatorTables, false); + } + + /** + * Delete tables defined in the schema. See {@link #unload(Properties, String, boolean, boolean)} + * for details. + * + * @param configProperties ScalarDB config properties. + * @param serializedSchemaJson serialized json string schema. + * @param deleteCoordinatorTables delete coordinator tables or not. + * @throws SchemaLoaderException thrown when deleting tables fails. + */ + public static void unload( + Properties configProperties, + @Nullable String serializedSchemaJson, + boolean deleteCoordinatorTables) + throws SchemaLoaderException { + unload(configProperties, serializedSchemaJson, deleteCoordinatorTables, false); + } + + /** + * Delete tables defined in the schema. See {@link #unload(Path, String, boolean, boolean)} for + * details. + * + * @param configFilePath path to ScalarDB config file. + * @param serializedSchemaJson serialized json string schema. + * @param deleteCoordinatorTables delete coordinator tables or not. + * @throws SchemaLoaderException thrown when deleting tables fails. + */ + public static void unload( + Path configFilePath, @Nullable String serializedSchemaJson, boolean deleteCoordinatorTables) + throws SchemaLoaderException { + unload(configFilePath, serializedSchemaJson, deleteCoordinatorTables, false); + } + + /** + * Delete tables defined in the schema. See {@link #unload(Either, Either, boolean, boolean)} for + * details. + * + * @param config ScalarDB config. + * @param schema schema definition. + * @param deleteCoordinatorTables delete coordinator tables or not. + * @throws SchemaLoaderException thrown when deleting tables fails. + */ + private static void unload( + Either config, Either schema, boolean deleteCoordinatorTables) + throws SchemaLoaderException { + unload(config, schema, deleteCoordinatorTables, false); + } + + /** + * Repair namespaces and tables. See {@link #repairAll(Properties, String, Map, boolean, boolean)} + * for details. + * + * @param configProperties ScalarDB config properties + * @param serializedSchemaJson serialized json string schema. + * @param options specific options for repairing. + * @param repairCoordinatorTable repair coordinator tables or not. + * @throws SchemaLoaderException thrown when repairing fails. + */ + public static void repairAll( + Properties configProperties, + String serializedSchemaJson, + Map options, + boolean repairCoordinatorTable) + throws SchemaLoaderException { + repairAll(configProperties, serializedSchemaJson, options, repairCoordinatorTable, false); + } + + /** + * Repair namespaces and tables. See {@link #repairAll(Path, String, Map, boolean, boolean)} for + * details. + * + * @param configProperties ScalarDB properties. + * @param schemaPath path to the schema file. + * @param options specific options for repairing. + * @param repairCoordinatorTable repair coordinator tables or not. + * @throws SchemaLoaderException thrown when repairing fails. + */ + public static void repairAll( + Properties configProperties, + Path schemaPath, + Map options, + boolean repairCoordinatorTable) + throws SchemaLoaderException { + repairAll(configProperties, schemaPath, options, repairCoordinatorTable, false); + } + + /** + * Repair namespaces and tables. See {@link #repairAll(Path, String, Map, boolean, boolean)} for + * details. + * + * @param configPath path to the ScalarDB config. + * @param serializedSchemaJson serialized json string schema. + * @param options specific options for repairing. + * @param repairCoordinatorTable repair coordinator tables or not. + * @throws SchemaLoaderException thrown when repairing fails. + */ + public static void repairAll( + Path configPath, + String serializedSchemaJson, + Map options, + boolean repairCoordinatorTable) + throws SchemaLoaderException { + repairAll(configPath, serializedSchemaJson, options, repairCoordinatorTable, false); + } + + /** + * Repair namespaces and tables. See {@link #repairAll(Path, Path, Map, boolean, boolean)} for + * details. + * + * @param configPath path to the ScalarDB config. + * @param schemaPath path to the schema file. + * @param options specific options for repairing. + * @param repairCoordinatorTable repair coordinator tables or not. + * @throws SchemaLoaderException thrown when repairing fails. + */ + public static void repairAll( + Path configPath, Path schemaPath, Map options, boolean repairCoordinatorTable) + throws SchemaLoaderException { + repairAll(configPath, schemaPath, options, repairCoordinatorTable, false); + } + + /** + * Repair namespaces and tables. See {@link #repairAll(Either, Either, Map, boolean, boolean)} for + * details. + * + * @param config ScalarDB config + * @param schema schema. + * @param options specific options for repairing. + * @param repairCoordinatorTable repair coordinator tables or not. + * @throws SchemaLoaderException thrown when repairing fails. + */ + private static void repairAll( + Either config, + Either schema, + Map options, + boolean repairCoordinatorTable) + throws SchemaLoaderException { + repairAll(config, schema, options, repairCoordinatorTable, false); + } + /** * Alter the tables defined in the schema. Supported alter operations are: * diff --git a/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java b/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java index 4a320ba0c1..edc17207dc 100644 --- a/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java +++ b/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java @@ -916,6 +916,616 @@ public void tearDown() throws Exception { } } + // For backward compatibility with the old method signatures. + + @Test + public void + load_WithConfigFileAndSchemaFileWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, schemaFilePath, options, true); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndSchemaFileWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, schemaFilePath, options, false); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndNullSchemaFileWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, (Path) null, options, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndNullSchemaFileWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, (Path) null, options, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndSerializedSchemaJsonWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, SERIALIZED_SCHEMA_JSON, options, true); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndSerializedSchemaJsonWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, SERIALIZED_SCHEMA_JSON, options, false); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndNullSerializedSchemaJsonWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, (String) null, options, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigFileAndNullSerializedSchemaJsonWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configFilePath, (String) null, options, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndSchemaFileWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, schemaFilePath, options, true); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndSchemaFileWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, schemaFilePath, options, false); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndNullSchemaFileWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, (Path) null, options, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndNullSchemaFileWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, (Path) null, options, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndSerializedSchemaJsonWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, SERIALIZED_SCHEMA_JSON, options, true); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndSerializedSchemaJsonWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, SERIALIZED_SCHEMA_JSON, options, false); + + // Assert + verify(parser).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndNullSerializedSchemaJsonWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, (String) null, options, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator).createCoordinatorTables(options); + } + + @Test + public void + load_WithConfigPropertiesAndNullSerializedSchemaJsonWithoutCreateCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.load(configProperties, (String) null, options, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).createTables(anyList()); + verify(operator, never()).createCoordinatorTables(options); + } + + @Test + public void + unload_WithConfigFileAndSchemaFileWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, schemaFilePath, true); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndSchemaFileWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, schemaFilePath, false); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndNullSchemaFileWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, (Path) null, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndNullSchemaFileWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, (Path) null, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndSerializedSchemaJsonWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, SERIALIZED_SCHEMA_JSON, true); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndSerializedSchemaJsonWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, SERIALIZED_SCHEMA_JSON, false); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndNullSerializedSchemaJsonWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, (String) null, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigFileAndNullSerializedSchemaJsonWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configFilePath, (String) null, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndSchemaFileWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, schemaFilePath, true); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndSchemaFileWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, schemaFilePath, false); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndNullSchemaFileWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, (Path) null, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndNullSchemaFileWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, (Path) null, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndSerializedSchemaJsonWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, SERIALIZED_SCHEMA_JSON, true); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndSerializedSchemaJsonWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, SERIALIZED_SCHEMA_JSON, false); + + // Assert + verify(parser).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndNullSerializedSchemaJsonWithDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, (String) null, true); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator).dropCoordinatorTables(); + } + + @Test + public void + unload_WithConfigPropertiesAndNullSerializedSchemaJsonWithoutDeleteCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.unload(configProperties, (String) null, false); + + // Assert + verify(parser, never()).parse(); + verify(operator).deleteTables(anyList()); + verify(operator, never()).dropCoordinatorTables(); + } + + @Test + public void + repairAll_WithConfigFilePathAndSerializedSchemaAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configFilePath, SERIALIZED_SCHEMA_JSON, options, true); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator).repairCoordinatorTables(options); + } + + @Test + public void + repairAll_WithConfigFilePathAndSerializedSchemaAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configFilePath, SERIALIZED_SCHEMA_JSON, options, false); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator, never()).repairCoordinatorTables(anyMap()); + } + + @Test + public void + repairAll_WithConfigPropertiesAndSerializedSchemaAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configProperties, SERIALIZED_SCHEMA_JSON, options, true); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator).repairCoordinatorTables(options); + } + + @Test + public void + repairAll_WithConfigPropertiesAndSerializedSchemaAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configProperties, SERIALIZED_SCHEMA_JSON, options, false); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator, never()).repairCoordinatorTables(anyMap()); + } + + @Test + public void + repairAll_WithConfigPropertiesAndSchemaFilePathAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configProperties, schemaFilePath, options, true); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator).repairCoordinatorTables(options); + } + + @Test + public void + repairAll_WithConfigPropertiesAndSchemaFilePathAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configProperties, schemaFilePath, options, false); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator, never()).repairCoordinatorTables(anyMap()); + } + + @Test + public void + repairAll_WithConfigFilePathAndSchemaFilePathAndDoRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configFilePath, schemaFilePath, options, true); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator).repairCoordinatorTables(options); + } + + @Test + public void + repairAll_WithConfigFilePathAndSchemaFilePathAndDoNotRepairCoordinatorTables_ShouldCallParserAndOperatorProperly() + throws Exception { + // Arrange + + // Act + SchemaLoader.repairAll(configFilePath, schemaFilePath, options, false); + + // Assert + verify(parser).parse(); + verify(operator).repairNamespaces(anyList()); + verify(operator).repairTables(anyList()); + verify(operator, never()).repairCoordinatorTables(anyMap()); + } + @Test public void alterTables_WithConfigFilePathAndSerializedSchema_ShouldCallParserAndOperatorProperly() From 7676ad3f316c054dc9b0f2ce4d42c573d1a9dc64 Mon Sep 17 00:00:00 2001 From: Mitsunori Komatsu Date: Thu, 12 Jun 2025 15:00:41 +0900 Subject: [PATCH 2/3] Remove unused methods --- .../scalar/db/schemaloader/SchemaLoader.java | 53 ------------------- 1 file changed, 53 deletions(-) diff --git a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java index b3f8aa0481..66046e35d8 100644 --- a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java +++ b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java @@ -531,25 +531,6 @@ public static void load( load(configFilePath, serializedSchemaJson, options, createCoordinatorTables, false); } - /** - * Creates tables defined in the schema file. See {@link #load(Either, Either, Map, boolean, - * boolean)} for details. - * - * @param config ScalarDB config. - * @param schema schema definition. - * @param options specific options for creating tables. - * @param createCoordinatorTables create coordinator tables or not. - * @throws SchemaLoaderException thrown when creating tables fails. - */ - private static void load( - Either config, - Either schema, - Map options, - boolean createCoordinatorTables) - throws SchemaLoaderException { - load(config, schema, options, createCoordinatorTables, false); - } - /** * Delete tables defined in the schema file. See {@link #unload(Properties, Path, boolean, * boolean)} for details. @@ -612,21 +593,6 @@ public static void unload( unload(configFilePath, serializedSchemaJson, deleteCoordinatorTables, false); } - /** - * Delete tables defined in the schema. See {@link #unload(Either, Either, boolean, boolean)} for - * details. - * - * @param config ScalarDB config. - * @param schema schema definition. - * @param deleteCoordinatorTables delete coordinator tables or not. - * @throws SchemaLoaderException thrown when deleting tables fails. - */ - private static void unload( - Either config, Either schema, boolean deleteCoordinatorTables) - throws SchemaLoaderException { - unload(config, schema, deleteCoordinatorTables, false); - } - /** * Repair namespaces and tables. See {@link #repairAll(Properties, String, Map, boolean, boolean)} * for details. @@ -700,25 +666,6 @@ public static void repairAll( repairAll(configPath, schemaPath, options, repairCoordinatorTable, false); } - /** - * Repair namespaces and tables. See {@link #repairAll(Either, Either, Map, boolean, boolean)} for - * details. - * - * @param config ScalarDB config - * @param schema schema. - * @param options specific options for repairing. - * @param repairCoordinatorTable repair coordinator tables or not. - * @throws SchemaLoaderException thrown when repairing fails. - */ - private static void repairAll( - Either config, - Either schema, - Map options, - boolean repairCoordinatorTable) - throws SchemaLoaderException { - repairAll(config, schema, options, repairCoordinatorTable, false); - } - /** * Alter the tables defined in the schema. Supported alter operations are: * From e7b6082f33b1a769d760023ebc5b4b31c1be4456 Mon Sep 17 00:00:00 2001 From: Mitsunori Komatsu Date: Fri, 13 Jun 2025 11:30:51 +0900 Subject: [PATCH 3/3] Remove comments --- .../src/main/java/com/scalar/db/schemaloader/SchemaLoader.java | 2 -- .../test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java | 2 -- 2 files changed, 4 deletions(-) diff --git a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java index 66046e35d8..36747986de 100644 --- a/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java +++ b/schema-loader/src/main/java/com/scalar/db/schemaloader/SchemaLoader.java @@ -453,8 +453,6 @@ private static void repairAll( } } - // For backward compatibility. - /** * Creates tables defined in the schema file. See {@link #load(Properties, Path, Map, boolean, * boolean)} for details. diff --git a/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java b/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java index edc17207dc..6ea37feeed 100644 --- a/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java +++ b/schema-loader/src/test/java/com/scalar/db/schemaloader/SchemaLoaderTest.java @@ -916,8 +916,6 @@ public void tearDown() throws Exception { } } - // For backward compatibility with the old method signatures. - @Test public void load_WithConfigFileAndSchemaFileWithCreateCoordinatorTables_ShouldCallParserAndOperatorProperly()