Skip to content

Commit 1df6747

Browse files
authored
Fixes API for lder version without BuildTools, adds tests for API v5 (#442)
* Fixes API for lder version without BuildTools, adds tests for API v5 * Enforces a speicif Maven version for Github CI
1 parent 0ccf8b3 commit 1df6747

File tree

14 files changed

+251
-45
lines changed

14 files changed

+251
-45
lines changed

.github/workflows/main.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,51 @@ env:
3030
GRADLE_USER_HOME: ~/.gradle
3131

3232
jobs:
33+
run-units:
34+
name: API MicroProfile Starter
35+
runs-on: ubuntu-20.04
36+
steps:
37+
- uses: actions/checkout@v2
38+
with:
39+
fetch-depth: 1
40+
- uses: actions/cache@v2
41+
with:
42+
path: ~/.m2/repository
43+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
44+
restore-keys: |
45+
${{ runner.os }}-maven-
46+
- uses: actions/cache@v2
47+
with:
48+
path: |
49+
~/.gradle/caches
50+
~/.gradle/wrapper
51+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
52+
restore-keys: |
53+
${{ runner.os }}-gradle-
54+
- uses: actions/setup-java@v2
55+
with:
56+
distribution: 'adopt'
57+
java-version: '11'
58+
check-latest: true
59+
- name: Set up Maven
60+
uses: stCarolas/[email protected]
61+
with:
62+
maven-version: 3.6.3
63+
- name: Build and run tests for Starter
64+
run: |
65+
mvn --version
66+
java --version
67+
mvn clean verify -Pthorntail -Dtest=APITest -DSTARTER_TS_WORKSPACE=$RUNNER_TEMP
68+
- name: Prepare failure archive (if maven failed)
69+
if: failure()
70+
shell: bash
71+
run: find . -type d -name '*-reports' -o -name "*.log" | tar -czf test-reports-apitest.tgz -T -
72+
- name: Upload failure Archive (if maven failed)
73+
uses: actions/upload-artifact@v2
74+
if: failure()
75+
with:
76+
name: test-reports-apitest
77+
path: 'test-reports-apitest.tgz'
3378
run-starter:
3479
name: ${{ matrix.runtime }} MicroProfile Starter
3580
runs-on: ubuntu-20.04
@@ -67,8 +112,14 @@ jobs:
67112
distribution: 'adopt'
68113
java-version: '11'
69114
check-latest: true
115+
- name: Set up Maven
116+
uses: stCarolas/[email protected]
117+
with:
118+
maven-version: 3.6.3
70119
- name: Build and run tests for Starter
71120
run: |
121+
mvn --version
122+
java --version
72123
mvn clean verify -Pthorntail -Dtest=TestMatrixTest#${{ matrix.runtime }}* -DSTARTER_TS_WORKSPACE=$RUNNER_TEMP
73124
- name: Prepare failure archive (if maven failed)
74125
if: failure()

src/it/java/org/eclipse/microprofile/starter/APITest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,16 @@
4545
*/
4646
@RunWith(Arquillian.class)
4747
@DefaultDeployment(type = DefaultDeployment.Type.WAR)
48-
public class APITest {
48+
public class APITest {
4949

5050
public static final String API_URL = "http://127.0.0.1:9090/api";
5151
final Client client = ClientBuilder.newBuilder().build();
5252

5353
private WebTarget target;
54+
private File v6Matrix;
55+
private File v6MatrixServers;
56+
private File v5Matrix;
57+
private File v5MatrixServers;
5458
private File v4Matrix;
5559
private File v4MatrixServers;
5660
private File v3Matrix;
@@ -59,6 +63,10 @@ public class APITest {
5963
@Before
6064
public void before() {
6165
target = client.target(API_URL);
66+
v6Matrix = new File(getClass().getClassLoader().getResource("json_examples/v6/supportMatrix.json.segments").getFile());
67+
v6MatrixServers = new File(getClass().getClassLoader().getResource("json_examples/v6/supportMatrix_servers.json.segments").getFile());
68+
v5Matrix = new File(getClass().getClassLoader().getResource("json_examples/v5/supportMatrix.json.segments").getFile());
69+
v5MatrixServers = new File(getClass().getClassLoader().getResource("json_examples/v5/supportMatrix_servers.json.segments").getFile());
6270
v4Matrix = new File(getClass().getClassLoader().getResource("json_examples/v4/supportMatrix.json.segments").getFile());
6371
v4MatrixServers = new File(getClass().getClassLoader().getResource("json_examples/v4/supportMatrix_servers.json.segments").getFile());
6472
v3Matrix = new File(getClass().getClassLoader().getResource("json_examples/v3/supportMatrix.json.segments").getFile());
@@ -79,6 +87,10 @@ public void test(File segments, String uri) throws FileNotFoundException {
7987
@Test
8088
@RunAsClient
8189
public void supportMatrix() throws FileNotFoundException {
90+
test(v6Matrix, "/6/supportMatrix");
91+
test(v6MatrixServers, "/6/supportMatrix/servers");
92+
test(v5Matrix, "/5/supportMatrix");
93+
test(v5MatrixServers, "/5/supportMatrix/servers");
8294
test(v4Matrix, "/4/supportMatrix");
8395
test(v4MatrixServers, "/4/supportMatrix/servers");
8496
test(v3Matrix, "/3/supportMatrix");

src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV2.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,13 @@ public Response getProject(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNone
7171
public Response projectPost(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch, @NotNull Project body) {
7272
return api.getProjectV1(ifNoneMatch, body);
7373
}
74+
75+
// The same as V3
76+
@Path("/supportMatrix/servers")
77+
@GET
78+
@Produces({"application/json"})
79+
@Override
80+
public Response supportMatrixServers(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
81+
return api.supportMatrixServersV3(ifNoneMatch);
82+
}
7483
}

src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV3.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@
1919
*/
2020
package org.eclipse.microprofile.starter.rest;
2121

22+
import org.eclipse.microprofile.starter.addon.microprofile.servers.model.SupportedServer;
23+
import org.eclipse.microprofile.starter.core.model.JavaSEVersion;
24+
import org.eclipse.microprofile.starter.core.model.MicroProfileVersion;
25+
2226
import javax.inject.Inject;
2327
import javax.ws.rs.GET;
2428
import javax.ws.rs.HeaderParam;
2529
import javax.ws.rs.Path;
2630
import javax.ws.rs.Produces;
31+
import javax.ws.rs.QueryParam;
2732
import javax.ws.rs.core.HttpHeaders;
2833
import javax.ws.rs.core.Response;
34+
import java.util.List;
2935

3036
/**
3137
* @author Michal Karm Babacek <[email protected]>
@@ -44,4 +50,25 @@ public Response supportMatrixServers(@HeaderParam(HttpHeaders.IF_NONE_MATCH) Str
4450
return api.supportMatrixServersV3(ifNoneMatch);
4551
}
4652

53+
// The same as V5
54+
@Path("/project")
55+
@GET
56+
@Produces({"application/zip", "application/json"})
57+
public Response getProject(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch,
58+
@QueryParam("supportedServer") SupportedServer supportedServer,
59+
@QueryParam("groupId") String groupId,
60+
@QueryParam("artifactId") String artifactId,
61+
@QueryParam("mpVersion") MicroProfileVersion mpVersion,
62+
@QueryParam("javaSEVersion") JavaSEVersion javaSEVersion,
63+
@QueryParam("selectedSpecs") List<String> selectedSpecCodes,
64+
@QueryParam("selectAllSpecs") boolean selectAllSpecs) {
65+
return api.getProjectV5(ifNoneMatch,
66+
supportedServer,
67+
groupId,
68+
artifactId,
69+
mpVersion,
70+
javaSEVersion,
71+
selectedSpecCodes,
72+
selectAllSpecs);
73+
}
4774
}

src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV4.java

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,55 @@
1919
*/
2020
package org.eclipse.microprofile.starter.rest;
2121

22+
import org.eclipse.microprofile.starter.addon.microprofile.servers.model.SupportedServer;
23+
import org.eclipse.microprofile.starter.core.model.JavaSEVersion;
24+
import org.eclipse.microprofile.starter.core.model.MicroProfileVersion;
25+
26+
import javax.inject.Inject;
27+
import javax.ws.rs.GET;
28+
import javax.ws.rs.HeaderParam;
2229
import javax.ws.rs.Path;
30+
import javax.ws.rs.Produces;
31+
import javax.ws.rs.QueryParam;
32+
import javax.ws.rs.core.HttpHeaders;
33+
import javax.ws.rs.core.Response;
34+
import java.util.List;
2335

2436
/**
2537
* @author Michal Karm Babacek <[email protected]>
2638
*/
2739
@Path("/4")
2840
public class APIEndpointV4 extends APIEndpointLatest {
41+
@Inject
42+
private APIService api;
43+
44+
// The same as V5
45+
@Path("/project")
46+
@GET
47+
@Produces({"application/zip", "application/json"})
48+
public Response getProject(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch,
49+
@QueryParam("supportedServer") SupportedServer supportedServer,
50+
@QueryParam("groupId") String groupId,
51+
@QueryParam("artifactId") String artifactId,
52+
@QueryParam("mpVersion") MicroProfileVersion mpVersion,
53+
@QueryParam("javaSEVersion") JavaSEVersion javaSEVersion,
54+
@QueryParam("selectedSpecs") List<String> selectedSpecCodes,
55+
@QueryParam("selectAllSpecs") boolean selectAllSpecs) {
56+
return api.getProjectV5(ifNoneMatch,
57+
supportedServer,
58+
groupId,
59+
artifactId,
60+
mpVersion,
61+
javaSEVersion,
62+
selectedSpecCodes,
63+
selectAllSpecs);
64+
}
2965

30-
// Does not differ from latest in anything.
66+
@Path("/supportMatrix/servers")
67+
@GET
68+
@Produces({"application/json"})
69+
public Response supportMatrixServers(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
70+
return api.supportMatrixServersV5(ifNoneMatch);
71+
}
3172

3273
}

src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV5.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,17 @@
2020
package org.eclipse.microprofile.starter.rest;
2121

2222
import org.eclipse.microprofile.starter.addon.microprofile.servers.model.SupportedServer;
23-
import org.eclipse.microprofile.starter.core.model.BuildTool;
2423
import org.eclipse.microprofile.starter.core.model.JavaSEVersion;
2524
import org.eclipse.microprofile.starter.core.model.MicroProfileVersion;
2625

2726
import javax.inject.Inject;
28-
import javax.ws.rs.core.HttpHeaders;
29-
import javax.ws.rs.core.Response;
3027
import javax.ws.rs.GET;
3128
import javax.ws.rs.HeaderParam;
3229
import javax.ws.rs.Path;
3330
import javax.ws.rs.Produces;
3431
import javax.ws.rs.QueryParam;
32+
import javax.ws.rs.core.HttpHeaders;
33+
import javax.ws.rs.core.Response;
3534
import java.util.List;
3635

3736
/**
@@ -54,16 +53,20 @@ public Response getProject(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNone
5453
@QueryParam("javaSEVersion") JavaSEVersion javaSEVersion,
5554
@QueryParam("selectedSpecs") List<String> selectedSpecCodes,
5655
@QueryParam("selectAllSpecs") boolean selectAllSpecs) {
57-
return api.getProject(ifNoneMatch,
56+
return api.getProjectV5(ifNoneMatch,
5857
supportedServer,
5958
groupId,
6059
artifactId,
6160
mpVersion,
6261
javaSEVersion,
63-
BuildTool.MAVEN,
6462
selectedSpecCodes,
6563
selectAllSpecs);
6664
}
6765

68-
66+
@Path("/supportMatrix/servers")
67+
@GET
68+
@Produces({"application/json"})
69+
public Response supportMatrixServers(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
70+
return api.supportMatrixServersV5(ifNoneMatch);
71+
}
6972
}

src/main/java/org/eclipse/microprofile/starter/rest/APIEndpointV6.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,12 @@
1919
*/
2020
package org.eclipse.microprofile.starter.rest;
2121

22-
import javax.inject.Inject;
23-
import javax.ws.rs.GET;
24-
import javax.ws.rs.HeaderParam;
2522
import javax.ws.rs.Path;
26-
import javax.ws.rs.Produces;
27-
import javax.ws.rs.core.HttpHeaders;
28-
import javax.ws.rs.core.Response;
2923

3024
/**
3125
*
3226
*/
3327
@Path("/6")
3428
public class APIEndpointV6 extends APIEndpointLatest {
35-
36-
@Inject
37-
private APIService api;
38-
39-
@Path("/supportMatrix/servers")
40-
@GET
41-
@Produces({"application/json"})
42-
public Response supportMatrixServers(@HeaderParam(HttpHeaders.IF_NONE_MATCH) String ifNoneMatch) {
43-
return api.supportMatrixServersv6(ifNoneMatch);
44-
}
45-
46-
47-
29+
// The current latest version
4830
}

0 commit comments

Comments
 (0)