Policy Gui Code Coverage 27/126927/1
authorlapentafd <francesco.lapenta@est.tech>
Wed, 26 Jan 2022 17:37:12 +0000 (17:37 +0000)
committerlapentafd <francesco.lapenta@est.tech>
Wed, 2 Feb 2022 11:41:41 +0000 (11:41 +0000)
Adding Generated tag for lombok methods in ApexEditorParameters
This will skip the sonar check on the @Data methods

Issue-ID: POLICY-3351
Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Change-Id: I73ec9f47fb90182221aebd5129bf2da32ab06cad

gui-editors/gui-editor-apex/src/main/java/org/onap/policy/gui/editors/apex/rest/ApexEditorParameters.java
gui-editors/gui-editor-apex/src/main/resources/webapp/js/ApexMain.js
gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/ApexMain.test.js
gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/fileMenu.test.js [new file with mode: 0644]
gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/showhideElement.test.js

index 3f988b5..58a4b33 100644 (file)
@@ -1,7 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ *  Modifications Copyright (C) 2020-2022 Nordix Foundation.
  *  Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -27,6 +27,7 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import lombok.Data;
+import lombok.Generated;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.ext.XLogger;
 import org.slf4j.ext.XLoggerFactory;
@@ -37,6 +38,7 @@ import org.slf4j.ext.XLoggerFactory;
  * @author Liam Fallon (liam.fallon@ericsson.com)
  */
 @Data
+@Generated
 public class ApexEditorParameters {
     // Logger for this class
     private static final XLogger LOGGER = XLoggerFactory.getXLogger(ApexEditorParameters.class);
index ce491ec..3fc3cd5 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * ============LICENSE_START=======================================================
  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
- *  Modifications Copyright (C) 2020 Nordix Foundation.
+ *  Modifications Copyright (C) 2020-2022 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -175,5 +175,6 @@ $(".ebInlineMessage").mouseleave(function(e) {
 });
 
 export {
-    clearLocalStorage
+    clearLocalStorage,
+    main_getRestRootURL
 }
index d26d926..beb73f5 100644 (file)
  */
 
 const mod = require('../ApexMain');
-
+const $ = require('jquery');
 
 test('Test main_getRestRootURL', () => {
+    jest.spyOn(window.localStorage.__proto__, 'getItem');
+    window.localStorage.__proto__.getItem = jest.fn(() => true);
     const mock_main_getRestRootURL = jest.fn(mod.main_getRestRootURL);
     mock_main_getRestRootURL();
     expect(mock_main_getRestRootURL).toBeCalled();
@@ -30,4 +32,13 @@ test('Test clearLocalStorage', () => {
     const mock_clearLocalStorage = jest.fn(mod.clearLocalStorage);
     mock_clearLocalStorage();
     expect(mock_clearLocalStorage).toBeCalled();
+});
+
+test('test ready', () => {
+    document.documentElement.innerHTML = '<html><head></head><body><ul id="menu li"><li><div>menu</div><ul><li><div>FileNew</div></li></ul></li></ul></body></html>';
+    window.$ = $;
+    $("#menu li").click();
+    let h1 = document.querySelector('ul');
+    console.log(document.documentElement.innerHTML);
+    expect(h1.textContent).toEqual('menuFileNew');
 });
\ No newline at end of file
diff --git a/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/fileMenu.test.js b/gui-editors/gui-editor-apex/src/main/resources/webapp/js/__test__/fileMenu.test.js
new file mode 100644 (file)
index 0000000..ffc9e2c
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * ============LICENSE_START=======================================================
+ *  Copyright (C) 2022 Nordix Foundation
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+const mod = require('../fileMenu');
+
+test('test hideMenu', () => {
+    document.documentElement.innerHTML = '<html><head></head><body><ul id="menu">Hello world!</ul></body></html>';
+    $ = require('jquery');
+    window.$ = $;
+    $('#menu').fileMenu();
+    $('#menu').click();
+    let h1 = document.querySelector('ul');
+    expect(h1.textContent).toEqual('Hello world!');
+});
index 5f85a70..6b2bfa5 100644 (file)
@@ -29,8 +29,11 @@ test('Test editTaskForm_activate CREATE', () => {
 
 test('Test editTaskForm_activate NO CHECKBOX', () => {
    const mock_activate = jest.fn(mod.showHideElement_display);
-   let documentSpy = jest.spyOn(document, 'getElementById');
-   mock_activate(documentSpy, null, null, 'hidestyle', 'buttonshowStyle','buttonhideStyle');
+   spyOn($.fn, "find").and.returnValue(false);
+   const mockedElementDOM = { classList: { contains: jest.fn(), remove: jest.fn(), add: jest.fn() } };
+   mockedElementDOM.classList.contains.mockReturnValueOnce(true);
+   mockedElementDOM.classList.remove.mockReturnValueOnce(true);
+   mock_activate(mockedElementDOM, 'element', 'style', 'hidestyle', 'buttonshowStyle','buttonhideStyle');
    expect(mock_activate).toBeCalled();
 });