Skip to content

Commit

Permalink
Merge branch 'draft' into gkwan-ibm-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
gkwan-ibm authored Jun 13, 2024
2 parents 7d61c26 + cbd4b7d commit 5b43c01
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
// tag::copyright[]
/*******************************************************************************
* Copyright (c) 2024 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
// end::copyright[]
package io.openliberty.guides.inventory;

import io.openliberty.guides.models.SystemLoad;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestMethodOrder;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;


@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class InventoryEndpointIT {
Expand Down Expand Up @@ -71,11 +75,14 @@ public void testNonEmpty() {
boolean hostnameExists = false;
boolean loadAverageExists = false;
for (int n = 0; n < systems.size(); n++) {
hostnameExists = systems.getJsonObject(n).get("hostname").toString().isEmpty();
loadAverageExists = systems.getJsonObject(n).get("systemLoad").toString().isEmpty();
hostnameExists = systems.getJsonObject(n).get("hostname")
.toString().isEmpty();
loadAverageExists = systems.getJsonObject(n).get("systemLoad")
.toString().isEmpty();

assertFalse(hostnameExists, "A host was registered, but it was empty");
assertFalse(loadAverageExists, "A load average was registered, but it was empty");
assertFalse(loadAverageExists,
"A load average was registered, but it was empty");
if (!hostnameExists && !loadAverageExists) {
String host = systems.getJsonObject(n).get("hostname").toString();
hostname = host.substring(1, host.length() - 1);
Expand All @@ -93,15 +100,17 @@ public void testNonEmpty() {
public void testValue() {
assertNotNull(hostname, "Hostname should be set by the first test.");

Response response = this.getResponse(baseUrl + INVENTORY_SYSTEMS + "/" + hostname);
Response response = this.getResponse(baseUrl +
INVENTORY_SYSTEMS + "/" + hostname);
this.assertResponse(baseUrl, response);

JsonObject system = response.readEntity(JsonObject.class);

String responseHostname = system.getString("hostname");
Boolean loadAverageExists = system.get("systemLoad").toString().isEmpty();

assertEquals(hostname, responseHostname, "Hostname should match the one from the TestNonEmpty");
assertEquals(hostname, responseHostname,
"Hostname should match the one from the TestNonEmpty");
assertFalse(loadAverageExists, "A Load Average should not be empty");

response.close();
Expand Down

0 comments on commit 5b43c01

Please sign in to comment.