Skip to content

Commit

Permalink
Help provider unit tests (#2258)
Browse files Browse the repository at this point in the history
* added unit tests to help provider classes

* minor fix

* updated tocs and buttons

* updated unit test

* made suggested changes
  • Loading branch information
antares1470 authored Jan 14, 2025
1 parent 966636a commit 98de46e
Show file tree
Hide file tree
Showing 49 changed files with 3,064 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2010-2025 Australian Signals Directorate
*
* 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.
*/
package au.gov.asd.tac.constellation.plugins.algorithms;

import java.util.Map;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/**
*
* @author antares
*/
public class AlgorithmPluginsHelpProviderNGTest {

@BeforeClass
public static void setUpClass() throws Exception {
// Not currently required
}

@AfterClass
public static void tearDownClass() throws Exception {
// Not currently required
}

@BeforeMethod
public void setUpMethod() throws Exception {
// Not currently required
}

@AfterMethod
public void tearDownMethod() throws Exception {
// Not currently required
}

/**
* Test of getHelpMap method, of class AlgorithmPluginsHelpProvider.
*/
@Test
public void testGetHelpMap() {
System.out.println("getHelpMap");

final AlgorithmPluginsHelpProvider instance = new AlgorithmPluginsHelpProvider();
final Map<String, String> helpMap = instance.getHelpMap();

assertEquals(helpMap.size(), 5);
//not going to go through and assert the existence of each specific item in the map
//but will assert they're all correctly located within the algorithms package
final String packageStart = "au.gov.asd.tac.constellation.plugins.algorithms.";
for (final String path : helpMap.keySet()) {
assertTrue(path.startsWith(packageStart));
}
}

/**
* Test of getHelpTOC method, of class AlgorithmPluginsHelpProvider.
*/
@Test
public void testGetHelpTOC() {
System.out.println("getHelpTOC");

final AlgorithmPluginsHelpProvider instance = new AlgorithmPluginsHelpProvider();
final String tocLocation = instance.getHelpTOC();

//the file separator used will vary from OS to OS so rather than copying the
//exact string from the actual class and asserting what we got is the same,
//we'll assert that some of the keyparts of the expected filepath are present
assertTrue(tocLocation.contains("docs"));
assertTrue(tocLocation.contains("CoreAlgorithmPlugins"));
assertTrue(tocLocation.contains("src"));
assertTrue(tocLocation.contains("plugins"));
assertTrue(tocLocation.contains("algorithms"));
assertTrue(tocLocation.contains("algorithms-toc.xml"));

assertTrue(tocLocation.indexOf("docs") < tocLocation.indexOf("CoreAlgorithmPlugins"));
assertTrue(tocLocation.indexOf("CoreAlgorithmPlugins") < tocLocation.indexOf("src"));
assertTrue(tocLocation.indexOf("src") < tocLocation.indexOf("plugins"));
assertTrue(tocLocation.indexOf("plugins") < tocLocation.indexOf("algorithms"));
assertTrue(tocLocation.indexOf("algorithms") < tocLocation.indexOf("algorithms-toc.xml"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2010-2025 Australian Signals Directorate
*
* 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.
*/
package au.gov.asd.tac.constellation.views.analyticview;

import java.util.Map;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/**
*
* @author antares
*/
public class AnalyticViewHelpProviderNGTest {

@BeforeClass
public static void setUpClass() throws Exception {
// Not currently required
}

@AfterClass
public static void tearDownClass() throws Exception {
// Not currently required
}

@BeforeMethod
public void setUpMethod() throws Exception {
// Not currently required
}

@AfterMethod
public void tearDownMethod() throws Exception {
// Not currently required
}

/**
* Test of getHelpMap method, of class AnalyticViewHelpProvider.
*/
@Test
public void testGetHelpMap() {
System.out.println("getHelpMap");

final AnalyticViewHelpProvider instance = new AnalyticViewHelpProvider();
final Map<String, String> helpMap = instance.getHelpMap();

assertEquals(helpMap.size(), 35);
//not going to go through and assert the existence of each specific item in the map
//but will assert they're all correctly located within the analytic view package
final String packageStart = "au.gov.asd.tac.constellation.views.analyticview.";
for (final String path : helpMap.keySet()) {
assertTrue(path.startsWith(packageStart));
}
}

/**
* Test of getHelpTOC method, of class AnalyticViewHelpProvider.
*/
@Test
public void testGetHelpTOC() {
System.out.println("getHelpTOC");

final AnalyticViewHelpProvider instance = new AnalyticViewHelpProvider();
final String tocLocation = instance.getHelpTOC();

//the file separator used will vary from OS to OS so rather than copying the
//exact string from the actual class and asserting what we got is the same,
//we'll assert that some of the keyparts of the expected filepath are present
assertTrue(tocLocation.contains("docs"));
assertTrue(tocLocation.contains("CoreAnalyticView"));
assertTrue(tocLocation.contains("src"));
assertTrue(tocLocation.contains("views"));
assertTrue(tocLocation.contains("analyticview"));
assertTrue(tocLocation.contains("analyticview-toc.xml"));

assertTrue(tocLocation.indexOf("docs") < tocLocation.indexOf("CoreAnalyticView"));
assertTrue(tocLocation.indexOf("CoreAnalyticView") < tocLocation.indexOf("src"));
assertTrue(tocLocation.indexOf("src") < tocLocation.indexOf("views"));
assertTrue(tocLocation.indexOf("views") < tocLocation.indexOf("analyticview"));
assertTrue(tocLocation.indexOf("analyticview") < tocLocation.indexOf("analyticview-toc.xml"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public void testGetHelpMap() {
expResult.put("au.gov.asd.tac.constellation.plugins.arrangements.uncollide", arrangementModulePath + "uncollide-arrangement.md");
expResult.put("au.gov.asd.tac.constellation.plugins.arrangements.pinUnpin", arrangementModulePath + "pin-unpin-nodes.md");

ArrangementPluginsHelpProvider instance = new ArrangementPluginsHelpProvider();
final ArrangementPluginsHelpProvider instance = new ArrangementPluginsHelpProvider();

Map result = instance.getHelpMap();
final Map<String, String> result = instance.getHelpMap();
assertTrue(expResult.equals(result));

}
Expand All @@ -75,12 +75,11 @@ public void testGetHelpMap() {
public void testGetHelpTOC() {
System.out.println("getHelpTOC");

ArrangementPluginsHelpProvider instance = new ArrangementPluginsHelpProvider();
final ArrangementPluginsHelpProvider instance = new ArrangementPluginsHelpProvider();
final String expResult = "ext" + SEP + "docs" + SEP + "CoreArrangementPlugins" + SEP + "src" + SEP + "au" + SEP
+ "gov" + SEP + "asd" + SEP + "tac" + SEP + CODEBASE_NAME + SEP + "plugins" + SEP + "arrangements" + SEP
+ "arrangements-toc.xml";

assertEquals(instance.getHelpTOC(), expResult);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright 2010-2025 Australian Signals Directorate
*
* 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.
*/
package au.gov.asd.tac.constellation.views.attributeeditor;

import java.util.Map;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

/**
*
* @author antares
*/
public class AttributeEditorHelpProviderNGTest {

@BeforeClass
public static void setUpClass() throws Exception {
// Not currently required
}

@AfterClass
public static void tearDownClass() throws Exception {
// Not currently required
}

@BeforeMethod
public void setUpMethod() throws Exception {
// Not currently required
}

@AfterMethod
public void tearDownMethod() throws Exception {
// Not currently required
}

/**
* Test of getHelpMap method, of class AttributeEditorHelpProvider.
*/
@Test
public void testGetHelpMap() {
System.out.println("getHelpMap");

final AttributeEditorHelpProvider instance = new AttributeEditorHelpProvider();
final Map<String, String> helpMap = instance.getHelpMap();

assertEquals(helpMap.size(), 1);
//not going to go through and assert the existence of each specific item in the map
//but will assert they're all correctly located within the attribute editor package
final String packageStart = "au.gov.asd.tac.constellation.views.attributeeditor.";
for (final String path : helpMap.keySet()) {
assertTrue(path.startsWith(packageStart));
}
}

/**
* Test of getHelpTOC method, of class AttributeEditorHelpProvider.
*/
@Test
public void testGetHelpTOC() {
System.out.println("getHelpTOC");

final AttributeEditorHelpProvider instance = new AttributeEditorHelpProvider();
final String tocLocation = instance.getHelpTOC();

//the file separator used will vary from OS to OS so rather than copying the
//exact string from the actual class and asserting what we got is the same,
//we'll assert that some of the keyparts of the expected filepath are present
assertTrue(tocLocation.contains("docs"));
assertTrue(tocLocation.contains("CoreAttributeEditorView"));
assertTrue(tocLocation.contains("src"));
assertTrue(tocLocation.contains("views"));
assertTrue(tocLocation.contains("attributeeditor"));
assertTrue(tocLocation.contains("attributeeditor-toc.xml"));

assertTrue(tocLocation.indexOf("docs") < tocLocation.indexOf("CoreAttributeEditorView"));
assertTrue(tocLocation.indexOf("CoreAttributeEditorView") < tocLocation.indexOf("src"));
assertTrue(tocLocation.indexOf("src") < tocLocation.indexOf("views"));
assertTrue(tocLocation.indexOf("views") < tocLocation.indexOf("attributeeditor"));
assertTrue(tocLocation.indexOf("attributeeditor") < tocLocation.indexOf("attributeeditor-toc.xml"));
}
}
Loading

0 comments on commit 98de46e

Please sign in to comment.