Skip to content

Commit 0dcaa98

Browse files
authored
Fix hosting (#172)
* fix hosting. update pom for newer quarkus
1 parent 15604aa commit 0dcaa98

File tree

6 files changed

+80
-114
lines changed

6 files changed

+80
-114
lines changed

pom.xml

Lines changed: 11 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
<groupId>io.quarkus</groupId>
7474
<artifactId>quarkus-smallrye-openapi</artifactId>
7575
</dependency>
76+
<dependency>
77+
<groupId>io.quarkus</groupId>
78+
<artifactId>quarkus-jacoco</artifactId>
79+
</dependency>
7680
<dependency>
7781
<groupId>io.quarkus</groupId>
7882
<artifactId>quarkus-rest-client</artifactId>
@@ -113,142 +117,40 @@
113117
<scope>test</scope>
114118
<version>${wiremock.version}</version>
115119
</dependency>
116-
<dependency>
117-
<groupId>org.jacoco</groupId>
118-
<artifactId>org.jacoco.agent</artifactId>
119-
<classifier>runtime</classifier>
120-
<scope>test</scope>
121-
<version>${jacoco.version}</version>
122-
</dependency>
123120
</dependencies>
124121
<build>
125122
<plugins>
126123
<plugin>
127-
<groupId>io.quarkus</groupId>
124+
<groupId>${quarkus.platform.group-id}</groupId>
128125
<artifactId>quarkus-maven-plugin</artifactId>
129126
<version>${quarkus.platform.version}</version>
127+
<extensions>true</extensions>
130128
<executions>
131129
<execution>
132130
<goals>
133131
<goal>build</goal>
132+
<goal>generate-code</goal>
133+
<goal>generate-code-tests</goal>
134134
</goals>
135135
</execution>
136136
</executions>
137137
</plugin>
138138
<plugin>
139139
<artifactId>maven-compiler-plugin</artifactId>
140140
<version>${compiler-plugin.version}</version>
141+
<configuration>
142+
<parameters>${maven.compiler.parameters}</parameters>
143+
</configuration>
141144
</plugin>
142145
<plugin>
143146
<artifactId>maven-surefire-plugin</artifactId>
144147
<version>${surefire-plugin.version}</version>
145148
<configuration>
146-
<excludedGroups>integration,nested</excludedGroups>
147149
<systemPropertyVariables>
148-
<jacoco-agent.destfile>${project.build.directory}/jacoco-ut.exec</jacoco-agent.destfile>
149150
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
150151
<maven.home>${maven.home}</maven.home>
151152
</systemPropertyVariables>
152153
</configuration>
153-
<executions>
154-
<execution>
155-
<id>integration-tests</id>
156-
<phase>integration-test</phase>
157-
<goals>
158-
<goal>test</goal>
159-
</goals>
160-
<configuration>
161-
<excludedGroups>!integration</excludedGroups>
162-
<groups>integration</groups>
163-
<systemPropertyVariables>
164-
<jacoco-agent.destfile>${project.build.directory}/jacoco-it.exec</jacoco-agent.destfile>
165-
</systemPropertyVariables>
166-
</configuration>
167-
</execution>
168-
</executions>
169-
</plugin>
170-
<plugin>
171-
<groupId>org.jacoco</groupId>
172-
<artifactId>jacoco-maven-plugin</artifactId>
173-
<version>${jacoco.version}</version>
174-
<executions>
175-
<execution>
176-
<id>instrument-ut</id>
177-
<goals>
178-
<goal>instrument</goal>
179-
</goals>
180-
</execution>
181-
<execution>
182-
<id>restore-ut</id>
183-
<goals>
184-
<goal>restore-instrumented-classes</goal>
185-
</goals>
186-
</execution>
187-
<execution>
188-
<id>report-ut</id>
189-
<goals>
190-
<goal>report</goal>
191-
</goals>
192-
<configuration>
193-
<dataFile>${project.build.directory}/jacoco-ut.exec</dataFile>
194-
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
195-
</configuration>
196-
</execution>
197-
<execution>
198-
<id>instrument-it</id>
199-
<phase>pre-integration-test</phase>
200-
<goals>
201-
<goal>instrument</goal>
202-
</goals>
203-
</execution>
204-
<execution>
205-
<id>restore-it</id>
206-
<phase>post-integration-test</phase>
207-
<goals>
208-
<goal>restore-instrumented-classes</goal>
209-
</goals>
210-
</execution>
211-
<execution>
212-
<id>report-it</id>
213-
<phase>post-integration-test</phase>
214-
<goals>
215-
<goal>report</goal>
216-
</goals>
217-
<configuration>
218-
<dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
219-
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
220-
</configuration>
221-
</execution>
222-
<execution>
223-
<id>merge-results</id>
224-
<phase>verify</phase>
225-
<goals>
226-
<goal>merge</goal>
227-
</goals>
228-
<configuration>
229-
<fileSets>
230-
<fileSet>
231-
<directory>${project.build.directory}</directory>
232-
<includes>
233-
<include>*.exec</include>
234-
</includes>
235-
</fileSet>
236-
</fileSets>
237-
<destFile>${project.build.directory}/jacoco.exec</destFile>
238-
</configuration>
239-
</execution>
240-
<execution>
241-
<id>post-merge-report</id>
242-
<phase>verify</phase>
243-
<goals>
244-
<goal>report</goal>
245-
</goals>
246-
<configuration>
247-
<dataFile>${project.build.directory}/jacoco.exec</dataFile>
248-
<outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
249-
</configuration>
250-
</execution>
251-
</executions>
252154
</plugin>
253155
</plugins>
254156
</build>

src/main/java/com/redhat/labs/lodestar/resource/HostingResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public Response getHostingEnvironments(@QueryParam("engagementUuids") Set<String
5959
@APIResponses(value = { @APIResponse(responseCode = "401", description = "Missing or Invalid JWT"),
6060
@APIResponse(responseCode = "200", description = "hosting environments have been returned.") })
6161
@Operation(summary = "Returns engagement hosting environments")
62-
public Response getHostingEnvironment(@QueryParam("engagementUuid") String engagementUuid) {
62+
public Response getHostingEnvironment(@PathParam("engagementUuid") String engagementUuid) {
6363
return Response.ok(hostingService.getHostingEnvironments(engagementUuid)).build();
6464
}
6565

@@ -68,7 +68,7 @@ public Response getHostingEnvironment(@QueryParam("engagementUuid") String engag
6868
@APIResponses(value = { @APIResponse(responseCode = "401", description = "Missing or Invalid JWT"),
6969
@APIResponse(responseCode = "200", description = "hosting environments updated.") })
7070
@Operation(summary = "Returns updated engagement hosting environments")
71-
public Response updateHostingEnvForEngagement(@QueryParam("engagementUuid") String engagementUuid, List<HostingEnvironment> hostingEnvironments) {
71+
public Response updateHostingEnvForEngagement(@PathParam("engagementUuid") String engagementUuid, List<HostingEnvironment> hostingEnvironments) {
7272
return Response.ok(hostingService.updateAndReload(engagementUuid, hostingEnvironments, jwtUtils.getAuthorFromToken(jwt))).build();
7373
}
7474

15 KB
Binary file not shown.

src/main/resources/application.properties

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,13 @@ git.commit=${LODESTAR_BACKEND_GIT_COMMIT:not.set}
7070
git.tag=${LODESTAR_BACKEND_GIT_TAG:not.set}
7171
version.yml=${LODESTAR_BACKEND_VERSIONS_PATH:/config/version-manifest.yml}
7272

73+
quarkus.swagger-ui.theme=flattop
74+
quarkus.swagger-ui.footer=&#169; 2021 Red HatOpen Innovation Labs
75+
quarkus.swagger-ui.title=Backend
7376
mp.openapi.extensions.smallrye.info.title=LodeStar Backend API
7477
mp.openapi.extensions.smallrye.info.version=${LODESTAR_BACKEND_GIT_COMMIT:1.0}
75-
quarkus.swagger-ui.theme=flattop
76-
78+
mp.openapi.extensions.smallrye.info.license.name=Apache 2.0
79+
mp.openapi.extensions.smallrye.info.license.url=http://www.apache.org/licenses/LICENSE-2.0.html
7780

7881
# git sync
7982
auto.repopulate.cron.expr=${AUTO_REPOP_CRON:0 0/5 * * * ?}
@@ -85,4 +88,4 @@ event.retry.max.delay=${EVENT_RETRY_MAX_DELAY:60}
8588
# event get engagements per page setting
8689
get.engagement.per.page=${EVENT_GET_PER_PAGE:20}
8790

88-
v2.enabled=${V2_ENABLED:false}
91+
v2.enabled=${V2_ENABLED:false}

src/test/java/com/redhat/labs/lodestar/resource/CategoryResourceTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,8 @@ void testGetCategories() {
6666
.body("size()", equalTo(3))
6767
.body("[0]", equalTo("autosuggest"));
6868
}
69+
70+
public static String[] nullEmptyBlankSource() {
71+
return new String[] { null, "", " " };
72+
}
6973
}

src/test/java/com/redhat/labs/lodestar/resource/HostingEnvironmentResourceTest.java

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import static io.restassured.RestAssured.given;
1919
import static org.hamcrest.CoreMatchers.containsString;
20+
import static org.hamcrest.CoreMatchers.equalTo;
2021

2122
@QuarkusTest
2223
@Tag("nested")
@@ -49,4 +50,60 @@ void testGetHostingEnvironments() {
4950
.body(containsString("env-one"));
5051

5152
}
53+
54+
@Test
55+
void testGetHostingEnvironmentsForEngagement() {
56+
57+
String token = TokenUtils.generateTokenString("/JwtClaimsWriter.json");
58+
59+
HostingEnvironment he = HostingEnvironment.builder().environmentName("env1").ocpCloudProviderName("provider1")
60+
.ocpClusterSize("small").ocpPersistentStorageSize("none").ocpSubDomain("env-one").ocpVersion("4.x.x")
61+
.build();
62+
Mockito.when(hostingEnvironmentApiClient.getHostingEnvironmentsByEngagementUuid("engagement-uuid"))
63+
.thenReturn(List.of(he));
64+
65+
given()
66+
.auth()
67+
.oauth2(token)
68+
.contentType(ContentType.JSON)
69+
.when()
70+
.pathParam("engagementUuid", "engagement-uuid")
71+
.get("engagements/hosting/environments/engagement/{engagementUuid}")
72+
.then()
73+
.statusCode(200)
74+
.body("size()", equalTo(1))
75+
.body("[0].environment_name", equalTo("env1"))
76+
.body(containsString("env-one"));
77+
78+
}
79+
80+
@Test
81+
void testPutHostingEnvironmentsForEngagement() {
82+
83+
String token = TokenUtils.generateTokenString("/JwtClaimsWriter.json");
84+
85+
HostingEnvironment he = HostingEnvironment.builder().environmentName("env1").ocpCloudProviderName("provider1")
86+
.ocpClusterSize("small").ocpPersistentStorageSize("none").ocpSubDomain("env-one").ocpVersion("4.x.x")
87+
.build();
88+
List hes = List.of(he);
89+
90+
Mockito.when(hostingEnvironmentApiClient.updateHostingEnvironments(Mockito.eq("engagement-uuid"), Mockito.anyList(),
91+
Mockito.anyString(), Mockito.anyString()))
92+
.thenReturn(hes);
93+
94+
given()
95+
.auth()
96+
.oauth2(token)
97+
.contentType(ContentType.JSON)
98+
.when()
99+
.pathParam("engagementUuid", "engagement-uuid")
100+
.body(hes)
101+
.put("engagements/hosting/environments/engagement/{engagementUuid}")
102+
.then()
103+
.statusCode(200)
104+
.body("size()", equalTo(1))
105+
.body("[0].environment_name", equalTo("env1"))
106+
.body(containsString("env-one"));
107+
108+
}
52109
}

0 commit comments

Comments
 (0)