-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edceb2d
commit afab846
Showing
3 changed files
with
140 additions
and
57 deletions.
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
68 changes: 68 additions & 0 deletions
68
opc-ua-sdk/codec-json/src/test/java/org/eclipse/milo/sdk/core/types/json/TestDataType.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,68 @@ | ||
/* | ||
* Copyright (c) 2024 the Eclipse Milo Authors | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.milo.sdk.core.types.json; | ||
|
||
import org.eclipse.milo.opcua.sdk.core.typetree.DataType; | ||
import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; | ||
import org.eclipse.milo.opcua.stack.core.types.builtin.QualifiedName; | ||
import org.eclipse.milo.opcua.stack.core.types.structured.DataTypeDefinition; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class TestDataType implements DataType { | ||
|
||
final NodeId nodeId; | ||
final QualifiedName browseName; | ||
final DataTypeDefinition definition; | ||
final boolean isAbstract; | ||
|
||
public TestDataType(NodeId nodeId, QualifiedName browseName, DataTypeDefinition definition, boolean isAbstract) { | ||
this.nodeId = nodeId; | ||
this.browseName = browseName; | ||
this.definition = definition; | ||
this.isAbstract = isAbstract; | ||
} | ||
|
||
@Override | ||
public NodeId getNodeId() { | ||
return nodeId; | ||
} | ||
|
||
@Override | ||
public QualifiedName getBrowseName() { | ||
return browseName; | ||
} | ||
|
||
@Override | ||
public @Nullable NodeId getBinaryEncodingId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable NodeId getXmlEncodingId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable NodeId getJsonEncodingId() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable DataTypeDefinition getDataTypeDefinition() { | ||
return definition; | ||
} | ||
|
||
@Override | ||
public Boolean isAbstract() { | ||
return isAbstract; | ||
} | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
...dk/codec-json/src/test/java/org/eclipse/milo/sdk/core/types/json/TestEncodingContext.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,71 @@ | ||
/* | ||
* Copyright (c) 2024 the Eclipse Milo Authors | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package org.eclipse.milo.sdk.core.types.json; | ||
|
||
import org.eclipse.milo.opcua.sdk.core.typetree.DataTypeTree; | ||
import org.eclipse.milo.opcua.stack.core.NamespaceTable; | ||
import org.eclipse.milo.opcua.stack.core.ServerTable; | ||
import org.eclipse.milo.opcua.stack.core.channel.EncodingLimits; | ||
import org.eclipse.milo.opcua.stack.core.encoding.DataTypeCodec; | ||
import org.eclipse.milo.opcua.stack.core.encoding.DefaultEncodingManager; | ||
import org.eclipse.milo.opcua.stack.core.encoding.EncodingContext; | ||
import org.eclipse.milo.opcua.stack.core.encoding.EncodingManager; | ||
import org.eclipse.milo.opcua.stack.core.types.DataTypeManager; | ||
import org.eclipse.milo.opcua.stack.core.types.DefaultDataTypeManager; | ||
import org.mockito.Mockito; | ||
|
||
class TestEncodingContext implements EncodingContext { | ||
|
||
DataTypeTree dataTypeTree = Mockito.mock(DataTypeTree.class); | ||
DataTypeManager dataTypeManager = new DefaultDataTypeManager(); | ||
|
||
public TestEncodingContext() { | ||
DataTypeCodec xvDataTypeCodec = | ||
JsonCodecFactory.create(JsonStructCodecTest.XV_DATA_TYPE, dataTypeTree); | ||
|
||
dataTypeManager.registerType( | ||
JsonStructCodecTest.XV_DATA_TYPE.getNodeId(), | ||
xvDataTypeCodec, | ||
JsonStructCodecTest.XV_DATA_TYPE.getBinaryEncodingId(), | ||
JsonStructCodecTest.XV_DATA_TYPE.getXmlEncodingId(), | ||
JsonStructCodecTest.XV_DATA_TYPE.getJsonEncodingId() | ||
); | ||
|
||
Mockito.when(dataTypeTree.getDataType(JsonStructCodecTest.XV_DATA_TYPE.getNodeId())) | ||
.thenReturn(JsonStructCodecTest.XV_DATA_TYPE); | ||
} | ||
|
||
@Override | ||
public DataTypeManager getDataTypeManager() { | ||
return dataTypeManager; | ||
} | ||
|
||
@Override | ||
public EncodingManager getEncodingManager() { | ||
return DefaultEncodingManager.createAndInitialize(); | ||
} | ||
|
||
@Override | ||
public EncodingLimits getEncodingLimits() { | ||
return EncodingLimits.DEFAULT; | ||
} | ||
|
||
@Override | ||
public NamespaceTable getNamespaceTable() { | ||
return new NamespaceTable(); | ||
} | ||
|
||
@Override | ||
public ServerTable getServerTable() { | ||
return new ServerTable(); | ||
} | ||
|
||
} |