// Path: src/test/java/com/mageddo/config/DatabaseConfigurator.java
// @Singleton
// public class DatabaseConfigurator {
// 
//   private static boolean migrated = false;
// 
//   private final Logger logger = LoggerFactory.getLogger(getClass());
//   private final NamedParameterJdbcTemplate namedJdbcTemplate;
//   private final PlatformTransactionManager platformTransactionManager;
//   private final Environment environment;
// 
//   public DatabaseConfigurator(NamedParameterJdbcTemplate namedJdbcTemplate,
//       PlatformTransactionManager platformTransactionManager, Environment environment) {
//     this.namedJdbcTemplate = namedJdbcTemplate;
//     this.platformTransactionManager = platformTransactionManager;
//     this.environment = environment;
//   }
// 
//   public void migrate() {
//     if (!migrated) {
//       final Flyway flyway = MigrationUtils.getFlyway(environment);
//       flyway.clean();
//       flyway.migrate();
//       migrated = true;
//     }
//     new TransactionTemplate(platformTransactionManager).execute((st) -> {
//       logger.info("status=schema-truncating");
//       final StringBuilder sql = new StringBuilder().append("SELECT  \n")
//           .append("	CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) \n")
//           .append("FROM INFORMATION_SCHEMA.TABLES \n")
//           .append("WHERE TABLE_SCHEMA = CURRENT_SCHEMA() \n")
//           .append("AND TABLE_NAME NOT IN (:tables) \n")
//           .append("ORDER BY TABLE_NAME \n");
//       final List<String> tables = namedJdbcTemplate.query(sql.toString(), Maps.of("tables", skipTables()),
//           (rs, i) -> rs.getString(1)
//       );
//       namedJdbcTemplate.update("SET CONSTRAINTS ALL DEFERRED", Maps.of());
//       for (final String table : tables) {
//         namedJdbcTemplate.update("DELETE FROM " + table, Maps.of());
//       }
//       namedJdbcTemplate.update("SET CONSTRAINTS ALL IMMEDIATE", Maps.of());
//       logger.info("status=schema-truncated");
//       try {
//         namedJdbcTemplate.update(TestUtils.readAsString("/db/base-data.sql"), Maps.of());
//       } catch (Exception e) {
//         logger.error("status=cant-run-base-data", e);
//         throw new RuntimeException(e);
//       }
//       logger.info("status=base-data-executed");
//       return null;
//     });
//   }
// 
//   public Collection<String> skipTables() {
//     return Arrays.asList("flyway_schema_history".toLowerCase(), "system_property".toLowerCase());
//   }
// 
// }
// 
// Path: src/test/java/com/mageddo/config/TestUtils.java
// public static void setupRestAssured(EmbeddedServer server) {
//   RestAssured.port = server.getPort();
//   RestAssured.port = server.getPort();
//   RestAssured.baseURI = String.format("%s://%s", server.getScheme(), server.getHost());
// }


import java.io.IOException;
import javax.inject.Inject;
import com.mageddo.common.jackson.JsonUtils;
import com.mageddo.config.DatabaseConfigurator;
import com.mageddo.rawstringliterals.RawString;
import com.mageddo.rawstringliterals.Rsl;
import org.json.JSONException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.skyscreamer.jsonassert.comparator.DefaultComparator;
import org.skyscreamer.jsonassert.comparator.JSONComparator;
import io.micronaut.http.MediaType;
import io.micronaut.runtime.server.EmbeddedServer;
import io.micronaut.test.annotation.MicronautTest;
import io.restassured.response.Response;
import static com.mageddo.config.TestUtils.setupRestAssured;
import static com.mageddo.rawstringliterals.RawStrings.lateInit;
import static io.micronaut.http.HttpStatus.NOT_FOUND;
import static io.micronaut.http.HttpStatus.OK;
import static io.restassured.RestAssured.get;
import static io.restassured.RestAssured.given;
import static org.hamcrest.text.IsEmptyString.emptyOrNullString;
import static org.skyscreamer.jsonassert.JSONAssert.assertEquals;
package com.mageddo.bookmarks.apiserver;







@Rsl
@MicronautTest(environments = "pg")
class SettingsControllerIntTest {

  private static final JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
  @Inject
  private EmbeddedServer server;
  @Inject
// Path: src/test/java/com/mageddo/config/DatabaseConfigurator.java
// @Singleton
// public class DatabaseConfigurator {
// 
//   private static boolean migrated = false;
// 
//   private final Logger logger = LoggerFactory.getLogger(getClass());
//   private final NamedParameterJdbcTemplate namedJdbcTemplate;
//   private final PlatformTransactionManager platformTransactionManager;
//   private final Environment environment;
// 
//   public DatabaseConfigurator(NamedParameterJdbcTemplate namedJdbcTemplate,
//       PlatformTransactionManager platformTransactionManager, Environment environment) {
//     this.namedJdbcTemplate = namedJdbcTemplate;
//     this.platformTransactionManager = platformTransactionManager;
//     this.environment = environment;
//   }
// 
//   public void migrate() {
//     if (!migrated) {
//       final Flyway flyway = MigrationUtils.getFlyway(environment);
//       flyway.clean();
//       flyway.migrate();
//       migrated = true;
//     }
//     new TransactionTemplate(platformTransactionManager).execute((st) -> {
//       logger.info("status=schema-truncating");
//       final StringBuilder sql = new StringBuilder().append("SELECT  \n")
//           .append("	CONCAT(TABLE_SCHEMA, '.', TABLE_NAME) \n")
//           .append("FROM INFORMATION_SCHEMA.TABLES \n")
//           .append("WHERE TABLE_SCHEMA = CURRENT_SCHEMA() \n")
//           .append("AND TABLE_NAME NOT IN (:tables) \n")
//           .append("ORDER BY TABLE_NAME \n");
//       final List<String> tables = namedJdbcTemplate.query(sql.toString(), Maps.of("tables", skipTables()),
//           (rs, i) -> rs.getString(1)
//       );
//       namedJdbcTemplate.update("SET CONSTRAINTS ALL DEFERRED", Maps.of());
//       for (final String table : tables) {
//         namedJdbcTemplate.update("DELETE FROM " + table, Maps.of());
//       }
//       namedJdbcTemplate.update("SET CONSTRAINTS ALL IMMEDIATE", Maps.of());
//       logger.info("status=schema-truncated");
//       try {
//         namedJdbcTemplate.update(TestUtils.readAsString("/db/base-data.sql"), Maps.of());
//       } catch (Exception e) {
//         logger.error("status=cant-run-base-data", e);
//         throw new RuntimeException(e);
//       }
//       logger.info("status=base-data-executed");
//       return null;
//     });
//   }
// 
//   public Collection<String> skipTables() {
//     return Arrays.asList("flyway_schema_history".toLowerCase(), "system_property".toLowerCase());
//   }
// 
// }
// 
// Path: src/test/java/com/mageddo/config/TestUtils.java
// public static void setupRestAssured(EmbeddedServer server) {
//   RestAssured.port = server.getPort();
//   RestAssured.port = server.getPort();
//   RestAssured.baseURI = String.format("%s://%s", server.getScheme(), server.getHost());
// }


// Path: src/test/java/com/mageddo/bookmarks/apiserver/SettingsControllerIntTest.java
import java.io.IOException;
import javax.inject.Inject;
import com.mageddo.common.jackson.JsonUtils;
import com.mageddo.config.DatabaseConfigurator;
import com.mageddo.rawstringliterals.RawString;
import com.mageddo.rawstringliterals.Rsl;
import org.json.JSONException;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONCompareMode;
import org.skyscreamer.jsonassert.comparator.DefaultComparator;
import org.skyscreamer.jsonassert.comparator.JSONComparator;
import io.micronaut.http.MediaType;
import io.micronaut.runtime.server.EmbeddedServer;
import io.micronaut.test.annotation.MicronautTest;
import io.restassured.response.Response;
import static com.mageddo.config.TestUtils.setupRestAssured;
import static com.mageddo.rawstringliterals.RawStrings.lateInit;
import static io.micronaut.http.HttpStatus.NOT_FOUND;
import static io.micronaut.http.HttpStatus.OK;
import static io.restassured.RestAssured.get;
import static io.restassured.RestAssured.given;
import static org.hamcrest.text.IsEmptyString.emptyOrNullString;
import static org.skyscreamer.jsonassert.JSONAssert.assertEquals;

package com.mageddo.bookmarks.apiserver;







@Rsl
@MicronautTest(environments = "pg")
class SettingsControllerIntTest {

  private static final JSONComparator comparator = new DefaultComparator(JSONCompareMode.LENIENT);
  @Inject
  private EmbeddedServer server;
  @Inject
  private DatabaseConfigurator databaseConfigurator;