|
19 | 19 | package org.apache.cayenne.project; |
20 | 20 |
|
21 | 21 | import org.apache.cayenne.configuration.ConfigurationNameMapper; |
| 22 | +import org.apache.cayenne.configuration.ConfigurationNodeVisitor; |
22 | 23 | import org.apache.cayenne.configuration.ConfigurationTree; |
23 | 24 | import org.apache.cayenne.configuration.DataChannelDescriptor; |
24 | 25 | import org.apache.cayenne.configuration.DataNodeDescriptor; |
|
27 | 28 | import org.apache.cayenne.di.Injector; |
28 | 29 | import org.apache.cayenne.di.Module; |
29 | 30 | import org.apache.cayenne.map.DataMap; |
| 31 | +import org.apache.cayenne.project.extension.BaseSaverDelegate; |
| 32 | +import org.apache.cayenne.project.extension.LoaderDelegate; |
30 | 33 | import org.apache.cayenne.project.extension.ProjectExtension; |
| 34 | +import org.apache.cayenne.project.extension.SaverDelegate; |
31 | 35 | import org.apache.cayenne.resource.URLResource; |
32 | 36 | import org.junit.jupiter.api.BeforeEach; |
33 | 37 | import org.junit.jupiter.api.Test; |
|
43 | 47 | import java.net.URL; |
44 | 48 | import java.util.Arrays; |
45 | 49 | import java.util.Collections; |
| 50 | +import java.util.List; |
46 | 51 |
|
47 | 52 | import static org.junit.jupiter.api.Assertions.assertEquals; |
48 | 53 | import static org.junit.jupiter.api.Assertions.assertTrue; |
@@ -135,6 +140,30 @@ private void assertSaveAs_Sorted(File file) throws Exception { |
135 | 140 | assertEquals("C", xpath.evaluate("@name", mapRefs.item(2))); |
136 | 141 | } |
137 | 142 |
|
| 143 | + @Test |
| 144 | + public void extensionsAreSortedByOrder() { |
| 145 | + ProjectExtension ext10 = stubExtension(10); |
| 146 | + ProjectExtension ext20 = stubExtension(20); |
| 147 | + ProjectExtension ext30 = stubExtension(30); |
| 148 | + |
| 149 | + // supply in reverse order — saver must still store them sorted ascending |
| 150 | + FileProjectSaver s1 = new FileProjectSaver(List.of(ext30, ext20, ext10)); |
| 151 | + assertEquals(List.of(ext10, ext20, ext30), s1.extensions); |
| 152 | + |
| 153 | + // supply in random order |
| 154 | + FileProjectSaver s2 = new FileProjectSaver(List.of(ext20, ext10, ext30)); |
| 155 | + assertEquals(List.of(ext10, ext20, ext30), s2.extensions); |
| 156 | + } |
| 157 | + |
| 158 | + private static ProjectExtension stubExtension(int order) { |
| 159 | + return new ProjectExtension() { |
| 160 | + @Override public LoaderDelegate createLoaderDelegate() { return null; } |
| 161 | + @Override public SaverDelegate createSaverDelegate() { return new BaseSaverDelegate(); } |
| 162 | + @Override public ConfigurationNodeVisitor<String> createNamingDelegate() { return null; } |
| 163 | + @Override public int order() { return order; } |
| 164 | + }; |
| 165 | + } |
| 166 | + |
138 | 167 | /** |
139 | 168 | * Regression test for CAY-1780: relative fragments (e.g. ./../) in target |
140 | 169 | * file path must be resolved correctly. |
|
0 commit comments