Skip to content

Commit

Permalink
Fix spotless errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lbestatlas committed Oct 17, 2024
1 parent 8eec176 commit 27a9355
Showing 1 changed file with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
/*
* Copyright 2024 Conductor Authors.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/
package com.netflix.conductor.postgres.config;

import com.netflix.conductor.common.config.TestObjectMapperConfiguration;
import java.util.Arrays;
import java.util.Objects;

import org.flywaydb.core.Flyway;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -14,34 +28,31 @@
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Arrays;
import java.util.Objects;
import com.netflix.conductor.common.config.TestObjectMapperConfiguration;

import static org.junit.Assert.assertTrue;

@ContextConfiguration(
classes = {
TestObjectMapperConfiguration.class,
PostgresConfiguration.class,
FlywayAutoConfiguration.class
TestObjectMapperConfiguration.class,
PostgresConfiguration.class,
FlywayAutoConfiguration.class
})
@RunWith(SpringRunner.class)
@TestPropertySource(
properties = {
"conductor.app.asyncIndexingEnabled=false",
"conductor.elasticsearch.version=0",
"conductor.indexing.type=postgres",
"conductor.postgres.applyDataMigrations=false",
"spring.flyway.clean-disabled=false"
"conductor.app.asyncIndexingEnabled=false",
"conductor.elasticsearch.version=0",
"conductor.indexing.type=postgres",
"conductor.postgres.applyDataMigrations=false",
"spring.flyway.clean-disabled=false"
})
@SpringBootTest
public class PostgresConfigurationDataMigrationTest {

@Autowired
Flyway flyway;
@Autowired Flyway flyway;

@Autowired
ResourcePatternResolver resourcePatternResolver;
@Autowired ResourcePatternResolver resourcePatternResolver;

// clean the database between tests.
@Before
Expand All @@ -52,11 +63,19 @@ public void before() {
@Test
public void dataMigrationIsNotAppliedWhenDisabled() throws Exception {
var files = resourcePatternResolver.getResources("classpath:db/migration_postgres_data/*");
Arrays.stream(flyway.info().applied()).forEach(migrationInfo ->
assertTrue("Data migration wrongly applied: " + migrationInfo.getScript(),
Arrays.stream(files)
.map(Resource::getFilename)
.filter(Objects::nonNull)
.noneMatch(fileName -> fileName.contains(migrationInfo.getScript()))));
Arrays.stream(flyway.info().applied())
.forEach(
migrationInfo ->
assertTrue(
"Data migration wrongly applied: "
+ migrationInfo.getScript(),
Arrays.stream(files)
.map(Resource::getFilename)
.filter(Objects::nonNull)
.noneMatch(
fileName ->
fileName.contains(
migrationInfo
.getScript()))));
}
}

0 comments on commit 27a9355

Please sign in to comment.