@Test public void testRegisterL3PrefixEndpoint_BadData() { WriteTransaction wt = newWriteTransactionMock(); endpointRpcRegistry.registerL3PrefixEndpoint(setL3PrefixTestVariables_NoIpPrefix()); endpointRpcRegistry.registerL3PrefixEndpoint(setL3PrefixTestVariables_NoL3Context()); endpointRpcRegistry.registerL3PrefixEndpoint(setL3PrefixTestVariables_NoTenant()); verify(wt, never()).put(eq(LogicalDatastoreType.OPERATIONAL), Mockito.<InstanceIdentifier<EndpointL3Prefix>>any(), any(EndpointL3Prefix.class)); }
@Override public Future<RpcResult<Void>> registerL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) { if (input.getL3Context() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have L3Context.") .build()); } if (input.getIpPrefix() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have ip-prefix.") .build()); } if (input.getTenant() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.") .build()); } WriteTransaction t = dataProvider.newWriteOnlyTransaction(); long timestamp = System.currentTimeMillis(); EndpointL3PrefixKey epL3PrefixKey = new EndpointL3PrefixKey(input.getIpPrefix(), input.getL3Context()); EndpointL3Prefix epL3Prefix = buildL3PrefixEndpoint(input).setTimestamp(timestamp).build(); InstanceIdentifier<EndpointL3Prefix> iid_l3prefix = InstanceIdentifier.builder(Endpoints.class).child(EndpointL3Prefix.class, epL3PrefixKey).build(); t.put(LogicalDatastoreType.OPERATIONAL, iid_l3prefix, epL3Prefix); ListenableFuture<Void> r = t.submit(); return Futures.transform(r, futureTrans, MoreExecutors.directExecutor()); }
EndpointRpcRegistry implements EndpointService, EpRendererAugmentationRegistry, AutoCloseable { @Override public Future<RpcResult<Void>> registerL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) { if (input.getL3Context() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have L3Context.") .build()); } if (input.getIpPrefix() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have ip-prefix.") .build()); } if (input.getTenant() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.") .build()); } WriteTransaction t = dataProvider.newWriteOnlyTransaction(); long timestamp = System.currentTimeMillis(); EndpointL3PrefixKey epL3PrefixKey = new EndpointL3PrefixKey(input.getIpPrefix(), input.getL3Context()); EndpointL3Prefix epL3Prefix = buildL3PrefixEndpoint(input).setTimestamp(timestamp).build(); InstanceIdentifier<EndpointL3Prefix> iid_l3prefix = InstanceIdentifier.builder(Endpoints.class).child(EndpointL3Prefix.class, epL3PrefixKey).build(); t.put(LogicalDatastoreType.OPERATIONAL, iid_l3prefix, epL3Prefix); ListenableFuture<Void> r = t.submit(); return Futures.transform(r, futureTrans, MoreExecutors.directExecutor()); } }
EndpointRpcRegistry implements EndpointService, EpRendererAugmentationRegistry, AutoCloseable { @Override public Future<RpcResult<Void>> registerL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) { if (input.getL3Context() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have L3Context.") .build()); } if (input.getIpPrefix() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have ip-prefix.") .build()); } if (input.getTenant() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.") .build()); } WriteTransaction t = dataProvider.newWriteOnlyTransaction(); long timestamp = System.currentTimeMillis(); EndpointL3PrefixKey epL3PrefixKey = new EndpointL3PrefixKey(input.getIpPrefix(), input.getL3Context()); EndpointL3Prefix epL3Prefix = buildL3PrefixEndpoint(input).setTimestamp(timestamp).build(); InstanceIdentifier<EndpointL3Prefix> iid_l3prefix = InstanceIdentifier.builder(Endpoints.class).child(EndpointL3Prefix.class, epL3PrefixKey).build(); t.put(LogicalDatastoreType.OPERATIONAL, iid_l3prefix, epL3Prefix); ListenableFuture<Void> r = t.submit(); return Futures.transform(r, futureTrans, MoreExecutors.directExecutor()); } EndpointRpcRegistry(DataBroker dataProvider); }
EndpointRpcRegistry implements EndpointService, EpRendererAugmentationRegistry, AutoCloseable { @Override public Future<RpcResult<Void>> registerL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) { if (input.getL3Context() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have L3Context.") .build()); } if (input.getIpPrefix() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have ip-prefix.") .build()); } if (input.getTenant() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.") .build()); } WriteTransaction t = dataProvider.newWriteOnlyTransaction(); long timestamp = System.currentTimeMillis(); EndpointL3PrefixKey epL3PrefixKey = new EndpointL3PrefixKey(input.getIpPrefix(), input.getL3Context()); EndpointL3Prefix epL3Prefix = buildL3PrefixEndpoint(input).setTimestamp(timestamp).build(); InstanceIdentifier<EndpointL3Prefix> iid_l3prefix = InstanceIdentifier.builder(Endpoints.class).child(EndpointL3Prefix.class, epL3PrefixKey).build(); t.put(LogicalDatastoreType.OPERATIONAL, iid_l3prefix, epL3Prefix); ListenableFuture<Void> r = t.submit(); return Futures.transform(r, futureTrans, MoreExecutors.directExecutor()); } EndpointRpcRegistry(DataBroker dataProvider); @Override void register(EpRendererAugmentation epRendererAugmentation); @Override void unregister(EpRendererAugmentation regImp); @Override void close(); @Override Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input); @Override Future<RpcResult<Void>> registerL3PrefixEndpoint(RegisterL3PrefixEndpointInput input); @Override Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input); @Override Future<RpcResult<Void>> setEndpointGroupConditions(SetEndpointGroupConditionsInput input); @Override Future<RpcResult<Void>> unsetEndpointGroupConditions(UnsetEndpointGroupConditionsInput input); }
EndpointRpcRegistry implements EndpointService, EpRendererAugmentationRegistry, AutoCloseable { @Override public Future<RpcResult<Void>> registerL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) { if (input.getL3Context() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have L3Context.") .build()); } if (input.getIpPrefix() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have ip-prefix.") .build()); } if (input.getTenant() == null) { return Futures.immediateFuture(RpcResultBuilder.<Void>failed() .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.") .build()); } WriteTransaction t = dataProvider.newWriteOnlyTransaction(); long timestamp = System.currentTimeMillis(); EndpointL3PrefixKey epL3PrefixKey = new EndpointL3PrefixKey(input.getIpPrefix(), input.getL3Context()); EndpointL3Prefix epL3Prefix = buildL3PrefixEndpoint(input).setTimestamp(timestamp).build(); InstanceIdentifier<EndpointL3Prefix> iid_l3prefix = InstanceIdentifier.builder(Endpoints.class).child(EndpointL3Prefix.class, epL3PrefixKey).build(); t.put(LogicalDatastoreType.OPERATIONAL, iid_l3prefix, epL3Prefix); ListenableFuture<Void> r = t.submit(); return Futures.transform(r, futureTrans, MoreExecutors.directExecutor()); } EndpointRpcRegistry(DataBroker dataProvider); @Override void register(EpRendererAugmentation epRendererAugmentation); @Override void unregister(EpRendererAugmentation regImp); @Override void close(); @Override Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input); @Override Future<RpcResult<Void>> registerL3PrefixEndpoint(RegisterL3PrefixEndpointInput input); @Override Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input); @Override Future<RpcResult<Void>> setEndpointGroupConditions(SetEndpointGroupConditionsInput input); @Override Future<RpcResult<Void>> unsetEndpointGroupConditions(UnsetEndpointGroupConditionsInput input);  }