AnnotatedBundle extends Bundle { public String getBundleName() { String name = getAnnotatedBundleName(); return StringUtils.isBlank(getProjectInfo().getVersion()) ? name : name + "-" + getProjectInfo().getVersion(); } AnnotatedBundle(Bundle fullBundle, AnnotatedEntity<? extends GatewayEntity> annotatedEntity,
                           ProjectInfo projectInfo); AnnotatedEntity<? extends GatewayEntity> getAnnotatedEntity(); void setAnnotatedEntity(AnnotatedEntity<? extends GatewayEntity> annotatedEntity); Bundle getFullBundle(); void setFullBundle(Bundle fullBundle); String getBundleName(); void addDependentBundle(DependentBundle dependentBundle); List<DependentBundle> getDependentBundles(); String getNamespace(final EntityBuilder.BundleType bundleType, boolean isShared);  }
@Test void testApplyUniqueNameForDeployment() { String uniqueSeparator = "::"; String policeName = "TestPolicy"; Encass encass = new Encass(); AnnotatedEntity<Encass> encassAnnotatedEntity = new AnnotatedEntity<>(encass); encassAnnotatedEntity.setEntityName("TestEncass"); ProjectInfo projectInfo = new ProjectInfo("TestName", "TestGroup", "unspecified"); AnnotatedBundle annotatedBundle = new AnnotatedBundle(null, encassAnnotatedEntity, projectInfo); String uniquePolicyName = annotatedBundle.applyUniqueName(policeName, EntityBuilder.BundleType.DEPLOYMENT); Assert.assertEquals(uniqueSeparator + projectInfo.getGroupName() + "." + annotatedBundle.getBundleName() + uniqueSeparator + policeName, uniquePolicyName); projectInfo = new ProjectInfo("TestName", "TestGroup", "1"); annotatedBundle = new AnnotatedBundle(null, encassAnnotatedEntity, projectInfo); uniquePolicyName = annotatedBundle.applyUniqueName(policeName, EntityBuilder.BundleType.DEPLOYMENT); Assert.assertEquals(uniqueSeparator + projectInfo.getGroupName() + "." + "TestName-TestEncass" + uniqueSeparator + policeName + uniqueSeparator + "1.0", uniquePolicyName); projectInfo = new ProjectInfo("TestName", "TestGroup", "1."); annotatedBundle = new AnnotatedBundle(null, encassAnnotatedEntity, projectInfo); uniquePolicyName = annotatedBundle.applyUniqueName(policeName, EntityBuilder.BundleType.DEPLOYMENT); Assert.assertEquals(uniqueSeparator + projectInfo.getGroupName() + "." + "TestName-TestEncass" + uniqueSeparator + policeName + uniqueSeparator + "1.0", uniquePolicyName); projectInfo = new ProjectInfo("TestName", "TestGroup", "1.2"); encassAnnotatedEntity.setBundleName("TestBundle"); annotatedBundle = new AnnotatedBundle(null, encassAnnotatedEntity, projectInfo); uniquePolicyName = annotatedBundle.applyUniqueName(policeName, EntityBuilder.BundleType.DEPLOYMENT); Assert.assertEquals(uniqueSeparator + projectInfo.getGroupName() + "." + "TestBundle" + uniqueSeparator + policeName + uniqueSeparator + "1.2", uniquePolicyName); }