-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Java 11 now required for building - compilation binaries remain compatible with Java 8
- Loading branch information
Showing
6 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.nodel; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface GitHubIssue { | ||
String value(); // The URL or ID of the GitHub issue | ||
} |
37 changes: 37 additions & 0 deletions
37
nodel-framework/src/test/java/org/nodel/SimpleNameTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.nodel; | ||
|
||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
class SimpleNameTest { | ||
|
||
@ParameterizedTest | ||
@ValueSource(strings = { | ||
"node_name", | ||
"Node Name", | ||
"node-name", | ||
"node.name", | ||
"node name" | ||
}) | ||
void testGetOriginalName(String originalName) { | ||
SimpleName name = new SimpleName(originalName); | ||
assertEquals(originalName, name.getOriginalName()); | ||
} | ||
|
||
@ParameterizedTest | ||
@CsvSource({ | ||
"node_name, nodename", | ||
"Node Name, NodeName", | ||
"node-name, nodename", | ||
"node.name, nodename", | ||
"node name, nodename" | ||
}) | ||
public void testGetReducedName(String originalName, String expectedReducedName) { | ||
SimpleName name = new SimpleName(originalName); | ||
assertEquals(expectedReducedName, name.getReducedName()); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
nodel-framework/src/test/java/org/nodel/toolkit/ManagedToolkitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package org.nodel.toolkit; | ||
|
||
import org.junit.jupiter.api.*; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.CsvSource; | ||
import org.nodel.GitHubIssue; | ||
import org.nodel.SimpleName; | ||
import org.nodel.core.NodelServerAction; | ||
import org.nodel.core.NodelServerEvent; | ||
import org.nodel.core.NodelServers; | ||
import org.nodel.host.BaseDynamicNode; | ||
import org.nodel.host.Binding; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
class ManagedToolkitTest { | ||
|
||
private ManagedToolkit managedToolkit; | ||
private Binding metadata; | ||
private ActionFunction actionFunction; | ||
|
||
@FunctionalInterface | ||
interface ActionFunction { | ||
void handle(Object arg); | ||
} | ||
|
||
@BeforeEach | ||
void setUp() { | ||
BaseDynamicNode mockNode = mock(BaseDynamicNode.class); | ||
when(mockNode.getName()).thenReturn(new SimpleName("MockNode")); | ||
managedToolkit = new ManagedToolkit(mockNode); | ||
metadata = new Binding(); | ||
actionFunction = arg -> {}; | ||
} | ||
|
||
@Disabled("Awaiting fix for issue: #284") | ||
@DisplayName("Original name of generated action") | ||
@GitHubIssue("https://github.com/museumsvictoria/nodel/issues/284") | ||
@ParameterizedTest | ||
@CsvSource({ | ||
"Action With Spaces, Action With Spaces", | ||
"Action-With-Hyphens, Action-With-Hyphens", | ||
}) | ||
void testCreateActionWithDefaultName(String actionName, String expectedName) { | ||
try (NodelServerAction action = managedToolkit.createAction(actionName, actionFunction::handle, metadata)) { | ||
assertEquals(expectedName, action.getAction().getOriginalName()); | ||
} | ||
} | ||
|
||
@DisplayName("Reduced name of generated action") | ||
@ParameterizedTest | ||
@CsvSource({ | ||
"Action With Spaces, ActionWithSpaces", | ||
"Action-With-Hyphens, ActionWithHyphens", | ||
}) | ||
void testCreateActionWithReducedName(String actionName, String expectedName) { | ||
try (NodelServerAction action = managedToolkit.createAction(actionName, actionFunction::handle, metadata)) { | ||
assertEquals(expectedName, action.getAction().getReducedName()); | ||
} | ||
} | ||
|
||
@Disabled("Awaiting fix for issue: #284") | ||
@DisplayName("Original name of generated event") | ||
@GitHubIssue("https://github.com/museumsvictoria/nodel/issues/284") | ||
@ParameterizedTest | ||
@CsvSource({ | ||
"Event With Spaces, Event With Spaces", | ||
"Event-With-Hyphens, Event-With-Hyphens", | ||
}) | ||
void testCreateEventWithDefaultName(String eventName, String expectedName) { | ||
try (NodelServerEvent event = managedToolkit.createEvent(eventName, metadata)) { | ||
NodelServers.instance().registerEvent(event); | ||
assertEquals(expectedName, event.getEvent().getOriginalName()); | ||
} | ||
} | ||
|
||
@DisplayName("Reduced name of generated event") | ||
@ParameterizedTest | ||
@CsvSource({ | ||
"Event With Spaces, EventWithSpaces", | ||
"Event-With-Hyphens, EventWithHyphens", | ||
}) | ||
|
||
void testCreateEventWithReducedName(String eventName, String expectedName) { | ||
try (NodelServerEvent event = managedToolkit.createEvent(eventName, metadata)) { | ||
NodelServers.instance().registerEvent(event); | ||
assertEquals(expectedName, event.getEvent().getReducedName()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters