@Test public void testAnnotatedEncassMetadata_ExcludingOptionalAnnotationFields() throws JsonProcessingException { BundleEntityBuilder builder = createBundleEntityBuilder(); Bundle bundle = createBundle(ENCASS_POLICY_WITH_ENV_DEPENDENCIES, true, true, true, projectInfo); Encass encass = buildTestEncassWithAnnotation(TEST_GUID, TEST_ENCASS_POLICY, true); encass.getAnnotations().forEach(a -> { a.setId(null); a.setName(null); a.setDescription(null); a.setTags(Collections.emptySet()); }); bundle.putAllEncasses(ImmutableMap.of(TEST_ENCASS, encass)); Map<String, BundleArtifacts> bundles = builder.build(bundle, EntityBuilder.BundleType.DEPLOYMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), projectInfo); assertNotNull(bundles); assertEquals(1, bundles.size()); BundleMetadata metadata = bundles.get("my-bundle-" + encass.getName() + "-1.0").getBundleMetadata(); assertNotNull(metadata); assertNotNull(metadata.getDefinedEntities().iterator().next().getId()); assertEquals("my-bundle-" + encass.getName(), metadata.getName()); assertEquals(encass.getProperties().get("description"), metadata.getDescription()); assertEquals(0, metadata.getTags().size()); verifyAnnotatedEncassBundleMetadata(bundles, bundle, encass, true, true, true); }
public BundleMetadata build(final AnnotatedBundle annotatedBundle, final Bundle bundle, final List<Entity> dependentEntities, ProjectInfo projectInfo) { if (annotatedBundle != null && annotatedBundle.getAnnotatedEntity() != null) { AnnotatedEntity<? extends GatewayEntity> annotatedEntity = annotatedBundle.getAnnotatedEntity(); final String bundleName = annotatedBundle.getBundleName(); String name = bundleName; if (StringUtils.isNotBlank(projectInfo.getVersion())) { name = bundleName.substring(0, bundleName.indexOf(projectInfo.getVersion()) - 1); } BundleMetadata.Builder builder = new BundleMetadata.Builder(annotatedEntity.getEntityType(), name, projectInfo.getName(), projectInfo.getGroupName(), projectInfo.getVersion()); builder.description(annotatedEntity.getDescription()); final Collection<Metadata> referencedEntities = getEnvironmentDependenciesMetadata(dependentEntities); builder.referencedEntities(referencedEntities); if (!referencedEntities.isEmpty()) { annotatedBundle.getDependentBundles().add(generateDependentEnvBundleFromProject(projectInfo)); } builder.dependencies(annotatedBundle.getDependentBundles()); builder.tags(annotatedEntity.getTags()); builder.redeployable(annotatedEntity.isRedeployable() || (MappingActions.NEW_OR_UPDATE.equals(EntityBuilderHelper.getDefaultEntityMappingAction()) && !isBundleContainsSharedEntity(annotatedBundle))); builder.l7Template(annotatedEntity.isL7Template()); builder.hasRouting(hasRoutingAssertion(dependentEntities)); final List<Metadata> definedEntities = new ArrayList<>(); definedEntities.add(annotatedEntity.getEntity().getMetadata()); return builder.definedEntities(definedEntities).build(); } else { return buildFullBundleMetadata(dependentEntities, bundle, projectInfo); } }
BundleMetadataBuilder { public BundleMetadata build(final AnnotatedBundle annotatedBundle, final Bundle bundle, final List<Entity> dependentEntities, ProjectInfo projectInfo) { if (annotatedBundle != null && annotatedBundle.getAnnotatedEntity() != null) { AnnotatedEntity<? extends GatewayEntity> annotatedEntity = annotatedBundle.getAnnotatedEntity(); final String bundleName = annotatedBundle.getBundleName(); String name = bundleName; if (StringUtils.isNotBlank(projectInfo.getVersion())) { name = bundleName.substring(0, bundleName.indexOf(projectInfo.getVersion()) - 1); } BundleMetadata.Builder builder = new BundleMetadata.Builder(annotatedEntity.getEntityType(), name, projectInfo.getName(), projectInfo.getGroupName(), projectInfo.getVersion()); builder.description(annotatedEntity.getDescription()); final Collection<Metadata> referencedEntities = getEnvironmentDependenciesMetadata(dependentEntities); builder.referencedEntities(referencedEntities); if (!referencedEntities.isEmpty()) { annotatedBundle.getDependentBundles().add(generateDependentEnvBundleFromProject(projectInfo)); } builder.dependencies(annotatedBundle.getDependentBundles()); builder.tags(annotatedEntity.getTags()); builder.redeployable(annotatedEntity.isRedeployable() || (MappingActions.NEW_OR_UPDATE.equals(EntityBuilderHelper.getDefaultEntityMappingAction()) && !isBundleContainsSharedEntity(annotatedBundle))); builder.l7Template(annotatedEntity.isL7Template()); builder.hasRouting(hasRoutingAssertion(dependentEntities)); final List<Metadata> definedEntities = new ArrayList<>(); definedEntities.add(annotatedEntity.getEntity().getMetadata()); return builder.definedEntities(definedEntities).build(); } else { return buildFullBundleMetadata(dependentEntities, bundle, projectInfo); } } }
BundleMetadataBuilder { public BundleMetadata build(final AnnotatedBundle annotatedBundle, final Bundle bundle, final List<Entity> dependentEntities, ProjectInfo projectInfo) { if (annotatedBundle != null && annotatedBundle.getAnnotatedEntity() != null) { AnnotatedEntity<? extends GatewayEntity> annotatedEntity = annotatedBundle.getAnnotatedEntity(); final String bundleName = annotatedBundle.getBundleName(); String name = bundleName; if (StringUtils.isNotBlank(projectInfo.getVersion())) { name = bundleName.substring(0, bundleName.indexOf(projectInfo.getVersion()) - 1); } BundleMetadata.Builder builder = new BundleMetadata.Builder(annotatedEntity.getEntityType(), name, projectInfo.getName(), projectInfo.getGroupName(), projectInfo.getVersion()); builder.description(annotatedEntity.getDescription()); final Collection<Metadata> referencedEntities = getEnvironmentDependenciesMetadata(dependentEntities); builder.referencedEntities(referencedEntities); if (!referencedEntities.isEmpty()) { annotatedBundle.getDependentBundles().add(generateDependentEnvBundleFromProject(projectInfo)); } builder.dependencies(annotatedBundle.getDependentBundles()); builder.tags(annotatedEntity.getTags()); builder.redeployable(annotatedEntity.isRedeployable() || (MappingActions.NEW_OR_UPDATE.equals(EntityBuilderHelper.getDefaultEntityMappingAction()) && !isBundleContainsSharedEntity(annotatedBundle))); builder.l7Template(annotatedEntity.isL7Template()); builder.hasRouting(hasRoutingAssertion(dependentEntities)); final List<Metadata> definedEntities = new ArrayList<>(); definedEntities.add(annotatedEntity.getEntity().getMetadata()); return builder.definedEntities(definedEntities).build(); } else { return buildFullBundleMetadata(dependentEntities, bundle, projectInfo); } } @Inject  BundleMetadataBuilder(final IdGenerator idGenerator); }
BundleMetadataBuilder { public BundleMetadata build(final AnnotatedBundle annotatedBundle, final Bundle bundle, final List<Entity> dependentEntities, ProjectInfo projectInfo) { if (annotatedBundle != null && annotatedBundle.getAnnotatedEntity() != null) { AnnotatedEntity<? extends GatewayEntity> annotatedEntity = annotatedBundle.getAnnotatedEntity(); final String bundleName = annotatedBundle.getBundleName(); String name = bundleName; if (StringUtils.isNotBlank(projectInfo.getVersion())) { name = bundleName.substring(0, bundleName.indexOf(projectInfo.getVersion()) - 1); } BundleMetadata.Builder builder = new BundleMetadata.Builder(annotatedEntity.getEntityType(), name, projectInfo.getName(), projectInfo.getGroupName(), projectInfo.getVersion()); builder.description(annotatedEntity.getDescription()); final Collection<Metadata> referencedEntities = getEnvironmentDependenciesMetadata(dependentEntities); builder.referencedEntities(referencedEntities); if (!referencedEntities.isEmpty()) { annotatedBundle.getDependentBundles().add(generateDependentEnvBundleFromProject(projectInfo)); } builder.dependencies(annotatedBundle.getDependentBundles()); builder.tags(annotatedEntity.getTags()); builder.redeployable(annotatedEntity.isRedeployable() || (MappingActions.NEW_OR_UPDATE.equals(EntityBuilderHelper.getDefaultEntityMappingAction()) && !isBundleContainsSharedEntity(annotatedBundle))); builder.l7Template(annotatedEntity.isL7Template()); builder.hasRouting(hasRoutingAssertion(dependentEntities)); final List<Metadata> definedEntities = new ArrayList<>(); definedEntities.add(annotatedEntity.getEntity().getMetadata()); return builder.definedEntities(definedEntities).build(); } else { return buildFullBundleMetadata(dependentEntities, bundle, projectInfo); } } @Inject  BundleMetadataBuilder(final IdGenerator idGenerator); BundleMetadata build(final AnnotatedBundle annotatedBundle, final Bundle bundle, final List<Entity> dependentEntities,
                                ProjectInfo projectInfo); BundleMetadata buildEnvironmentMetadata(final List<Entity> entities, ProjectInfo projectInfo); }
BundleMetadataBuilder { public BundleMetadata build(final AnnotatedBundle annotatedBundle, final Bundle bundle, final List<Entity> dependentEntities, ProjectInfo projectInfo) { if (annotatedBundle != null && annotatedBundle.getAnnotatedEntity() != null) { AnnotatedEntity<? extends GatewayEntity> annotatedEntity = annotatedBundle.getAnnotatedEntity(); final String bundleName = annotatedBundle.getBundleName(); String name = bundleName; if (StringUtils.isNotBlank(projectInfo.getVersion())) { name = bundleName.substring(0, bundleName.indexOf(projectInfo.getVersion()) - 1); } BundleMetadata.Builder builder = new BundleMetadata.Builder(annotatedEntity.getEntityType(), name, projectInfo.getName(), projectInfo.getGroupName(), projectInfo.getVersion()); builder.description(annotatedEntity.getDescription()); final Collection<Metadata> referencedEntities = getEnvironmentDependenciesMetadata(dependentEntities); builder.referencedEntities(referencedEntities); if (!referencedEntities.isEmpty()) { annotatedBundle.getDependentBundles().add(generateDependentEnvBundleFromProject(projectInfo)); } builder.dependencies(annotatedBundle.getDependentBundles()); builder.tags(annotatedEntity.getTags()); builder.redeployable(annotatedEntity.isRedeployable() || (MappingActions.NEW_OR_UPDATE.equals(EntityBuilderHelper.getDefaultEntityMappingAction()) && !isBundleContainsSharedEntity(annotatedBundle))); builder.l7Template(annotatedEntity.isL7Template()); builder.hasRouting(hasRoutingAssertion(dependentEntities)); final List<Metadata> definedEntities = new ArrayList<>(); definedEntities.add(annotatedEntity.getEntity().getMetadata()); return builder.definedEntities(definedEntities).build(); } else { return buildFullBundleMetadata(dependentEntities, bundle, projectInfo); } } @Inject  BundleMetadataBuilder(final IdGenerator idGenerator); BundleMetadata build(final AnnotatedBundle annotatedBundle, final Bundle bundle, final List<Entity> dependentEntities,
                                ProjectInfo projectInfo); BundleMetadata buildEnvironmentMetadata(final List<Entity> entities, ProjectInfo projectInfo);  }