"use strict";
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
const internal_1 = require("../../../internal");
const Storage_1 = require("../../../Storage");
const testHelper_1 = require("../../testHelper");
const projectionTestUtils_1 = require("../../Utilities/projectionTestUtils");
/**
 * A test class for testing the AddTypeAttribute operation in a projection as well as TypeAttribute in a resolution guidance
 */
describe('Cdm/Projection/ProjectionAddTypeTest', () => {
    /**
     * All possible combinations of the different resolution directives
     */
    const resOptsCombinations = [
        [],
        ['referenceOnly'],
        ['normalized'],
        ['structured'],
        ['referenceOnly', 'normalized'],
        ['referenceOnly', 'structured'],
        ['normalized', 'structured'],
        ['referenceOnly', 'normalized', 'structured']
    ];
    /**
     * The path between TestDataPath and TestName.
     */
    const testsSubpath = 'Cdm/Projection/ProjectionAddTypeTest';
    /**
     * Test for creating a projection with an AddTypeAttribute operation on an entity attribute using the object model
     */
    it('TestEntityAttributeProjUsingObjectModel', () => __awaiter(void 0, void 0, void 0, function* () {
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, 'TestEntityAttributeProjUsingObjectModel');
        corpus.storage.mount('local', new Storage_1.LocalAdapter(testHelper_1.testHelper.getActualOutputFolderPath(testsSubpath, 'TestEntityAttributeProjUsingObjectModel')));
        const localRoot = corpus.storage.fetchRootFolder('local');
        // Create an entity
        const entity = projectionTestUtils_1.projectionTestUtils.createEntity(corpus, localRoot);
        // Create a projection
        const projection = projectionTestUtils_1.projectionTestUtils.createProjection(corpus, localRoot);
        // Create an AddTypeAttribute operation
        const addTypeAttrOp = corpus.MakeObject(internal_1.cdmObjectType.operationAddTypeAttributeDef);
        addTypeAttrOp.typeAttribute = corpus.MakeObject(internal_1.cdmObjectType.typeAttributeDef, 'testType');
        addTypeAttrOp.typeAttribute.dataType = corpus.MakeRef(internal_1.cdmObjectType.dataTypeRef, 'entityName', true);
        projection.operations.push(addTypeAttrOp);
        // Create an entity reference to hold this projection
        const projectionEntityRef = corpus.MakeObject(internal_1.cdmObjectType.entityRef, undefined);
        projectionEntityRef.explicitReference = projection;
        // Create an entity attribute that contains this projection and add this to the entity
        const entityAttribute = corpus.MakeObject(internal_1.cdmObjectType.entityAttributeDef, 'TestEntityAttribute');
        entityAttribute.entity = projectionEntityRef;
        entity.attributes.push(entityAttribute);
        // Resolve the entity
        const resolvedEntity = yield entity.createResolvedEntityAsync(`Resolved_${entity.entityName}.cdm.json`, undefined, localRoot);
        // Verify correctness of the resolved attributes after running the AddTypeAttribute operation
        // Original set of attributes: ["id", "name", "value", "date"]
        // Type attribute: "testType"
        expect(resolvedEntity.attributes.length)
            .toEqual(5);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('id');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('name');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('value');
        expect(resolvedEntity.attributes.allItems[3].name)
            .toEqual('date');
        expect(resolvedEntity.attributes.allItems[4].name)
            .toEqual('testType');
        expect(resolvedEntity.attributes.allItems[4].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
    }));
    /**
     * Test for creating a projection with an AddTypeAttribute operation on an entity definition using the object model
     */
    it('TestEntityProjUsingObjectModel', () => __awaiter(void 0, void 0, void 0, function* () {
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, 'TestEntityProjUsingObjectModel');
        corpus.storage.mount('local', new Storage_1.LocalAdapter(testHelper_1.testHelper.getActualOutputFolderPath(testsSubpath, 'TestEntityProjUsingObjectModel')));
        const localRoot = corpus.storage.fetchRootFolder('local');
        // Create an entity
        const entity = projectionTestUtils_1.projectionTestUtils.createEntity(corpus, localRoot);
        // Create a projection
        const projection = projectionTestUtils_1.projectionTestUtils.createProjection(corpus, localRoot);
        // Create an AddTypeAttribute operation
        const addTypeAttrOp = corpus.MakeObject(internal_1.cdmObjectType.operationAddTypeAttributeDef);
        addTypeAttrOp.typeAttribute = corpus.MakeObject(internal_1.cdmObjectType.typeAttributeDef, 'testType');
        addTypeAttrOp.typeAttribute.dataType = corpus.MakeRef(internal_1.cdmObjectType.dataTypeRef, 'entityName', true);
        projection.operations.push(addTypeAttrOp);
        // Create an entity reference to hold this projection
        const projectionEntityRef = corpus.MakeObject(internal_1.cdmObjectType.entityRef, undefined);
        projectionEntityRef.explicitReference = projection;
        // Set the entity's ExtendEntity to be the projection
        entity.extendsEntity = projectionEntityRef;
        // Resolve the entity
        const resolvedEntity = yield entity.createResolvedEntityAsync(`Resolved_${entity.entityName}.cdm.json`, undefined, localRoot);
        // Verify correctness of the resolved attributes after running the AddTypeAttribute operation
        // Original set of attributes: ["id", "name", "value", "date"]
        // Type attribute: "testType"
        expect(resolvedEntity.attributes.length)
            .toEqual(5);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('id');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('name');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('value');
        expect(resolvedEntity.attributes.allItems[3].name)
            .toEqual('date');
        expect(resolvedEntity.attributes.allItems[4].name)
            .toEqual('testType');
        expect(resolvedEntity.attributes.allItems[4].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
    }));
    /**
     * Test for creating a projection with an AddTypeAttribute operation and a condition using the object model
     */
    it('TestConditionalProjUsingObjectModel', () => __awaiter(void 0, void 0, void 0, function* () {
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, 'TestConditionalProjUsingObjectModel');
        corpus.storage.mount('local', new Storage_1.LocalAdapter(testHelper_1.testHelper.getActualOutputFolderPath(testsSubpath, 'TestConditionalProjUsingObjectModel')));
        const localRoot = corpus.storage.fetchRootFolder('local');
        // Create an entity
        const entity = projectionTestUtils_1.projectionTestUtils.createEntity(corpus, localRoot);
        // Create a projection with a condition that states the operation should only execute when the resolution directive is 'referenceOnly'
        const projection = projectionTestUtils_1.projectionTestUtils.createProjection(corpus, localRoot);
        projection.condition = 'referenceOnly==true';
        // Create an AddTypeAttribute operation
        const addTypeAttrOp = corpus.MakeObject(internal_1.cdmObjectType.operationAddTypeAttributeDef);
        addTypeAttrOp.typeAttribute = corpus.MakeObject(internal_1.cdmObjectType.typeAttributeDef, 'testType');
        addTypeAttrOp.typeAttribute.dataType = corpus.MakeRef(internal_1.cdmObjectType.dataTypeRef, 'entityName', true);
        projection.operations.push(addTypeAttrOp);
        // Create an entity reference to hold this projection
        const projectionEntityRef = corpus.MakeObject(internal_1.cdmObjectType.entityRef, undefined);
        projectionEntityRef.explicitReference = projection;
        // Create an entity attribute that contains this projection and add this to the entity
        const entityAttribute = corpus.MakeObject(internal_1.cdmObjectType.entityAttributeDef, 'TestEntityAttribute');
        entityAttribute.entity = projectionEntityRef;
        entity.attributes.push(entityAttribute);
        // Create resolution options with the 'referenceOnly' directive
        const resOpt = new internal_1.resolveOptions(entity.inDocument);
        resOpt.directives = new internal_1.AttributeResolutionDirectiveSet(new Set(['referenceOnly']));
        // Resolve the entity with 'referenceOnly'
        const resolvedEntityWithReferenceOnly = yield entity.createResolvedEntityAsync(`Resolved_${entity.entityName}.cdm.json`, resOpt, localRoot);
        // Verify correctness of the resolved attributes after running the AddTypeAttribute operation
        // Original set of attributes: ["id", "name", "value", "date"]
        // Type attribute: "testType"
        expect(resolvedEntityWithReferenceOnly.attributes.length)
            .toEqual(5);
        expect(resolvedEntityWithReferenceOnly.attributes.allItems[0].name)
            .toEqual('id');
        expect(resolvedEntityWithReferenceOnly.attributes.allItems[1].name)
            .toEqual('name');
        expect(resolvedEntityWithReferenceOnly.attributes.allItems[2].name)
            .toEqual('value');
        expect(resolvedEntityWithReferenceOnly.attributes.allItems[3].name)
            .toEqual('date');
        expect(resolvedEntityWithReferenceOnly.attributes.allItems[4].name)
            .toEqual('testType');
        expect(resolvedEntityWithReferenceOnly.attributes.allItems[4].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
        // Now resolve the entity with the 'structured' directive
        resOpt.directives = new internal_1.AttributeResolutionDirectiveSet(new Set(['structured']));
        const resolvedEntityWithStructured = yield entity.createResolvedEntityAsync(`Resolved_${entity.entityName}.cdm.json`, resOpt, localRoot);
        // Verify correctness of the resolved attributes after running the AddTypeAttribute operation
        // Original set of attributes: ["id", "name", "value", "date"]
        // No Type attribute added, condition was false
        expect(resolvedEntityWithStructured.attributes.length)
            .toEqual(4);
        expect(resolvedEntityWithStructured.attributes.allItems[0].name)
            .toEqual('id');
        expect(resolvedEntityWithStructured.attributes.allItems[1].name)
            .toEqual('name');
        expect(resolvedEntityWithStructured.attributes.allItems[2].name)
            .toEqual('value');
        expect(resolvedEntityWithStructured.attributes.allItems[3].name)
            .toEqual('date');
    }));
    /**
     * AddTypeAttribute on an entity attribute
     */
    it('TestAddTypeAttributeProj', () => __awaiter(void 0, void 0, void 0, function* () {
        const testName = 'TestAddTypeAttributeProj';
        const entityName = 'Customer';
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, testName);
        for (const resOpt of resOptsCombinations) {
            yield projectionTestUtils_1.projectionTestUtils.loadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
        }
        const entity = yield corpus.fetchObjectAsync(`local:/${entityName}.cdm.json/${entityName}`);
        const resolvedEntity = yield projectionTestUtils_1.projectionTestUtils.getResolvedEntity(corpus, entity, []);
        // Original set of attributes: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
        // Type attribute: "someType"
        expect(resolvedEntity.attributes.length)
            .toEqual(8);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('emailId');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('address');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('isPrimary');
        expect(resolvedEntity.attributes.allItems[3].name)
            .toEqual('phoneId');
        expect(resolvedEntity.attributes.allItems[4].name)
            .toEqual('number');
        expect(resolvedEntity.attributes.allItems[5].name)
            .toEqual('socialId');
        expect(resolvedEntity.attributes.allItems[6].name)
            .toEqual('account');
        expect(resolvedEntity.attributes.allItems[7].name)
            .toEqual('someType');
        expect(resolvedEntity.attributes.allItems[7].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
    }));
    /**
     * SelectedTypeAttribute on an entity attribute
     */
    it('TestSelectedTypeAttr', () => __awaiter(void 0, void 0, void 0, function* () {
        const testName = 'TestSelectedTypeAttr';
        const entityName = 'Customer';
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, testName);
        for (const resOpt of resOptsCombinations) {
            yield projectionTestUtils_1.projectionTestUtils.loadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
        }
        const entity = yield corpus.fetchObjectAsync(`local:/${entityName}.cdm.json/${entityName}`);
        const resolvedEntity = yield projectionTestUtils_1.projectionTestUtils.getResolvedEntity(corpus, entity, []);
        // Original set of attributes: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
        // Type attribute: "someType"
        expect(resolvedEntity.attributes.length)
            .toEqual(8);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('emailId');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('address');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('isPrimary');
        expect(resolvedEntity.attributes.allItems[3].name)
            .toEqual('phoneId');
        expect(resolvedEntity.attributes.allItems[4].name)
            .toEqual('number');
        expect(resolvedEntity.attributes.allItems[5].name)
            .toEqual('socialId');
        expect(resolvedEntity.attributes.allItems[6].name)
            .toEqual('account');
        expect(resolvedEntity.attributes.allItems[7].name)
            .toEqual('someType');
        expect(resolvedEntity.attributes.allItems[7].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
    }));
    /**
     * AddTypeAttribute on an entity definition
     */
    it('TestExtendsEntityProj', () => __awaiter(void 0, void 0, void 0, function* () {
        const testName = 'TestExtendsEntityProj';
        const entityName = 'Customer';
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, testName);
        for (const resOpt of resOptsCombinations) {
            yield projectionTestUtils_1.projectionTestUtils.loadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
        }
        const entity = yield corpus.fetchObjectAsync(`local:/${entityName}.cdm.json/${entityName}`);
        const resolvedEntity = yield projectionTestUtils_1.projectionTestUtils.getResolvedEntity(corpus, entity, []);
        // Original set of attributes: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
        // Type attribute: "someType"
        expect(resolvedEntity.attributes.length)
            .toEqual(8);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('emailId');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('address');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('isPrimary');
        expect(resolvedEntity.attributes.allItems[3].name)
            .toEqual('phoneId');
        expect(resolvedEntity.attributes.allItems[4].name)
            .toEqual('number');
        expect(resolvedEntity.attributes.allItems[5].name)
            .toEqual('socialId');
        expect(resolvedEntity.attributes.allItems[6].name)
            .toEqual('account');
        expect(resolvedEntity.attributes.allItems[7].name)
            .toEqual('someType');
        expect(resolvedEntity.attributes.allItems[7].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
    }));
    /**
     * SelectedTypeAttribute on an entity definition
     */
    it('TestExtendsEntity', () => __awaiter(void 0, void 0, void 0, function* () {
        const testName = 'TestExtendsEntity';
        const entityName = 'Customer';
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, testName);
        for (const resOpt of resOptsCombinations) {
            yield projectionTestUtils_1.projectionTestUtils.loadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
        }
        const entity = yield corpus.fetchObjectAsync(`local:/${entityName}.cdm.json/${entityName}`);
        const resolvedEntity = yield projectionTestUtils_1.projectionTestUtils.getResolvedEntity(corpus, entity, []);
        // Original set of attributes: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
        // Type attribute: "someType" (using extendsEntityResolutionGuidance)
        expect(resolvedEntity.attributes.length)
            .toEqual(8);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('emailId');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('address');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('isPrimary');
        expect(resolvedEntity.attributes.allItems[3].name)
            .toEqual('phoneId');
        expect(resolvedEntity.attributes.allItems[4].name)
            .toEqual('number');
        expect(resolvedEntity.attributes.allItems[5].name)
            .toEqual('socialId');
        expect(resolvedEntity.attributes.allItems[6].name)
            .toEqual('account');
        expect(resolvedEntity.attributes.allItems[7].name)
            .toEqual('someType');
        expect(resolvedEntity.attributes.allItems[7].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
    }));
    /**
     * AddTypeAttribute on an entity attribute (after a CombineAttributes)
     */
    it('TestAddTypeWithCombineProj', () => __awaiter(void 0, void 0, void 0, function* () {
        const testName = 'TestAddTypeWithCombineProj';
        const entityName = 'Customer';
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, testName);
        for (const resOpt of resOptsCombinations) {
            yield projectionTestUtils_1.projectionTestUtils.loadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
        }
        const entity = yield corpus.fetchObjectAsync(`local:/${entityName}.cdm.json/${entityName}`);
        const resolvedEntity = yield projectionTestUtils_1.projectionTestUtils.getResolvedEntity(corpus, entity, []);
        // Original set of attributes: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
        // Merge ["emailId, "phoneId, "socialId"] into "contactId", type attribute: "contactType"
        expect(resolvedEntity.attributes.length)
            .toEqual(6);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('address');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('isPrimary');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('number');
        expect(resolvedEntity.attributes.allItems[3].name)
            .toEqual('account');
        expect(resolvedEntity.attributes.allItems[4].name)
            .toEqual('contactId');
        expect(resolvedEntity.attributes.allItems[5].name)
            .toEqual('contactType');
        expect(resolvedEntity.attributes.allItems[5].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
    }));
    /**
     * AddTypeAttribute with other operations in the same projection
     */
    it('TestCombineOpsProj', () => __awaiter(void 0, void 0, void 0, function* () {
        const testName = 'TestCombineOpsProj';
        const entityName = 'Customer';
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, testName);
        for (const resOpt of resOptsCombinations) {
            yield projectionTestUtils_1.projectionTestUtils.loadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
        }
        const entity = yield corpus.fetchObjectAsync(`local:/${entityName}.cdm.json/${entityName}`);
        const resolvedEntity = yield projectionTestUtils_1.projectionTestUtils.getResolvedEntity(corpus, entity, []);
        // Original set of attributes: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
        // Type attribute: "someType", rename "address" to "homeAddress"
        expect(resolvedEntity.attributes.length)
            .toEqual(9);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('emailId');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('address');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('isPrimary');
        expect(resolvedEntity.attributes.allItems[3].name)
            .toEqual('phoneId');
        expect(resolvedEntity.attributes.allItems[4].name)
            .toEqual('number');
        expect(resolvedEntity.attributes.allItems[5].name)
            .toEqual('socialId');
        expect(resolvedEntity.attributes.allItems[6].name)
            .toEqual('account');
        expect(resolvedEntity.attributes.allItems[7].name)
            .toEqual('someType');
        expect(resolvedEntity.attributes.allItems[7].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
        expect(resolvedEntity.attributes.allItems[8].name)
            .toEqual('homeAddress');
    }));
    /**
     * Nested projections with AddTypeAttribute and other operations
     */
    it('TestCombineOpsNestedProj', () => __awaiter(void 0, void 0, void 0, function* () {
        const testName = 'TestCombineOpsNestedProj';
        const entityName = 'Customer';
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, testName);
        for (const resOpt of resOptsCombinations) {
            yield projectionTestUtils_1.projectionTestUtils.loadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
        }
        const entity = yield corpus.fetchObjectAsync(`local:/${entityName}.cdm.json/${entityName}`);
        const resolvedEntity = yield projectionTestUtils_1.projectionTestUtils.getResolvedEntity(corpus, entity, []);
        // Original set of attributes: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
        // Merge ["emailId, "phoneId, "socialId"] into "contactId", type attribute: "contactType",
        // rename ["contactId", "isPrimary"] as "new_{m}", include ["contactId", "new_isPrimary", "contactType"]
        expect(resolvedEntity.attributes.length)
            .toEqual(3);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('new_contactId');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('new_isPrimary');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('contactType');
        expect(resolvedEntity.attributes.allItems[2].appliedTraits.allItems[4].namedReference)
            .toEqual('is.linkedEntity.name');
    }));
    /**
     * AddTypeAttribute with a condition
     */
    it('TestConditionalProj', () => __awaiter(void 0, void 0, void 0, function* () {
        const testName = 'TestConditionalProj';
        const entityName = 'Customer';
        const corpus = testHelper_1.testHelper.getLocalCorpus(testsSubpath, testName);
        for (const resOpt of resOptsCombinations) {
            yield projectionTestUtils_1.projectionTestUtils.loadEntityForResolutionOptionAndSave(corpus, testName, testsSubpath, entityName, resOpt);
        }
        const entity = yield corpus.fetchObjectAsync(`local:/${entityName}.cdm.json/${entityName}`);
        const resolvedEntity = yield projectionTestUtils_1.projectionTestUtils.getResolvedEntity(corpus, entity, []);
        // Original set of attributes: ["emailId", "address", "isPrimary", "phoneId", "number", "socialId", "account"]
        // Merge ["emailId, "phoneId, "socialId"] into "contactId", type attribute: "contactType"
        // Condition for projection containing AddTypeAttribute is false, so no Type attribute is created
        expect(resolvedEntity.attributes.length)
            .toEqual(5);
        expect(resolvedEntity.attributes.allItems[0].name)
            .toEqual('address');
        expect(resolvedEntity.attributes.allItems[1].name)
            .toEqual('isPrimary');
        expect(resolvedEntity.attributes.allItems[2].name)
            .toEqual('number');
        expect(resolvedEntity.attributes.allItems[3].name)
            .toEqual('account');
        expect(resolvedEntity.attributes.allItems[4].name)
            .toEqual('contactId');
    }));
});
//# sourceMappingURL=ProjectionAddType.test.js.map