Test Your Model
Before deploying your model, you can optionally run tests with the Workbench or with the Model Development Tool.
Test with the Workbench (C# and Java)
You can use the ScaleOut Digital Twins Workbench, an open source library for .NET or Java, to test digital twin models for real-time analytics or simulation. To use the workbench, jump to the section ScaleOut Digital Twins Workbench. This topic will guide you through the process of creating your application and linking to the API libraries, which you download from public repositories.
Note
The ScaleOut Digital Twins Workbench lets you avoid the need to download the full ScaleOut Digital Twins product to deploy and test your digital twin models. This open source library is a great way to familiarize yourself with the framework and to shorten the design cycle when debugging applications.
To use the workbench, jump to the section ScaleOut Digital Twins Workbench.
The ScaleOut Digital Twin Maven Archetypes generate a Java project tailored for real-time digital twin applications — including basic unit tests located in the src/test/java/
directory.
Navigate to the TestModel
class located in the src/test/java/
directory’s com.digitaltwin.quickstart
package.
Inside, you’ll see the following test – copy the code below to update the message instantiation and add message logging validation:
@Test
public void testMessageBasedInitialization() {
try (Workbench workbench = new Workbench()) {
String modelName = "MyRealTimeTwinModel";
String testId = "23";
String messageContents = "Hello ScaleOut Digital Twin Streaming Service!";
// Add the DigitalTwinImpl real-time model to the workbench.
workbench.addRealTimeModel(modelName, new MyRealTimeTwinMessageProcessor(), MyRealTimeTwinModel.class, MyRealTimeTwinMessage.class);
// Create a message list with an initialization message
List<Object> messages = new LinkedList<>();
MyRealTimeTwinMessage message = new MyRealTimeTwinMessage(messageContents);
messages.add(message);
// Send the message list to the workbench. The workbench is responsible for instantiating the model's instance
// and delivering the message.
workbench.send(modelName, testId, messages);
// Introspect on the state of the DigitalTwinImpl instance.
HashMap<String, DigitalTwinBase> instances = workbench.getInstances(modelName);
MyRealTimeTwinModel instance = (MyRealTimeTwinModel)instances.get(testId);
Assert.assertNotNull(instance);
// Introspect on the state of the Logged Messages
List<LogMessage> loggedMessages = workbench.getLoggedMessages(modelName, 0);
for(LogMessage logMessage : loggedMessages) {
Assert.assertNotNull(logMessage);
Assert.assertSame(messageContents, logMessage.getMessage());
}
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Now, you can run the test to ensure proper function. From your IDE execute your unit test task or from a terminal execute:
mvn test
Test with the Model Development Tool
You can access the Model Development Tool’s testing features by changing to the Test Model tab at the top of the left sidebar. To run a simple test on the model you just built, enter 1
for the instance ID and Hello World
for the StringPayload, and click Send message and run all rules. You should see that both rules executed successfully.
For guidance on more advanced testing with the Model Development Tool, see Testing a Model.
Continue to the next section to learn how to deploy your model with the ScaleOut Digital Twins UI and use the REST service to send it messages.