@Test public void testProcessSgtInfo() throws Exception { final SgtInfo sgtInfo1 = new SgtInfo(SGT_1, EPG_NAME_1, SGT_1_UUID); final SgtInfo sgtInfo2 = new SgtInfo(SGT_2, EPG_NAME_2, SGT_2_UUID); final CheckedFuture<Void, TransactionCommitFailedException> outcome = generator.processSgtInfo(TENANT_ID, Lists.newArrayList(sgtInfo1, sgtInfo2)); outcome.get(10, TimeUnit.SECONDS); final EndpointGroupId epgId1 = new EndpointGroupId(EPG_NAME_1); final InstanceIdentifier<EndpointGroup> epgPath1 = IidFactory.endpointGroupIid(TENANT_ID, epgId1); final EndpointGroup epg1 = createEpg(epgId1, SGT_1.getValue()); final EndpointGroupId epgId2 = new EndpointGroupId(EPG_NAME_2); final InstanceIdentifier<EndpointGroup> epgPath2 = IidFactory.endpointGroupIid(TENANT_ID, epgId2); final EndpointGroup epg2 = createEpg(epgId2, SGT_2.getValue()); final InOrder inOrder = Mockito.inOrder(wTx); inOrder.verify(wTx, Mockito.calls(1)).put(LogicalDatastoreType.CONFIGURATION, epgPath1, epg1, true); inOrder.verify(wTx, Mockito.calls(1)).put(LogicalDatastoreType.CONFIGURATION, epgPath2, epg2, false); inOrder.verify(wTx).submit(); Mockito.verifyZeroInteractions(wTx); }
@Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Integer sgtValue = sgtInfo.getSgt().getValue(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgtValue, sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtName); final InstanceIdentifier<EndpointGroup> epgPath = IidFactory.endpointGroupIid(tenantId, epgId); final EndpointGroup epg = new EndpointGroupBuilder() .setId(epgId) .setDescription(new Description("imported from ISE for sgt=" + sgtValue)) .setName(new Name(sgtName.replaceAll(" ", "_") + "--" + sgtValue)) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epgPath, epg, createParent); createParent = false; } return wTx.submit(); }
SgtToEpgGeneratorImpl implements SgtInfoProcessor { @Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Integer sgtValue = sgtInfo.getSgt().getValue(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgtValue, sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtName); final InstanceIdentifier<EndpointGroup> epgPath = IidFactory.endpointGroupIid(tenantId, epgId); final EndpointGroup epg = new EndpointGroupBuilder() .setId(epgId) .setDescription(new Description("imported from ISE for sgt=" + sgtValue)) .setName(new Name(sgtName.replaceAll(" ", "_") + "--" + sgtValue)) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epgPath, epg, createParent); createParent = false; } return wTx.submit(); } }
SgtToEpgGeneratorImpl implements SgtInfoProcessor { @Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Integer sgtValue = sgtInfo.getSgt().getValue(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgtValue, sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtName); final InstanceIdentifier<EndpointGroup> epgPath = IidFactory.endpointGroupIid(tenantId, epgId); final EndpointGroup epg = new EndpointGroupBuilder() .setId(epgId) .setDescription(new Description("imported from ISE for sgt=" + sgtValue)) .setName(new Name(sgtName.replaceAll(" ", "_") + "--" + sgtValue)) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epgPath, epg, createParent); createParent = false; } return wTx.submit(); } SgtToEpgGeneratorImpl(final DataBroker dataBroker); }
SgtToEpgGeneratorImpl implements SgtInfoProcessor { @Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Integer sgtValue = sgtInfo.getSgt().getValue(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgtValue, sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtName); final InstanceIdentifier<EndpointGroup> epgPath = IidFactory.endpointGroupIid(tenantId, epgId); final EndpointGroup epg = new EndpointGroupBuilder() .setId(epgId) .setDescription(new Description("imported from ISE for sgt=" + sgtValue)) .setName(new Name(sgtName.replaceAll(" ", "_") + "--" + sgtValue)) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epgPath, epg, createParent); createParent = false; } return wTx.submit(); } SgtToEpgGeneratorImpl(final DataBroker dataBroker); @Override CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos); }
SgtToEpgGeneratorImpl implements SgtInfoProcessor { @Override public CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos) { final WriteTransaction wTx = dataBroker.newWriteOnlyTransaction(); boolean createParent = true; for (SgtInfo sgtInfo : sgtInfos) { final Integer sgtValue = sgtInfo.getSgt().getValue(); final String sgtName = sgtInfo.getName(); LOG.trace("processing sgtInfo: {} - {}", sgtValue, sgtName); final EndpointGroupId epgId = new EndpointGroupId(sgtName); final InstanceIdentifier<EndpointGroup> epgPath = IidFactory.endpointGroupIid(tenantId, epgId); final EndpointGroup epg = new EndpointGroupBuilder() .setId(epgId) .setDescription(new Description("imported from ISE for sgt=" + sgtValue)) .setName(new Name(sgtName.replaceAll(" ", "_") + "--" + sgtValue)) .build(); wTx.put(LogicalDatastoreType.CONFIGURATION, epgPath, epg, createParent); createParent = false; } return wTx.submit(); } SgtToEpgGeneratorImpl(final DataBroker dataBroker); @Override CheckedFuture<Void, TransactionCommitFailedException> processSgtInfo(final TenantId tenantId, final List<SgtInfo> sgtInfos);  }