@Test
void buildEncassDeploymentWithWrongGuidAndId() {

    final Bundle bundle = new Bundle();
    EncassEntityBuilder builder = new EncassEntityBuilder(ID_GENERATOR);
    Encass encass = buildTestEncass(TEST_GUID, TEST_GOID, TEST_POLICY_PATH);
    encass.setName(TEST_ENCASS);
    Set<Annotation> annotations = new HashSet<>();
    Annotation annotation = new Annotation(AnnotationType.BUNDLE_HINTS);
    annotation.setGuid("");
    annotation.setId("");
    annotations.add(annotation);
    annotations.add(new Annotation(AnnotationType.SHARED));
    encass.setAnnotations(annotations);
    encass.setParentEntityShared(encass.getAnnotations().contains(new Annotation(AnnotationType.SHARED)));
    bundle.putAllEncasses(ImmutableMap.of(TEST_ENCASS, encass));
    Policy policy = new Policy();
    policy.setName(TEST_POLICY_PATH);
    policy.setId(TEST_POLICY_ID);
    bundle.getPolicies().put(TEST_POLICY_PATH, policy);
    AnnotatedEntity annotatedEntity = encass.getAnnotatedEntity();
    AnnotatedBundle annotatedBundle = new AnnotatedBundle(bundle, annotatedEntity, projectInfo);
    annotatedBundle.putAllEncasses(ImmutableMap.of(TEST_ENCASS, encass));
    annotatedBundle.getPolicies().put(TEST_POLICY_PATH, policy);
    List<Entity> entities = builder.build(annotatedBundle, BundleType.DEPLOYMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument());
    assertFalse(entities.isEmpty());
    assertEquals(1, entities.size());
    Entity entity = entities.get(0);
    String name = annotatedBundle.applyUniqueName(TEST_ENCASS, BundleType.DEPLOYMENT, true);
    assertEquals(name, entity.getName());
    assertNotNull(entity.getId(), TEST_GOID);
    assertEquals(entity.getGuid(), TEST_GUID);
    annotations = new HashSet<>();
    annotation = new Annotation(AnnotationType.BUNDLE_HINTS);
    annotation.setGuid("wrongGuid");
    annotation.setId("wrongId");
    annotations.add(annotation);
    annotations.add(new Annotation(AnnotationType.SHARED));
    encass.setAnnotations(annotations);
    encass.setParentEntityShared(encass.getAnnotations().contains(new Annotation(AnnotationType.SHARED)));
    encass.setAnnotatedEntity(null);
    annotatedEntity = encass.getAnnotatedEntity();
    annotatedBundle = new AnnotatedBundle(bundle, annotatedEntity, projectInfo);
    annotatedBundle.putAllEncasses(ImmutableMap.of(TEST_ENCASS, encass));
    annotatedBundle.getPolicies().put(TEST_POLICY_PATH, policy);
    entities = builder.build(annotatedBundle, BundleType.DEPLOYMENT, DocumentTools.INSTANCE.getDocumentBuilder().newDocument());
    entity = entities.get(0);
    name = annotatedBundle.applyUniqueName(TEST_ENCASS, BundleType.DEPLOYMENT, true);
    assertEquals(name, entity.getName());
    assertNotNull(entity.getId(), TEST_GOID);
    assertEquals(entity.getGuid(), TEST_GUID);
}