import static org.junit.Assert.assertTrue;
import com.google.common.util.concurrent.ListenableFuture;
-import java.math.BigInteger;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+import org.opendaylight.yangtools.yang.common.Uint8;
public class SalRoleServiceImplTest {
@Mock
private OutboundQueue mockOutboundQueue;
- private NodeId testNodeId = new NodeId(Uri.getDefaultInstance("openflow:1"));
-
- private static short testVersion = 4;
+ private final NodeId testNodeId = new NodeId(Uri.getDefaultInstance("openflow:1"));
private static long testXid = 100L;
public void setup() {
MockitoAnnotations.initMocks(this);
Mockito.when(mockDeviceInfo.getNodeId()).thenReturn(testNodeId);
- Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
+ Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(Uint64.valueOf(10));
+ Uint8 testVersion = Uint8.valueOf(4);
Mockito.when(mockFeaturesOutput.getVersion()).thenReturn(testVersion);
Mockito.when(mockDeviceContext.getDeviceState()).thenReturn(mockDeviceState);
Mockito.when(mockDeviceContext.getDeviceInfo()).thenReturn(mockDeviceInfo);
Mockito.when(mockFeaturesReply.getVersion()).thenReturn(testVersion);
Mockito.when(mockDeviceContext.getMessageSpy()).thenReturn(mockMessageSpy);
Mockito.when(mockRequestContextStack.<RoleRequestOutput>createRequestContext()).thenReturn(mockRequestContext);
- Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(testXid));
+ Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(Uint32.valueOf(testXid)));
Mockito.when(mockConnectionContext.getOutboundQueueProvider()).thenReturn(mockOutboundQueue);
Mockito.when(mockDeviceContext.getPrimaryConnectionContext().getConnectionState())
.thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
NodeKey key = new NodeKey(testNodeId);
- InstanceIdentifier<Node> path = InstanceIdentifier.<Nodes>builder(Nodes.class)
- .<Node, NodeKey>child(Node.class, key)
+ InstanceIdentifier<Node> path = InstanceIdentifier.builder(Nodes.class)
+ .child(Node.class, key)
.build();
nodeRef = new NodeRef(path);
@Test
public void testSetRole() throws Exception {
- RoleRequestOutput roleRequestOutput = (new RoleRequestOutputBuilder())
- .setXid(testXid).setGenerationId(BigInteger.valueOf(1)).build();
+ RoleRequestOutput roleRequestOutput = new RoleRequestOutputBuilder()
+ .setXid(testXid).setGenerationId(Uint64.ONE).build();
ListenableFuture<RpcResult<RoleRequestOutput>> futureOutput =
RpcResultBuilder.<RoleRequestOutput>success().withResult(roleRequestOutput).buildFuture();
SetRoleOutput setRoleOutput = roleOutputRpcResult.getResult();
assertNotNull(setRoleOutput);
- assertEquals(BigInteger.valueOf(testXid), setRoleOutput.getTransactionId().getValue());
+ assertEquals(Uint64.valueOf(testXid), setRoleOutput.getTransactionId().getValue());
}
public void testDuplicateRoles() throws Exception {
// set role to slave
- RoleRequestOutput roleRequestOutput = (new RoleRequestOutputBuilder())
- .setXid(testXid).setGenerationId(BigInteger.valueOf(1)).build();
+ RoleRequestOutput roleRequestOutput = new RoleRequestOutputBuilder()
+ .setXid(testXid).setGenerationId(Uint64.ONE).build();
ListenableFuture<RpcResult<RoleRequestOutput>> futureOutput =
RpcResultBuilder.<RoleRequestOutput>success().withResult(roleRequestOutput).buildFuture();
SetRoleOutput setRoleOutput = roleOutputRpcResult.getResult();
assertNotNull(setRoleOutput);
- assertEquals(BigInteger.valueOf(testXid), setRoleOutput.getTransactionId().getValue());
+ assertEquals(Uint64.valueOf(testXid), setRoleOutput.getTransactionId().getValue());
// make another role change with the same role - slave
Future<RpcResult<SetRoleOutput>> future2 = salRoleService.setRole(setRoleInput);