<commit_before>/* global describe, beforeEach, it*/


const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const fse = require('fs-extra');

const expectedFiles = {
    dockercompose: [
        'docker-compose.yml',
        'jhipster-registry.yml',
        'central-server-config/application.yml'
    ],
    elk: [
        'jhipster-console.yml',
        'log-conf/logstash.conf'
    ],
    prometheus: [
        'prometheus.yml',
        'prometheus-conf/alert.rules',
        'prometheus-conf/prometheus.yml',
        'alertmanager-conf/config.yml'
    ],
    monolith: [
        'docker-compose.yml'
    ]
};

describe('JHipster Docker Compose Sub Generator', () => {
    describe('only gateway', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'no'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('only one microservice', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'no'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('gateway and one microservice', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'no'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('gateway and one microservice, with elk', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'elk'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', () => {
            assert.file(expectedFiles.elk);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('gateway and one microservice, with prometheus', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'prometheus'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {<commit_msg>Add tests for docker-compose zipkin and curator<commit_after>/* global describe, beforeEach, it*/


const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
const fse = require('fs-extra');

const expectedFiles = {
    dockercompose: [
        'docker-compose.yml',
        'jhipster-registry.yml',
        'central-server-config/application.yml'
    ],
    elk: [
        'jhipster-console.yml',
        'log-conf/logstash.conf'
    ],
    prometheus: [
        'prometheus.yml',
        'prometheus-conf/alert.rules',
        'prometheus-conf/prometheus.yml',
        'alertmanager-conf/config.yml'
    ],
    monolith: [
        'docker-compose.yml'
    ]
};

describe('JHipster Docker Compose Sub Generator', () => {
    describe('only gateway', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'no'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('only one microservice', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'no'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('gateway and one microservice', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'no'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('gateway and one microservice, with elk', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'elk'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', () => {
            assert.file(expectedFiles.elk);
        });
        it('creates compose file without zipkin, without curator', () => {
            assert.noFileContent('docker-compose.yml', /jhipster-zipkin/);
            assert.noFileContent('docker-compose.yml', /jhipster-curator/);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('no prometheus files', () => {
            assert.noFile(expectedFiles.prometheus);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('gateway and one microservice, with zipkin', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'elk',
                    consoleOptions: [
                        'zipkin'
                    ]
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', () => {
            assert.file(expectedFiles.elk);
        });
        it('creates compose file with zipkin, without curator', () => {
            assert.fileContent('docker-compose.yml', /jhipster-zipkin/);
            assert.noFileContent('docker-compose.yml', /jhipster-curator/);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('no prometheus files', () => {
            assert.noFile(expectedFiles.prometheus);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('gateway and one microservice, with curator', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'elk',
                    consoleOptions: [
                        'curator'
                    ]
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', () => {
            assert.file(expectedFiles.elk);
        });
        it('creates compose file without zipkin, with curator', () => {
            assert.noFileContent('docker-compose.yml', /jhipster-zipkin/);
            assert.fileContent('docker-compose.yml', /jhipster-curator/);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('no prometheus files', () => {
            assert.noFile(expectedFiles.prometheus);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('gateway and one microservice, with zipkin and curator', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'elk',
                    consoleOptions: [
                        'curator',
                        'zipkin'
                    ]
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
            assert.file(expectedFiles.dockercompose);
        });
        it('creates expected elk files', () => {
            assert.file(expectedFiles.elk);
        });
        it('creates compose file without zipkin, with curator', () => {
            assert.fileContent('docker-compose.yml', /jhipster-zipkin/);
            assert.fileContent('docker-compose.yml', /jhipster-curator/);
        });
        it('creates jhipster-registry content', () => {
            assert.fileContent('docker-compose.yml', /jhipster-registry:8761\/config/);
        });
        it('no prometheus files', () => {
            assert.noFile(expectedFiles.prometheus);
        });
        it('creates compose file without container_name, external_links, links', () => {
            assert.noFileContent('docker-compose.yml', /container_name:/);
            assert.noFileContent('docker-compose.yml', /external_links:/);
            assert.noFileContent('docker-compose.yml', /links:/);
        });
    });

    describe('gateway and one microservice, with prometheus', () => {
        beforeEach((done) => {
            helpers
                .run(require.resolve('../generators/docker-compose'))
                .inTmpDir((dir) => {
                    fse.copySync(path.join(__dirname, './templates/compose/'), dir);
                })
                .withPrompts({
                    composeApplicationType: 'microservice',
                    directoryPath: './',
                    chosenApps: [
                        '01-gateway',
                        '02-mysql'
                    ],
                    clusteredDbApps: [],
                    monitoring: 'prometheus'
                })
                .on('end', done);
        });
        it('creates expected default files', () => {
{'fraction_non_alphanumeric': 0.14571718195641156, 'fraction_numerical': 0.00446021287379625, 'mean_word_length': 1.4775238573581115, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 92, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4304166', 'n_tokens_mistral': 5543, 'n_tokens_neox': 5066, 'n_words': 740}