@Test public void testBuildAddressEndpointWithLocationAugmentation() throws Exception { final TenantId tenantId = new TenantId("tn1"); final AddressEndpoint endpoint = new AddressEndpointBuilder() .setTenant(tenantId) .setCondition(buildConditions(new String[]{"cn2", "cn1"})) .setEndpointGroup(buildEndpointGroupIds(new String[]{"epg2", "epg1"})) .build(); Mockito.doCallRealMethod().when(keyFactory).sortValueKeyLists(Matchers.<EndpointPolicyTemplateBySgt>any()); final List<ConditionName> conditions = buildConditions(new String[]{"cn1", "cn2"}); final List<EndpointGroupId> endpointGroupIds = buildEndpointGroupIds(new String[]{"epg1", "epg2"}); final EndpointPolicyTemplateBySgt epPolicyTemplate = new EndpointPolicyTemplateBySgtBuilder() .setTenant(tenantId) .setEndpointGroups(endpointGroupIds) .setConditions(conditions) .setSgt(new Sgt(42)) .build(); Mockito.when(epPolicyDao.readBy(keyCapt.capture())).thenReturn(Collections.singletonList(epPolicyTemplate)); final Map.Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> augmentationEntry = augmetor.buildAddressEndpointWithLocationAugmentation(endpoint); final EpPolicyTemplateValueKey keyValue = keyCapt.getValue(); Assert.assertEquals(tenantId, keyValue.getTenantId()); Assert.assertEquals(endpointGroupIds, keyValue.getEpgId()); Assert.assertEquals(conditions, keyValue.getConditionName()); }
@Override public Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> buildAddressEndpointWithLocationAugmentation( AddressEndpoint input) { final EpPolicyTemplateValueKey templateValueKey = epPolicyTemplateKeyFactory.createKey( input.getTenant(), input.getEndpointGroup(), input.getCondition()); final Collection<EndpointPolicyTemplateBySgt> epPolicyTemplates = epPolicyTemplateDao.readBy(templateValueKey); final Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> entry; if (epPolicyTemplates.isEmpty()) { entry = null; } else { } return null; }
SxpEndpointAugmentorImpl implements EndpointAugmentor { @Override public Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> buildAddressEndpointWithLocationAugmentation( AddressEndpoint input) { final EpPolicyTemplateValueKey templateValueKey = epPolicyTemplateKeyFactory.createKey( input.getTenant(), input.getEndpointGroup(), input.getCondition()); final Collection<EndpointPolicyTemplateBySgt> epPolicyTemplates = epPolicyTemplateDao.readBy(templateValueKey); final Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> entry; if (epPolicyTemplates.isEmpty()) { entry = null; } else { } return null; } }
SxpEndpointAugmentorImpl implements EndpointAugmentor { @Override public Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> buildAddressEndpointWithLocationAugmentation( AddressEndpoint input) { final EpPolicyTemplateValueKey templateValueKey = epPolicyTemplateKeyFactory.createKey( input.getTenant(), input.getEndpointGroup(), input.getCondition()); final Collection<EndpointPolicyTemplateBySgt> epPolicyTemplates = epPolicyTemplateDao.readBy(templateValueKey); final Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> entry; if (epPolicyTemplates.isEmpty()) { entry = null; } else { } return null; } SxpEndpointAugmentorImpl(final ReadableByKey<EpPolicyTemplateValueKey, EndpointPolicyTemplateBySgt> epPolicyTemplateDao,
                                   final EpPolicyTemplateValueKeyFactory epPolicyTemplateKeyFactory); }
SxpEndpointAugmentorImpl implements EndpointAugmentor { @Override public Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> buildAddressEndpointWithLocationAugmentation( AddressEndpoint input) { final EpPolicyTemplateValueKey templateValueKey = epPolicyTemplateKeyFactory.createKey( input.getTenant(), input.getEndpointGroup(), input.getCondition()); final Collection<EndpointPolicyTemplateBySgt> epPolicyTemplates = epPolicyTemplateDao.readBy(templateValueKey); final Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> entry; if (epPolicyTemplates.isEmpty()) { entry = null; } else { } return null; } SxpEndpointAugmentorImpl(final ReadableByKey<EpPolicyTemplateValueKey, EndpointPolicyTemplateBySgt> epPolicyTemplateDao,
                                   final EpPolicyTemplateValueKeyFactory epPolicyTemplateKeyFactory); @Override Entry<Class<? extends Augmentation<AddressEndpoint>>, Augmentation<AddressEndpoint>> buildAddressEndpointAugmentation(
            AddressEndpointReg input); @Override Entry<Class<? extends Augmentation<ContainmentEndpoint>>, Augmentation<ContainmentEndpoint>> buildContainmentEndpointAugmentation(
            ContainmentEndpointReg input); @Override Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> buildAddressEndpointWithLocationAugmentation(
            AddressEndpoint input); @Override Entry<Class<? extends Augmentation<ContainmentEndpointWithLocation>>, Augmentation<ContainmentEndpointWithLocation>> buildContainmentEndpointWithLocationAugmentation(
            ContainmentEndpoint input); }
SxpEndpointAugmentorImpl implements EndpointAugmentor { @Override public Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> buildAddressEndpointWithLocationAugmentation( AddressEndpoint input) { final EpPolicyTemplateValueKey templateValueKey = epPolicyTemplateKeyFactory.createKey( input.getTenant(), input.getEndpointGroup(), input.getCondition()); final Collection<EndpointPolicyTemplateBySgt> epPolicyTemplates = epPolicyTemplateDao.readBy(templateValueKey); final Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> entry; if (epPolicyTemplates.isEmpty()) { entry = null; } else { } return null; } SxpEndpointAugmentorImpl(final ReadableByKey<EpPolicyTemplateValueKey, EndpointPolicyTemplateBySgt> epPolicyTemplateDao,
                                   final EpPolicyTemplateValueKeyFactory epPolicyTemplateKeyFactory); @Override Entry<Class<? extends Augmentation<AddressEndpoint>>, Augmentation<AddressEndpoint>> buildAddressEndpointAugmentation(
            AddressEndpointReg input); @Override Entry<Class<? extends Augmentation<ContainmentEndpoint>>, Augmentation<ContainmentEndpoint>> buildContainmentEndpointAugmentation(
            ContainmentEndpointReg input); @Override Entry<Class<? extends Augmentation<AddressEndpointWithLocation>>, Augmentation<AddressEndpointWithLocation>> buildAddressEndpointWithLocationAugmentation(
            AddressEndpoint input); @Override Entry<Class<? extends Augmentation<ContainmentEndpointWithLocation>>, Augmentation<ContainmentEndpointWithLocation>> buildContainmentEndpointWithLocationAugmentation(
            ContainmentEndpoint input);  }