"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
/**
 * Copyright 2017-2020 Plexus Interop Deutsche Bank AG
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
var path = require("path");
var files_1 = require("../../src/common/files");
var fs_extra_1 = require("fs-extra");
function getTestBaseDir() {
    return path.resolve(files_1.getBaseDir(), '../../../samples/greeting/registry');
}
exports.getTestBaseDir = getTestBaseDir;
function getInvalidTestBaseDir() {
    return path.resolve(files_1.getBaseDir(), '../../../dsl/gen/test/src/main/resources');
}
exports.getInvalidTestBaseDir = getInvalidTestBaseDir;
function getTestClientInput() {
    return 'greeting_client.interop';
}
exports.getTestClientInput = getTestClientInput;
function getApprovalsBaseDir() {
    return path.join(files_1.getBaseDir(), 'tests/approved');
}
exports.getApprovalsBaseDir = getApprovalsBaseDir;
function prepareOutDir(testName) {
    var outDir = path.join(files_1.getBaseDir(), 'dist/gen', testName);
    fs_extra_1.mkdirsSync(outDir);
    return outDir;
}
exports.prepareOutDir = prepareOutDir;
function filesEqual(first, second) {
    return tslib_1.__awaiter(this, void 0, void 0, function () {
        var firstContent, secondContent;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, files_1.readTextFile(first)];
                case 1:
                    firstContent = _a.sent();
                    return [4 /*yield*/, files_1.readTextFile(second)];
                case 2:
                    secondContent = _a.sent();
                    return [2 /*return*/, unifyWhiteSpaces(firstContent) === unifyWhiteSpaces(secondContent)];
            }
        });
    });
}
exports.filesEqual = filesEqual;
function unifyWhiteSpaces(s) {
    return s.replace(/\s+/g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