IosXeDataStoreAPI implements Callable { @Override public Object call() { switch (currentTransaction) { case WRITE_FUNCTION: { try { Preconditions.checkNotNull(data); ServiceFunction serviceFunction = (ServiceFunction) data; InstanceIdentifier<ServiceFunction> serviceFunctionIid = SfcIosXeUtils .createSfIid(serviceFunction.getKey()); return writeMergeTransaction(serviceFunctionIid, serviceFunction); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of ServiceFunction", data); } break; } case READ_FUNCTION: { try { Preconditions.checkNotNull(data); SfName serviceFunction = (SfName) data; InstanceIdentifier<ServiceFunction> serviceFunctionIid = SfcIosXeUtils .createSfIid(new ServiceFunctionKey(serviceFunction.getValue())); return readTransaction(serviceFunctionIid); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of ServiceFunction", data); } break; } case DELETE_FUNCTION: { try { Preconditions.checkNotNull(data); ServiceFunctionKey serviceFunctionKey = (ServiceFunctionKey) data; InstanceIdentifier<ServiceFunction> serviceFunctionIid = SfcIosXeUtils .createSfIid(serviceFunctionKey); return deleteTransaction(serviceFunctionIid); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of ServiceFunction", data); } break; } case WRITE_LOCAL: { try { Preconditions.checkNotNull(data); Local localSff = (Local) data; InstanceIdentifier<Local> localIid = SfcIosXeUtils.createLocalSffIid(); return writeMergeTransaction(localIid, localSff); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of Local", data); } break; } case READ_LOCAL: { InstanceIdentifier<Local> localIid = SfcIosXeUtils.createLocalSffIid(); return readTransaction(localIid); } case DELETE_LOCAL: { InstanceIdentifier<Local> localIid = SfcIosXeUtils.createLocalSffIid(); return deleteTransaction(localIid); } case WRITE_REMOTE: { try { Preconditions.checkNotNull(data); ServiceFfName remoteSff = (ServiceFfName) data; InstanceIdentifier<ServiceFfName> remoteIid = SfcIosXeUtils.createRemoteSffIid(remoteSff); return writeMergeTransaction(remoteIid, remoteSff); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of ServiceFfName", data); } break; } case DELETE_REMOTE: { try { Preconditions.checkNotNull(data); ServiceFfName remoteSff = (ServiceFfName) data; InstanceIdentifier<ServiceFfName> remoteIid = SfcIosXeUtils.createRemoteSffIid(remoteSff); return deleteTransaction(remoteIid); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of ServiceFfName", data); } break; } case READ_REMOTE: { try { Preconditions.checkNotNull(data); SffName remoteSffName = (SffName) data; InstanceIdentifier<ServiceFfName> remoteIid = SfcIosXeUtils.createRemoteSffIid(remoteSffName); return readTransaction(remoteIid); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of SffName", data); } break; } case WRITE_PATH: { try { Preconditions.checkNotNull(data); ServicePath path = (ServicePath) data; InstanceIdentifier<ServicePath> pathIid = SfcIosXeUtils.createServicePathIid(path .getKey()); return writeMergeTransaction(pathIid, path); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of ServicePath", data); } break; } case READ_PATH: { try { Preconditions.checkNotNull(data); ServicePathKey pathKey = (ServicePathKey) data; InstanceIdentifier<ServicePath> pathIid = SfcIosXeUtils.createServicePathIid(pathKey); return readTransaction(pathIid); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of ServicePath", data); } break; } case DELETE_PATH: { try { Preconditions.checkNotNull(data); ServicePathKey pathKey = (ServicePathKey) data; InstanceIdentifier<ServicePath> pathIid = SfcIosXeUtils.createServicePathIid(pathKey); return deleteTransaction(pathIid); } catch (ClassCastException e) { LOG.error("Argument data {} is not an instance of ServicePathKey", data); } break; } } return null; } IosXeDataStoreAPI(DataBroker mountPoint, Object data, Transaction transaction,
                             LogicalDatastoreType datastoreType); @Override Object call();  }
@Test public void writeServiceFunction() { ServiceFunction data = buildTestServiceFunction(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_FUNCTION, LogicalDatastoreType.CONFIGURATION); boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); }
@Test public void readServiceFunction() { ServiceFunction data = buildTestServiceFunction(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new SfName(SERVICE_NAME), READ_FUNCTION, LogicalDatastoreType.CONFIGURATION); ServiceFunction function = (ServiceFunction) iosXeDataStoreAPI.call(); assertNull(function); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_FUNCTION, LogicalDatastoreType.CONFIGURATION); Boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new SfName(SERVICE_NAME), READ_FUNCTION, LogicalDatastoreType.CONFIGURATION); function = (ServiceFunction) iosXeDataStoreAPI.call(); assertEquals(buildTestServiceFunction(), function); }
@Test public void deleteServiceFunction() { ServiceFunction data = buildTestServiceFunction(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_FUNCTION, LogicalDatastoreType.CONFIGURATION); boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new SfName(SERVICE_NAME), READ_FUNCTION, LogicalDatastoreType.CONFIGURATION); ServiceFunction function = (ServiceFunction) iosXeDataStoreAPI.call(); assertEquals(buildTestServiceFunction(), function); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new ServiceFunctionKey(SERVICE_NAME), DELETE_FUNCTION, LogicalDatastoreType.CONFIGURATION); result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new SfName(SERVICE_NAME), READ_FUNCTION, LogicalDatastoreType.CONFIGURATION); function = (ServiceFunction) iosXeDataStoreAPI.call(); assertNull(function); }
@Test public void writeLocalServiceForwarder() { Local data = buildLocalServiceForwarder(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_LOCAL, LogicalDatastoreType.CONFIGURATION); boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); }
@Test public void readLocalServiceForwarder() { Local data = buildLocalServiceForwarder(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, null, READ_LOCAL, LogicalDatastoreType.CONFIGURATION); Local forwarder = (Local) iosXeDataStoreAPI.call(); assertNull(forwarder); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_LOCAL, LogicalDatastoreType.CONFIGURATION); Boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, null, READ_LOCAL, LogicalDatastoreType.CONFIGURATION); forwarder = (Local) iosXeDataStoreAPI.call(); assertEquals(buildLocalServiceForwarder(), forwarder); }
@Test public void deleteLocalServiceForwarder() { Local data = buildLocalServiceForwarder(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_LOCAL, LogicalDatastoreType.CONFIGURATION); boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, null, READ_LOCAL, LogicalDatastoreType.CONFIGURATION); Local forwarder = (Local) iosXeDataStoreAPI.call(); assertEquals(buildLocalServiceForwarder(), forwarder); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, null, DELETE_LOCAL, LogicalDatastoreType.CONFIGURATION); result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, null, READ_LOCAL, LogicalDatastoreType.CONFIGURATION); forwarder = (Local) iosXeDataStoreAPI.call(); assertNull(forwarder); }
@Test public void writeRemoteServiceForwarder() { ServiceFfName data = buildRemoteServiceForwarder(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_REMOTE, LogicalDatastoreType.CONFIGURATION); boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); }
@Test public void readRemoteServiceForwarder() { ServiceFfName data = buildRemoteServiceForwarder(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new SffName(REMOTE_FORWARDER), READ_REMOTE, LogicalDatastoreType.CONFIGURATION); ServiceFfName forwarder = (ServiceFfName) iosXeDataStoreAPI.call(); assertNull(forwarder); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_REMOTE, LogicalDatastoreType.CONFIGURATION); Boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new SffName(REMOTE_FORWARDER), READ_REMOTE, LogicalDatastoreType.CONFIGURATION); forwarder = (ServiceFfName) iosXeDataStoreAPI.call(); assertEquals(buildRemoteServiceForwarder(), forwarder); }
@Test public void deleteRemoteServiceForwarder() { ServiceFfName data = buildRemoteServiceForwarder(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_REMOTE, LogicalDatastoreType.CONFIGURATION); boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new SffName(REMOTE_FORWARDER), READ_REMOTE, LogicalDatastoreType.CONFIGURATION); ServiceFfName forwarder = (ServiceFfName) iosXeDataStoreAPI.call(); assertEquals(buildRemoteServiceForwarder(), forwarder); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, DELETE_REMOTE, LogicalDatastoreType.CONFIGURATION); result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new SffName(REMOTE_FORWARDER), READ_LOCAL, LogicalDatastoreType.CONFIGURATION); forwarder = (ServiceFfName) iosXeDataStoreAPI.call(); assertNull(forwarder); }
@Test public void writeRemovePath() { ServicePath data = buildServicePath(); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, data, WRITE_PATH, LogicalDatastoreType.CONFIGURATION); boolean result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); iosXeDataStoreAPI = new IosXeDataStoreAPI(mountpoint, new ServicePathKey(1L), DELETE_PATH, LogicalDatastoreType.CONFIGURATION); result = (boolean) iosXeDataStoreAPI.call(); assertTrue(result); }