@Test
public void testEnvironmentBundleMetadata() throws JsonProcessingException {

    BundleEntityBuilder builder = createBundleEntityBuilder();
    // create un-annotated bundle
    Bundle bundle = createBundle(ENCASS_POLICY_WITH_ENV_DEPENDENCIES, true, true, false, projectInfo);
    // create encass with the empty set of annotations and add it to the bundle
    Encass encass = buildTestEncassWithAnnotation(TEST_ENCASS, TEST_ENCASS_ID, TEST_GUID, TEST_ENCASS_POLICY, Collections.emptySet());
    bundle.putAllEncasses(ImmutableMap.of(TEST_ENCASS, encass));
    Map<String, BundleArtifacts> bundles = builder.build(bundle, EntityBuilder.BundleType.ENVIRONMENT,
            DocumentTools.INSTANCE.getDocumentBuilder().newDocument(), projectInfo, true);
    assertNotNull(bundles);
    assertEquals(1, bundles.size());
    BundleMetadata metadata = bundles.get(projectInfo.getName() + "-" + projectInfo.getVersion()).getBundleMetadata();
    assertNotNull(metadata);
    assertEquals(projectInfo.getName() + "-environment", metadata.getName());
    assertEquals(projectInfo.getGroupName(), metadata.getGroupName());
    assertEquals(projectInfo.getVersion() + "-qa", metadata.getVersion());
    assertEquals(EntityBuilder.BundleType.ENVIRONMENT.name(), metadata.getType());
    assertEquals(StringUtils.EMPTY, metadata.getDescription());
    List<String> tags = new ArrayList<>();
    tags.add("qa");
    assertEquals(tags, metadata.getTags());
    assertTrue(metadata.isRedeployable());
    assertFalse(metadata.isL7Template());
    Collection<Metadata> definedEntities = metadata.getDefinedEntities();
    assertEquals(3, definedEntities.size());
    definedEntities.stream().forEach(definedEntityData -> {
        switch (definedEntityData.getType()) {
            case EntityTypes.JDBC_CONNECTION:
                assertEquals("::" + metadata.getGroupName() + "::" + "some-jdbc" + "::1.0", definedEntityData.getName());
                break;
            case EntityTypes.TRUSTED_CERT_TYPE:
                assertEquals("apim-hugh-new.lvn.broadcom.net", definedEntityData.getName());
                break;
            case EntityTypes.STORED_PASSWORD_TYPE:
                assertEquals("secure-pass", definedEntityData.getName());
                break;
            default:
                break;
        }
    });
}