This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new 438fff8  [OPENMEETINGS-2703] browser warning should be eliminated, 
sonar should be happier
438fff8 is described below

commit 438fff884fd8cd2575febe02f2b0c70e576bab60
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Wed Nov 17 00:42:23 2021 +0700

    [OPENMEETINGS-2703] browser warning should be eliminated, sonar should be 
happier
---
 .../openmeetings/webservice/TestInfoService.java   | 27 +++++++++++-
 .../openmeetings/webservice/InfoWebService.java    | 50 +++++++++++-----------
 2 files changed, 50 insertions(+), 27 deletions(-)

diff --git 
a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestInfoService.java
 
b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestInfoService.java
index 2d7906e..021e52f 100644
--- 
a/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestInfoService.java
+++ 
b/openmeetings-web/src/test/java/org/apache/openmeetings/webservice/TestInfoService.java
@@ -19,22 +19,47 @@
 package org.apache.openmeetings.webservice;
 
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import org.apache.openmeetings.db.dto.basic.Health;
 import org.apache.openmeetings.db.dto.basic.Info;
 import org.junit.jupiter.api.Test;
 
+import com.github.openjson.JSONObject;
+
 class TestInfoService extends AbstractWebServiceTest {
        private static final String INFO_SERVICE_MOUNT = "info";
 
        @Test
        void infoTest() {
-               Info info = 
getClient(getInfoUrl()).path("/version").get(Info.class);
+               Info info = getClient(getInfoUrl())
+                               .path("/version")
+                               .get(Info.class);
                assertNotNull(info, "Valid info should be returned");
                assertNotNull(info.getBuildDate(), "Valid BuildDate should be 
returned");
                assertNotNull(info.getRevision(), "Valid Revision should be 
returned");
                assertNotNull(info.getVersion(), "Valid Version should be 
returned");
        }
 
+       @Test
+       void healthTest() {
+               Health health = getClient(getInfoUrl())
+                               .path("/health")
+                               .get(Health.class);
+               assertNotNull(health, "Valid health should be returned");
+               assertTrue(health.isDbOk(), "DB should be OK");
+       }
+
+       @Test
+       void manifestTest() {
+               String manifest = getClient(getInfoUrl())
+                               .path("/manifest.webmanifest")
+                               .get(String.class);
+               assertNotNull(manifest, "Valid manifestshould be returned");
+               JSONObject json = new JSONObject(manifest);
+               assertTrue(json.getBoolean("prefer_related_applications"), "the 
value should be of type Boolean");
+       }
+
        protected static String getInfoUrl() {
                return getServiceUrl(INFO_SERVICE_MOUNT);
        }
diff --git 
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/InfoWebService.java
 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/InfoWebService.java
index 235b9d7..845181b 100644
--- 
a/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/InfoWebService.java
+++ 
b/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/InfoWebService.java
@@ -18,6 +18,8 @@
  */
 package org.apache.openmeetings.webservice;
 
+import static 
org.apache.openmeetings.util.OpenmeetingsVariables.getApplicationName;
+import static org.apache.openmeetings.util.OpenmeetingsVariables.getWebappPath;
 import static org.apache.openmeetings.webservice.Constants.TNS;
 
 import java.net.URI;
@@ -32,7 +34,6 @@ import javax.ws.rs.core.MediaType;
 import org.apache.cxf.feature.Features;
 import org.apache.openmeetings.db.dto.basic.Health;
 import org.apache.openmeetings.db.dto.basic.Info;
-import org.apache.openmeetings.util.OpenmeetingsVariables;
 import org.apache.openmeetings.util.Version;
 import org.apache.openmeetings.webservice.schema.HealthWrapper;
 import org.apache.openmeetings.webservice.schema.InfoWrapper;
@@ -104,33 +105,30 @@ public class InfoWebService {
        @Path("/manifest.webmanifest")
        @Produces({"application/manifest+json"})
        public String getManifest() {
-               URI omPath = OpenmeetingsVariables.getWebappPath();
-               JSONObject manifest = new JSONObject();
-               manifest.put("name", OpenmeetingsVariables.getApplicationName() 
+ " " + Version.getVersion());
-               manifest.put("short_name", 
OpenmeetingsVariables.getApplicationName() + " " + Version.getVersion());
-               manifest.put("description", "Openmeetings provides video 
conferencing, instant messaging, white board, collaborative document editing 
and other groupware tools.");
-               manifest.put("start_url",  omPath.resolve("?pwa=true"));
-               manifest.put("scope", "/");
-               manifest.put("background_color", "#ffffff");
-               manifest.put("theme_color", "#ffffff");
-               manifest.put("dir", "auto");
-               manifest.put("display", "standalone");
-               manifest.put("orientation", "landscape");
-               JSONArray icons = new JSONArray();
-               icons.put(generateIcon("manifest-icon-512.maskable.png", 
"512x512", "maskable", omPath));
-               icons.put(generateIcon("manifest-icon-192.maskable.png", 
"192x192", "maskable", omPath));
-               manifest.put("icons", icons);
-               manifest.put("prefer_related_applications", "false");
-               return manifest.toString(2);
+               URI omPath = getWebappPath();
+               return new JSONObject()
+                               .put("name", getApplicationName() + " " + 
Version.getVersion())
+                               .put("short_name", getApplicationName() + " " + 
Version.getVersion())
+                               .put("description", "Openmeetings provides 
video conferencing, instant messaging, white board, collaborative document 
editing and other groupware tools.")
+                               .put("start_url",  omPath.resolve("?pwa=true"))
+                               .put("scope", "/")
+                               .put("background_color", "#ffffff")
+                               .put("theme_color", "#ffffff")
+                               .put("dir", "auto")
+                               .put("display", "standalone")
+                               .put("orientation", "landscape")
+                               .put("icons", new JSONArray()
+                                               
.put(generateIcon("manifest-icon-512.maskable.png", "512x512", "maskable", 
omPath))
+                                               
.put(generateIcon("manifest-icon-192.maskable.png", "192x192", "maskable", 
omPath)))
+                               .put("prefer_related_applications", false)
+                               .toString(2);
        }
 
        private JSONObject generateIcon(String name, String dimension, String 
purpose, URI omPath) {
-               JSONObject icon = new JSONObject();
-               icon.put("src", omPath.resolve("images/icons/" + name));
-               icon.put("type", "image/png");
-               icon.put("sizes", dimension);
-               icon.put("purpose", purpose);
-               return icon;
+               return new JSONObject()
+                               .put("src", omPath.resolve("images/icons/" + 
name))
+                               .put("type", "image/png")
+                               .put("sizes", dimension)
+                               .put("purpose", purpose);
        }
-
 }

Reply via email to