Skip to content

Commit b053e85

Browse files
committed
Add the remaining API entrypoints
1 parent b323bb8 commit b053e85

File tree

21 files changed

+1493
-15
lines changed

21 files changed

+1493
-15
lines changed

net.adoptopenjdk.v3.api/src/main/java/net/adoptopenjdk/v3/api/AOV3APICallsType.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,59 @@ AOV3RequestAssetsForReleaseType assetsForRelease(
9494
Optional<AOV3SortOrder> sortOrder,
9595
Optional<AOV3Vendor> vendor
9696
);
97+
98+
/**
99+
* @param errorReceiver A receiver of errors encountered during the API call
100+
*
101+
* @return An executable request
102+
*
103+
* @see "https://api.adoptopenjdk.net/swagger-ui/#/Assets/get_v3_assets_latest__feature_version___jvm_impl_"
104+
*/
105+
106+
AOV3RequestAssetsForLatestType assetsForLatest(
107+
Consumer<AOV3Error> errorReceiver,
108+
BigInteger version,
109+
AOV3JVMImplementation jvmImplementation
110+
);
111+
112+
/**
113+
* @param errorReceiver A receiver of errors encountered during the API call
114+
*
115+
* @return An executable request
116+
*
117+
* @see "https://api.adoptopenjdk.net/swagger-ui/#/Binary/get_v3_binary_latest__feature_version___release_type___os___arch___image_type___jvm_impl___heap_size___vendor_"
118+
*/
119+
120+
AOV3RequestBinaryForLatestType binaryForLatest(
121+
Consumer<AOV3Error> errorReceiver,
122+
AOV3Architecture architecture,
123+
BigInteger version,
124+
AOV3HeapSize heapSize,
125+
AOV3ImageKind imageKind,
126+
AOV3JVMImplementation jvmImplementation,
127+
AOV3OperatingSystem operatingSystem,
128+
AOV3ReleaseKind releaseKind,
129+
AOV3Vendor vendor,
130+
Optional<String> project
131+
);
132+
133+
/**
134+
* @param errorReceiver A receiver of errors encountered during the API call
135+
*
136+
* @return An executable request
137+
*
138+
* @see "https://api.adoptopenjdk.net/swagger-ui/#/Binary/get_v3_binary_version__release_name___os___arch___image_type___jvm_impl___heap_size___vendor_"
139+
*/
140+
141+
AOV3RequestBinaryForReleaseType binaryForRelease(
142+
Consumer<AOV3Error> errorReceiver,
143+
String releaseName,
144+
AOV3OperatingSystem operatingSystem,
145+
AOV3Architecture architecture,
146+
AOV3ImageKind imageKind,
147+
AOV3JVMImplementation jvmImplementation,
148+
AOV3HeapSize heapSize,
149+
AOV3Vendor vendor,
150+
Optional<String> project
151+
);
97152
}

net.adoptopenjdk.v3.api/src/main/java/net/adoptopenjdk/v3/api/AOV3JVMImplementation.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
import java.util.Objects;
1818

19+
/**
20+
* A JVM implementation such as Hotspot, OpenJ9, etc.
21+
*/
22+
1923
public enum AOV3JVMImplementation implements AOV3HasNameTextType
2024
{
2125
HOTSPOT("hotspot"),
@@ -39,14 +43,7 @@ public enum AOV3JVMImplementation implements AOV3HasNameTextType
3943
public static AOV3JVMImplementation of(
4044
final String jvmImplementation)
4145
{
42-
switch (jvmImplementation) {
43-
case "hotspot":
44-
return HOTSPOT;
45-
case "openj9":
46-
return OPENJ9;
47-
default:
48-
throw new IllegalStateException("Unexpected value: " + jvmImplementation);
49-
}
46+
return valueOf(jvmImplementation.toUpperCase());
5047
}
5148

5249
@Override
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright © 2020 Mark Raynsford <code@io7m.com> http://io7m.com
3+
*
4+
* Permission to use, copy, modify, and/or distribute this software for any
5+
* purpose with or without fee is hereby granted, provided that the above
6+
* copyright notice and this permission notice appear in all copies.
7+
*
8+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9+
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10+
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11+
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12+
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13+
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
14+
* IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15+
*/
16+
17+
package net.adoptopenjdk.v3.api;
18+
19+
import com.io7m.immutables.styles.ImmutablesStyleType;
20+
import org.immutables.value.Value;
21+
22+
/**
23+
* @see "https://api.adoptopenjdk.net/swagger-ui/#/Assets/get_v3_assets_feature_releases__feature_version___release_type_"
24+
*/
25+
26+
@ImmutablesStyleType
27+
@Value.Immutable
28+
public interface AOV3ListBinaryAssetViewType
29+
{
30+
/**
31+
* @return Information about the binary
32+
*/
33+
34+
AOV3Binary binary();
35+
36+
/**
37+
* @return The name of the release
38+
*/
39+
40+
String releaseName();
41+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
package net.adoptopenjdk.v3.api;
16+
17+
import java.util.List;
18+
19+
/**
20+
* @see "https://api.adoptopenjdk.net/swagger-ui/#/Assets/get_v3_assets_latest__feature_version___jvm_impl_"
21+
*/
22+
23+
public interface AOV3RequestAssetsForLatestType
24+
extends AOV3RequestType<List<AOV3ListBinaryAssetView>>
25+
{
26+
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
package net.adoptopenjdk.v3.api;
16+
17+
import java.net.URI;
18+
19+
/**
20+
* @see "https://api.adoptopenjdk.net/swagger-ui/#/Binary/get_v3_binary_latest__feature_version___release_type___os___arch___image_type___jvm_impl___heap_size___vendor_"
21+
*/
22+
23+
public interface AOV3RequestBinaryForLatestType
24+
extends AOV3RequestType<URI>
25+
{
26+
27+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
package net.adoptopenjdk.v3.api;
16+
17+
import java.net.URI;
18+
19+
/**
20+
* @see "https://api.adoptopenjdk.net/swagger-ui/#/Binary/get_v3_binary_version__release_name___os___arch___image_type___jvm_impl___heap_size___vendor_"
21+
*/
22+
23+
public interface AOV3RequestBinaryForReleaseType
24+
extends AOV3RequestType<URI>
25+
{
26+
27+
}

net.adoptopenjdk.v3.tests/src/test/java/net/adoptopenjdk/v3/tests/AOV3ClientsIntegrationTest.java

Lines changed: 114 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,120 @@ public void testAssetsForReleaseFiltered()
163163
Optional.of(AOV3Vendor.ADOPT_OPENJDK)
164164
);
165165

166-
final var releases = request.execute();
167-
LOG.debug("releases: {}", Integer.valueOf(releases.size()));
168-
LOG.debug("releases: {}", releases);
166+
final var assets = request.execute();
167+
LOG.debug("assets: {}", Integer.valueOf(assets.size()));
168+
LOG.debug("assets: {}", assets);
169+
}
170+
}
171+
172+
@Test
173+
public void testAssetsForLatest()
174+
throws Exception
175+
{
176+
try (var client = this.clients.createClient()) {
177+
final var request = client.assetsForLatest(
178+
this::logError,
179+
BigInteger.valueOf(11L),
180+
AOV3JVMImplementation.HOTSPOT
181+
);
182+
183+
final var assets = request.execute();
184+
LOG.debug("assets: {}", Integer.valueOf(assets.size()));
185+
LOG.debug("assets: {}", assets);
186+
}
187+
}
188+
189+
@Test
190+
public void testBinaryForLatest()
191+
throws Exception
192+
{
193+
try (var client = this.clients.createClient()) {
194+
final var request =
195+
client.binaryForLatest(
196+
this::logError,
197+
AOV3Architecture.X64,
198+
BigInteger.valueOf(11L),
199+
AOV3HeapSize.NORMAL,
200+
AOV3ImageKind.JDK,
201+
AOV3JVMImplementation.HOTSPOT,
202+
AOV3OperatingSystem.LINUX,
203+
AOV3ReleaseKind.GENERAL_AVAILABILITY,
204+
AOV3Vendor.ADOPT_OPENJDK,
205+
Optional.empty()
206+
);
207+
208+
final var uri = request.execute();
209+
LOG.debug("uri: {}", uri);
210+
}
211+
}
212+
213+
@Test
214+
public void testBinaryForLatestWithProject()
215+
throws Exception
216+
{
217+
try (var client = this.clients.createClient()) {
218+
final var request =
219+
client.binaryForLatest(
220+
this::logError,
221+
AOV3Architecture.X64,
222+
BigInteger.valueOf(11L),
223+
AOV3HeapSize.NORMAL,
224+
AOV3ImageKind.JDK,
225+
AOV3JVMImplementation.HOTSPOT,
226+
AOV3OperatingSystem.LINUX,
227+
AOV3ReleaseKind.GENERAL_AVAILABILITY,
228+
AOV3Vendor.ADOPT_OPENJDK,
229+
Optional.of("jdk")
230+
);
231+
232+
final var uri = request.execute();
233+
LOG.debug("uri: {}", uri);
234+
}
235+
}
236+
237+
@Test
238+
public void testBinaryForRelease()
239+
throws Exception
240+
{
241+
try (var client = this.clients.createClient()) {
242+
final var request =
243+
client.binaryForRelease(
244+
this::logError,
245+
"jdk-11.0.6+10",
246+
AOV3OperatingSystem.LINUX,
247+
AOV3Architecture.X64,
248+
AOV3ImageKind.JDK,
249+
AOV3JVMImplementation.HOTSPOT,
250+
AOV3HeapSize.NORMAL,
251+
AOV3Vendor.ADOPT_OPENJDK,
252+
Optional.empty()
253+
);
254+
255+
final var uri = request.execute();
256+
LOG.debug("uri: {}", uri);
257+
}
258+
}
259+
260+
@Test
261+
public void testBinaryForReleaseWithProject()
262+
throws Exception
263+
{
264+
try (var client = this.clients.createClient()) {
265+
final var request =
266+
client.binaryForRelease(
267+
this::logError,
268+
"jdk-11.0.6+10",
269+
AOV3OperatingSystem.LINUX,
270+
AOV3Architecture.X64,
271+
AOV3ImageKind.JDK,
272+
AOV3JVMImplementation.HOTSPOT,
273+
AOV3HeapSize.NORMAL,
274+
AOV3Vendor.ADOPT_OPENJDK,
275+
Optional.of("jdk")
276+
);
277+
278+
final var uri = request.execute();
279+
LOG.debug("uri: {}", uri);
169280
}
170281
}
171282
}

net.adoptopenjdk.v3.tests/src/test/java/net/adoptopenjdk/v3/tests/AOV3ClientsTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ public void testRequestFailure0()
8787
final var headers =
8888
HttpHeaders.of(Map.of(), (key, val) -> true);
8989

90+
Mockito.when(this.client.followRedirects())
91+
.thenReturn(HttpClient.Redirect.NEVER);
9092
Mockito.when(this.client.send(Mockito.any(), Mockito.any()))
9193
.thenReturn(this.response);
9294
Mockito.when(Integer.valueOf(this.response.statusCode()))

net.adoptopenjdk.v3.tests/src/test/java/net/adoptopenjdk/v3/tests/AOV3ResponseParsersTest.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,28 @@ public Stream<DynamicTest> testAssetsForReleaseFuzz()
252252
});
253253
}
254254

255+
@Test
256+
public void testAssetsForLatest()
257+
throws Exception
258+
{
259+
final var stream = resource("assetsForLatest.json");
260+
final var parser =
261+
this.parsers.createParser(this::logError, URI.create("urn:test"), stream);
262+
final var assets = parser.parseAssetsForLatest();
263+
264+
{
265+
final var release = assets.get(0);
266+
Assertions.assertEquals("jdk-11.0.6+10", release.releaseName());
267+
}
268+
269+
{
270+
final var release = assets.get(25);
271+
Assertions.assertEquals("jdk-11.0.6+10", release.releaseName());
272+
}
273+
274+
Assertions.assertEquals(0, this.errors.size());
275+
}
276+
255277
private void testAssetsForReleaseFuzzOnce(
256278
final Integer index)
257279
throws Exception

0 commit comments

Comments
 (0)