|
| 1 | +/* |
| 2 | + * Copyright © 2024 XDEV Software (https://xdev.software) |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package software.xdev.spring.data.eclipse.store.integration.isolated.tests.data.migration.with.multiple.scripts; |
| 17 | + |
| 18 | +import org.junit.jupiter.api.Assertions; |
| 19 | +import org.junit.jupiter.api.Test; |
| 20 | +import org.springframework.beans.factory.annotation.Autowired; |
| 21 | +import org.springframework.test.context.ContextConfiguration; |
| 22 | + |
| 23 | +import software.xdev.micromigration.version.MigrationVersion; |
| 24 | +import software.xdev.spring.data.eclipse.store.helper.TestUtil; |
| 25 | +import software.xdev.spring.data.eclipse.store.integration.isolated.IsolatedTestAnnotations; |
| 26 | + |
| 27 | + |
| 28 | +@IsolatedTestAnnotations |
| 29 | +@ContextConfiguration(classes = {DataMigrationWithMultipleScriptsTestConfiguration.class}) |
| 30 | +class DataMigrationWithMultipleScriptsTest |
| 31 | +{ |
| 32 | + @Autowired |
| 33 | + private DataMigrationWithMultipleScriptsTestConfiguration configuration; |
| 34 | + @Autowired |
| 35 | + private PersistedEntityRepository repository; |
| 36 | + |
| 37 | + @Test |
| 38 | + void assertUpdateV1Executed() |
| 39 | + { |
| 40 | + Assertions.assertEquals(2, this.repository.count()); |
| 41 | + Assertions.assertEquals( |
| 42 | + new MigrationVersion(1, 1, 0), |
| 43 | + this.configuration.getStorageInstance().getRoot().getDataVersion().getVersion()); |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + void assertNotUpdatedAfterMigration() |
| 48 | + { |
| 49 | + TestUtil.doBeforeAndAfterRestartOfDatastore( |
| 50 | + this.configuration, |
| 51 | + () -> { |
| 52 | + Assertions.assertEquals(2, this.repository.count()); |
| 53 | + Assertions.assertEquals( |
| 54 | + new MigrationVersion(1, 1, 0), |
| 55 | + this.configuration.getStorageInstance().getRoot().getDataVersion().getVersion()); |
| 56 | + } |
| 57 | + ); |
| 58 | + } |
| 59 | +} |
0 commit comments