1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.repository.metadata;
20
21 import javax.inject.Inject;
22
23 import org.apache.maven.artifact.ArtifactScopeEnum;
24 import org.codehaus.plexus.testing.PlexusTest;
25 import org.junit.jupiter.api.BeforeEach;
26 import org.junit.jupiter.api.Test;
27
28 import static org.junit.jupiter.api.Assertions.assertEquals;
29 import static org.junit.jupiter.api.Assertions.assertNotNull;
30
31
32
33
34
35 @PlexusTest
36 @Deprecated
37 class DefaultClasspathTransformationTestType {
38 @Inject
39 ClasspathTransformation transform;
40
41 MetadataGraph graph;
42
43 MetadataGraphVertex v1;
44 MetadataGraphVertex v2;
45 MetadataGraphVertex v3;
46 MetadataGraphVertex v4;
47
48
49 @BeforeEach
50 void setUp() throws Exception {
51 graph = new MetadataGraph(4, 3);
52
53
54
55
56
57
58 v1 = graph.addVertex(new ArtifactMetadata("g", "a1", "1.0"));
59 graph.setEntry(v1);
60 v2 = graph.addVertex(new ArtifactMetadata("g", "a2", "1.0"));
61 v3 = graph.addVertex(new ArtifactMetadata("g", "a3", "1.0"));
62 v4 = graph.addVertex(new ArtifactMetadata("g", "a4", "1.0"));
63
64
65 graph.addEdge(v1, v2, new MetadataGraphEdge("1.1", true, null, null, 2, 1));
66 graph.addEdge(v1, v2, new MetadataGraphEdge("1.2", true, null, null, 2, 2));
67
68
69 graph.addEdge(v1, v3, new MetadataGraphEdge("1.1", true, null, null, 2, 1));
70 graph.addEdge(v1, v3, new MetadataGraphEdge("1.2", true, null, null, 4, 2));
71
72
73 graph.addEdge(v3, v4, new MetadataGraphEdge("1.1", true, ArtifactScopeEnum.runtime, null, 2, 2));
74 graph.addEdge(v3, v4, new MetadataGraphEdge("1.2", true, ArtifactScopeEnum.test, null, 2, 2));
75 }
76
77
78 @Test
79 void testCompileClasspathTransform() throws Exception {
80 ClasspathContainer res;
81
82 res = transform.transform(graph, ArtifactScopeEnum.compile, false);
83
84 assertNotNull(res, "null classpath container after compile transform");
85 assertNotNull(res.getClasspath(), "null classpath after compile transform");
86 assertEquals(3, res.getClasspath().size(), "compile classpath should have 3 entries");
87 }
88
89
90 @Test
91 void testRuntimeClasspathTransform() throws Exception {
92 ClasspathContainer res;
93
94 res = transform.transform(graph, ArtifactScopeEnum.runtime, false);
95
96 assertNotNull(res, "null classpath container after runtime transform");
97 assertNotNull(res.getClasspath(), "null classpath after runtime transform");
98 assertEquals(4, res.getClasspath().size(), "runtime classpath should have 4 entries");
99
100 ArtifactMetadata md = res.getClasspath().get(3);
101 assertEquals("1.1", md.getVersion(), "runtime artifact version should be 1.1");
102 }
103
104
105 @Test
106 void testTestClasspathTransform() throws Exception {
107 ClasspathContainer res;
108
109 res = transform.transform(graph, ArtifactScopeEnum.test, false);
110
111 assertNotNull(res, "null classpath container after test transform");
112 assertNotNull(res.getClasspath(), "null classpath after test transform");
113 assertEquals(4, res.getClasspath().size(), "test classpath should have 4 entries");
114
115 ArtifactMetadata md = res.getClasspath().get(3);
116 assertEquals("1.2", md.getVersion(), "test artifact version should be 1.2");
117 }
118
119
120 }