diff --git a/generators/common/index.js b/generators/common/index.js
index 2d88ea6b..8378b910 100644
--- a/generators/common/index.js
+++ b/generators/common/index.js
@@ -1,10 +1,9 @@
const chalk = require('chalk');
-
-const EntityServerGenerator = require('generator-jhipster/generators/common');
+const CommonGenerator = require('generator-jhipster/generators/common');
const entandoBlueprintWritingPhase = require('./phases/writing');
-module.exports = class extends EntityServerGenerator {
+module.exports = class extends CommonGenerator {
constructor(args, opts) {
super(args, { fromBlueprint: true, ...opts }); // fromBlueprint variable is important
diff --git a/generators/entity-server/templates/ui/widgets/detailsWidget/src/components/__tests__/EntityDetails.test.js.ejs b/generators/entity-server/templates/ui/widgets/detailsWidget/src/components/__tests__/EntityDetails.test.js.ejs
index 2c85e643..3135f9c6 100644
--- a/generators/entity-server/templates/ui/widgets/detailsWidget/src/components/__tests__/EntityDetails.test.js.ejs
+++ b/generators/entity-server/templates/ui/widgets/detailsWidget/src/components/__tests__/EntityDetails.test.js.ejs
@@ -8,10 +8,11 @@ import <%= entityClass %>Details from 'components/<%= entityClass %>Details';
import <%= entityInstance %>Mock from 'components/__mocks__/<%= entityInstance %>Mocks';
describe('<%= entityClass %>Details component', () => {
+<%_ if(fields && fields.length){_%>
test('renders data in details widget', () => {
const { getByText } = render(<<%= entityClass %>Details <%= entityInstance %>={<%= entityInstance %>Mock} />);
<%# TODO: THIS ONLY APPLIES IF THE DATA IS NOT SHOWN AS A DIFFERENT ITEM (e.g. Boolean as checkbox) #%>
- <%_ const firstField = fields[0].fieldName; _%>
- expect(getByText('entities.<%= entityInstance %>.<%= firstField %>')).toBeInTheDocument();
+ expect(getByText('entities.<%= entityInstance %>.<%= fields[0].fieldName %>')).toBeInTheDocument();
});
+<%_ } _%>
});
diff --git a/generators/server/phases/writing/files.js b/generators/server/phases/writing/files.js
index a9a0b9b5..a759410c 100644
--- a/generators/server/phases/writing/files.js
+++ b/generators/server/phases/writing/files.js
@@ -35,6 +35,8 @@ const serverFiles = {
{
templates: ['package.json'],
},
+ ],
+ bundle: [
{
templates: [
{ file: 'prepareMicrofrontends.sh', method: 'copy', noEjs: true },
@@ -47,11 +49,9 @@ const serverFiles = {
PATH: '.',
templates: [
{
- useBluePrint: true,
file: 'bundle/descriptor.yaml',
},
{
- useBluePrint: true,
file: 'bundle/plugins/myplugin.yaml',
renameTo: generator => `bundle/plugins/${generator.baseName.toLowerCase()}-plugin.yaml`,
},
diff --git a/test/app.spec.js b/test/app.spec.js
new file mode 100644
index 00000000..295128a2
--- /dev/null
+++ b/test/app.spec.js
@@ -0,0 +1,54 @@
+const path = require('path');
+const assert = require('yeoman-assert');
+const helpers = require('yeoman-test');
+const constants = require('generator-jhipster/generators/generator-constants');
+const expectedFiles = require('./utils/expected-files');
+
+const appBaseName = 'entandoPlugin';
+const { SERVER_MAIN_RES_DIR } = constants;
+
+describe('Subgenerator app of entando JHipster blueprint', () => {
+ describe('With default blueprint configuration', () => {
+ before(done => {
+ helpers
+ .run('generator-jhipster/generators/app')
+ .withOptions({
+ 'from-cli': true,
+ skipInstall: true,
+ blueprint: 'entando',
+ skipChecks: true,
+ })
+ .withGenerators([
+ [
+ require('../generators/app/index.js'), // eslint-disable-line global-require
+ 'jhipster-entando:app',
+ path.join(__dirname, '../generators/app/index.js'),
+ ],
+ ])
+ .withPrompts({
+ baseName: appBaseName,
+ packageName: 'com.mycompany.myapp',
+ applicationType: 'microservice',
+ databaseType: 'sql',
+ devDatabaseType: 'h2Disk',
+ prodDatabaseType: 'mysql',
+ cacheProvider: 'ehcache',
+ authenticationType: 'oauth2',
+ enableTranslation: true,
+ nativeLanguage: 'en',
+ languages: ['fr', 'de'],
+ buildTool: 'maven',
+ rememberMeKey: '2bb60a80889aa6e6767e9ccd8714982681152aa5',
+ })
+ .on('end', done);
+ });
+
+ it('creates expected files for the blueprint', () => {
+ assert.file(expectedFiles.microservices);
+ });
+
+ it('microservice index.html contains Entando data', () => {
+ assert.fileContent(`${SERVER_MAIN_RES_DIR}static/index.html`, 'https://dev.entando.org/');
+ });
+ });
+});
diff --git a/test/common.spec.js b/test/common.spec.js
new file mode 100644
index 00000000..c55a9ecc
--- /dev/null
+++ b/test/common.spec.js
@@ -0,0 +1,52 @@
+const path = require('path');
+const assert = require('yeoman-assert');
+const helpers = require('yeoman-test');
+
+describe('Subgenerator common of entando JHipster blueprint', () => {
+ describe('With default blueprint configuration', () => {
+ before(done => {
+ helpers
+ .run('generator-jhipster/generators/common')
+ .withOptions({
+ 'from-cli': true,
+ skipInstall: true,
+ blueprint: 'entando',
+ skipChecks: true,
+ })
+ .withGenerators([
+ [
+ require('../generators/common/index.js'), // eslint-disable-line global-require
+ 'jhipster-entando:common',
+ path.join(__dirname, '../generators/common/index.js'),
+ ],
+ ])
+ .withPrompts({
+ baseName: 'entandoPlugin',
+ packageName: 'com.mycompany.myapp',
+ applicationType: 'microservice',
+ databaseType: 'sql',
+ devDatabaseType: 'h2Disk',
+ prodDatabaseType: 'mysql',
+ cacheProvider: 'ehcache',
+ authenticationType: 'oauth2',
+ enableTranslation: true,
+ nativeLanguage: 'en',
+ languages: ['fr', 'de'],
+ buildTool: 'maven',
+ rememberMeKey: '2bb60a80889aa6e6767e9ccd8714982681152aa5',
+ })
+ .on('end', done);
+ });
+
+ it('creates expected files for the blueprint', () => {
+ assert.fileContent(
+ '.gitignore',
+ '######################\n' +
+ '# Entando bundles\n' +
+ '######################\n' +
+ 'bundle/\n' +
+ '# !/bundle/descriptor.yaml',
+ );
+ });
+ });
+});
diff --git a/test/entity.spec.js b/test/entity.spec.js
index f65ac8ad..588704c8 100644
--- a/test/entity.spec.js
+++ b/test/entity.spec.js
@@ -3,8 +3,10 @@ const fse = require('fs-extra');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
+const expectedFiles = require('./utils/expected-files');
+
describe('Subgenerator entity of entando JHipster blueprint', () => {
- describe('Sample test', () => {
+ describe('With default blueprint configuration', () => {
before(done => {
helpers
.run('generator-jhipster/generators/entity')
@@ -35,9 +37,169 @@ describe('Subgenerator entity of entando JHipster blueprint', () => {
.on('end', done);
});
- it('it works', () => {
- // Adds your tests here
- assert.textEqual('Write your own tests!', 'Write your own tests!');
+ it('creates expected files for the blueprint', () => {
+ assert.file(expectedFiles.entity.server.common);
+ });
+
+ it('creates expected details widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.detailsWidget);
+ });
+
+ it('creates expected details widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.formWidget);
+ });
+
+ it('creates expected table widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.tableWidget);
+ });
+ });
+
+ describe('With noDb blueprint configuration', () => {
+ before(done => {
+ helpers
+ .run('generator-jhipster/generators/entity')
+ .inTmpDir(dir => {
+ fse.copySync(path.join(__dirname, '../test/templates/ngx-blueprint-noDb'), dir);
+ })
+ .withOptions({
+ 'from-cli': true,
+ skipInstall: true,
+ blueprint: 'entando',
+ skipChecks: true,
+ })
+ .withGenerators([
+ [
+ require('../generators/entity/index.js'), // eslint-disable-line global-require
+ 'jhipster-entando:entity',
+ path.join(__dirname, '../generators/entity/index.js'),
+ ],
+ ])
+ .withArguments(['foo'])
+ .withPrompts({
+ fieldAdd: false,
+ relationshipAdd: false,
+ dto: 'no',
+ service: 'no',
+ pagination: 'infinite-scroll',
+ })
+ .on('end', done);
+ });
+
+ it('creates expected files for the blueprint', () => {
+ assert.file(expectedFiles.entity.server.common);
+ assert.file(expectedFiles.entity.server.noDb);
+ });
+
+ it('creates expected details widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.detailsWidget);
+ });
+
+ it('creates expected details widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.formWidget);
+ });
+
+ it('creates expected table widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.tableWidget);
+ });
+ });
+
+ describe('With noDb with serviceClass blueprint configuration', () => {
+ before(done => {
+ helpers
+ .run('generator-jhipster/generators/entity')
+ .inTmpDir(dir => {
+ fse.copySync(path.join(__dirname, '../test/templates/ngx-blueprint-noDb'), dir);
+ })
+ .withOptions({
+ 'from-cli': true,
+ skipInstall: true,
+ blueprint: 'entando',
+ skipChecks: true,
+ })
+ .withGenerators([
+ [
+ require('../generators/entity/index.js'), // eslint-disable-line global-require
+ 'jhipster-entando:entity',
+ path.join(__dirname, '../generators/entity/index.js'),
+ ],
+ ])
+ .withArguments(['foo'])
+ .withPrompts({
+ fieldAdd: false,
+ relationshipAdd: false,
+ dto: 'no',
+ service: 'serviceClass',
+ pagination: 'infinite-scroll',
+ })
+ .on('end', done);
+ });
+
+ it('creates expected files for the blueprint', () => {
+ assert.file(expectedFiles.entity.server.common);
+ assert.file(expectedFiles.entity.server.noDb);
+ assert.file(expectedFiles.entity.server.serviceClass);
+ });
+
+ it('creates expected details widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.detailsWidget);
+ });
+
+ it('creates expected details widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.formWidget);
+ });
+
+ it('creates expected table widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.tableWidget);
+ });
+ });
+
+ describe('With noDb with serviceImpl blueprint configuration', () => {
+ before(done => {
+ helpers
+ .run('generator-jhipster/generators/entity')
+ .inTmpDir(dir => {
+ fse.copySync(path.join(__dirname, '../test/templates/ngx-blueprint-noDb'), dir);
+ })
+ .withOptions({
+ 'from-cli': true,
+ skipInstall: true,
+ blueprint: 'entando',
+ skipChecks: true,
+ })
+ .withGenerators([
+ [
+ require('../generators/entity/index.js'), // eslint-disable-line global-require
+ 'jhipster-entando:entity',
+ path.join(__dirname, '../generators/entity/index.js'),
+ ],
+ ])
+ .withArguments(['foo'])
+ .withPrompts({
+ fieldAdd: false,
+ relationshipAdd: false,
+ dto: 'no',
+ service: 'serviceImpl',
+ pagination: 'infinite-scroll',
+ })
+ .on('end', done);
+ });
+
+ it('creates expected files for the blueprint', () => {
+ assert.file(expectedFiles.entity.server.common);
+ assert.file(expectedFiles.entity.server.noDb);
+ assert.file(expectedFiles.entity.server.serviceImpl);
+ });
+
+ it('creates expected details widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.detailsWidget);
+ });
+
+ it('creates expected details widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.formWidget);
+ });
+
+ it('creates expected table widget files for the blueprint', () => {
+ assert.file(expectedFiles.entity.widget.tableWidget);
});
});
});
diff --git a/test/server.spec.js b/test/server.spec.js
index 66ad0598..a9a962f9 100644
--- a/test/server.spec.js
+++ b/test/server.spec.js
@@ -1,18 +1,14 @@
-const _ = require('lodash');
-const YAML = require('yaml');
-const fs = require('fs');
const path = require('path');
const assert = require('yeoman-assert');
const helpers = require('yeoman-test');
+const constants = require('generator-jhipster/generators/generator-constants');
const expectedFiles = require('./utils/expected-files');
-function readFile(filename, json) {
- const file = fs.readFileSync(filename, 'utf8');
- return json ? JSON.parse(file) : file;
-}
+const appBaseName = 'entandoPlugin';
+const { DOCKER_DIR, SERVER_MAIN_SRC_DIR, SERVER_MAIN_RES_DIR } = constants;
describe('Subgenerator server of entando JHipster blueprint', () => {
- describe('Sample test', () => {
+ describe('With default blueprint configuration', () => {
before(done => {
helpers
.run('generator-jhipster/generators/server')
@@ -30,57 +26,424 @@ describe('Subgenerator server of entando JHipster blueprint', () => {
],
])
.withPrompts({
- baseName: 'entandoPlugin',
+ baseName: appBaseName,
packageName: 'com.mycompany.myapp',
applicationType: 'microservice',
databaseType: 'sql',
devDatabaseType: 'h2Disk',
prodDatabaseType: 'mysql',
cacheProvider: 'ehcache',
- authenticationType: 'oidc',
+ authenticationType: 'oauth2',
enableTranslation: true,
nativeLanguage: 'en',
languages: ['fr', 'de'],
buildTool: 'maven',
rememberMeKey: '2bb60a80889aa6e6767e9ccd8714982681152aa5',
+ dockerImageOrganization: 'test',
})
.on('end', done);
});
it('creates expected files for the blueprint', () => {
assert.file(expectedFiles.server);
+ assert.file(`bundle/plugins/${appBaseName.toLowerCase()}-plugin.yaml`);
});
- it('verifies application configuration contains EntandoProperties reference', () => {
- const applicationFile = expectedFiles.server.filter(item =>
- item.endsWith('com/mycompany/myapp/EntandoPluginApp.java'),
- )[0];
- assert.fileContent(applicationFile, /EntandoProperties\.class/);
- });
-
- it('verifies application.yml file contains entando properties', () => {
- const applicationYml = expectedFiles.server.filter(item => item.endsWith('application.yml'))[0];
- const fileContent = readFile(applicationYml, false);
- const config = YAML.parse(fileContent);
-
- assert.ok(
- Object.prototype.hasOwnProperty.call(config, 'entando'),
- 'application.yml should contain an entando property',
- );
-
- const entandoProperties = config.entando;
- const expectedProperties = {
- /* eslint-disable no-template-curly-in-string */
- 'client-id': '${CLIENT_ID:entandoPlugin}',
- 'client-secret': '${CLIENT_SECRET:entandoPlugin}',
- 'access-token-uri':
- '${TOKEN_SERVICE:http://localhost:9080/auth/realms/entando-development}/protocol/openid-connect/token',
- 'auth-service-uri': '${ENTANDO_AUTH:http://localhost:8082/}',
- 'config-service-uri': '${ENTANDO_CONFIG:http://localhost:8083/}',
- };
- assert.ok(
- _.isEqual(entandoProperties, expectedProperties),
- 'entando properties in application.yml not as expected',
+ it('pom.xml contains the javax servlet dependency', () => {
+ assert.fileContent(
+ 'pom.xml',
+ ' \n' +
+ ' javax.servlet\n' +
+ ' javax.servlet-api\n' +
+ ' \n',
+ );
+ });
+
+ it('pom.xml contains the Undertow dependency', () => {
+ assert.fileContent(
+ 'pom.xml',
+ ' \n' +
+ ' org.springframework.boot\n' +
+ ' spring-boot-starter-undertow\n' +
+ 'provided\n' +
+ ' \n',
+ );
+ });
+
+ it('pom.xml contains the Scala-library dependency', () => {
+ assert.fileContent(
+ 'pom.xml',
+ ' \n' +
+ ' org.scala-lang\n' +
+ ' scala-library\n' +
+ ' 2.12.1\n' +
+ ' \n',
+ );
+ });
+
+ it('pom.xml contains the mbknor-jackson-jsonschema dependecy', () => {
+ assert.fileContent(
+ 'pom.xml',
+ ' \n' +
+ ' com.kjetland\n' +
+ ' mbknor-jackson-jsonschema_2.12\n' +
+ ' 1.0.34\n' +
+ '\n' +
+ ' \n' +
+ ' \n' +
+ ' org.scala-lang\n' +
+ ' scala-library\n' +
+ ' \n' +
+ ' \n' +
+ ' \n' +
+ ' \n',
+ );
+ });
+
+ it('pom.xml contains the snapshot repository', () => {
+ assert.fileContent(
+ 'pom.xml',
+ ' \n' +
+ ' snapshot-repo\n' +
+ ' https://oss.sonatype.org/content/repositories/snapshots\n' +
+ ' \n',
+ );
+ });
+
+ it('pom.xml contains the entando dockerImageOrganization', () => {
+ assert.fileContent(
+ 'pom.xml',
+ ' \n' +
+ ' true\n' +
+ ' \n' +
+ ' \n' +
+ ' entando/entando-alpine-base:6.0.0\n' +
+ ' \n' +
+ ' \n' +
+ // eslint-disable-next-line no-template-curly-in-string
+ ' /${project.artifactId}:${project.version}\n' +
+ ' \n' +
+ ' \n' +
+ ' src/main/jib\n' +
+ ' \n' +
+ ' \n' +
+ ' /entrypoint.sh\n' +
+ ' 777\n' +
+ ' \n' +
+ ' \n' +
+ ' \n' +
+ ' \n' +
+ ' \n' +
+ ' /bin/bash\n' +
+ ' \n' +
+ ' /entrypoint.sh\n' +
+ ' \n' +
+ ' \n' +
+ ' 8080\n' +
+ ' \n' +
+ ' \n' +
+ ' ALWAYS\n' +
+ ' 0\n' +
+ ' \n' +
+ '\t\t\t USE_CURRENT_TIMESTAMP\n' +
+ ' \n' +
+ ' ',
+ );
+ });
+
+ it('pom.xml contains the modified JIB creationTime', () => {
+ assert.fileContent('pom.xml', '\t\t\t USE_CURRENT_TIMESTAMP');
+ });
+
+ it('pom.xml contains springfox-swagger-ui dependency', () => {
+ assert.fileContent(
+ 'pom.xml',
+ ' \n' +
+ ' io.springfox\n' +
+ ' springfox-swagger-ui\n' +
+ ' 2.9.2\n' +
+ ' ',
+ );
+ });
+
+ it('Keycloack docker file contains the Entando modifications', () => {
+ assert.fileContent(`${DOCKER_DIR}keycloak.yml`, 'entando/entando-keycloak:6.0.15');
+ assert.fileContent(
+ `${DOCKER_DIR}keycloak.yml`,
+ ' command:\n' +
+ ' [\n' +
+ " '-b',\n" +
+ " '0.0.0.0',\n" +
+ " '-Dkeycloak.profile.feature.scripts=enabled',\n" +
+ " '-Dkeycloak.profile.feature.upload_scripts=enabled',\n" +
+ " '-Dkeycloak.migration.action=import',\n" +
+ " '-Dkeycloak.migration.provider=dir',\n" +
+ " '-Dkeycloak.migration.dir=/opt/jboss/keycloak/realm-config',\n" +
+ " '-Dkeycloak.migration.strategy=OVERWRITE_EXISTING',\n" +
+ " '-Djboss.socket.binding.port-offset=1000',\n" +
+ ' ]',
+ );
+ });
+
+ it('SecurityConfiguration file contains Entando modifications', () => {
+ assert.fileContent(
+ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/SecurityConfiguration.java`,
+ " .contentSecurityPolicy(\"default-src 'self' http://localhost:9080; frame-src 'self' data:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://storage.googleapis.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self' data:\")\n",
+ );
+ });
+
+ it('JHipster-realm.json file contains swagger-ui data', () => {
+ assert.fileContent(
+ `${DOCKER_DIR}realm-config/jhipster-realm.json`,
+ '{\n' +
+ ' "id": "d64b8b39-e190-44b8-aafb-13d589e3e21f",\n' +
+ ' "clientId": "swagger_ui",\n' +
+ ' "rootUrl": "http://localhost:8081",\n' +
+ ' "adminUrl": "http://localhost:8081",\n' +
+ ' "surrogateAuthRequired": false,\n' +
+ ' "enabled": true,\n' +
+ ' "clientAuthenticatorType": "client-secret",\n' +
+ ' "secret": "swagger_ui",\n' +
+ ' "redirectUris": ["http://localhost:*", "https://localhost:*", "http://127.0.0.1:*", "https://127.0.0.1:*", "dev.localhost.ionic:*"],\n' +
+ ' "webOrigins": ["*"],\n' +
+ ' "notBefore": 0,\n' +
+ ' "bearerOnly": false,\n' +
+ ' "consentRequired": false,\n' +
+ ' "standardFlowEnabled": true,\n' +
+ ' "implicitFlowEnabled": true,\n' +
+ ' "directAccessGrantsEnabled": false,\n' +
+ ' "serviceAccountsEnabled": false,\n' +
+ ' "publicClient": true,\n' +
+ ' "frontchannelLogout": false,\n' +
+ ' "protocol": "openid-connect",\n' +
+ ' "attributes": {\n' +
+ ' "saml.assertion.signature": "false",\n' +
+ ' "saml.force.post.binding": "false",\n' +
+ ' "saml.multivalued.roles": "false",\n' +
+ ' "saml.encrypt": "false",\n' +
+ ' "saml.server.signature": "false",\n' +
+ ' "saml.server.signature.keyinfo.ext": "false",\n' +
+ ' "exclude.session.state.from.auth.response": "false",\n' +
+ ' "saml_force_name_id_format": "false",\n' +
+ ' "saml.client.signature": "false",\n' +
+ ' "tls.client.certificate.bound.access.tokens": "false",\n' +
+ ' "saml.authnstatement": "false",\n' +
+ ' "display.on.consent.screen": "false",\n' +
+ ' "saml.onetimeuse.condition": "false"\n' +
+ ' },\n' +
+ ' "authenticationFlowBindingOverrides": {},\n' +
+ ' "fullScopeAllowed": true,\n' +
+ ' "nodeReRegistrationTimeout": -1,\n' +
+ ' "defaultClientScopes": ["web-origins", "jhipster", "role_list", "roles", "profile", "email"],\n' +
+ ' "optionalClientScopes": ["address", "phone", "offline_access"]\n' +
+ ' }\n' +
+ ' ],\n' +
+ ' "clientScopes": [\n' +
+ ' {\n' +
+ ' "id": "1dc1e050-891a-4f5b-ac9d-5ea0c2e3c05e",\n' +
+ ' "name": "address",\n' +
+ ' "description": "OpenID Connect built-in scope: address",\n' +
+ ' "protocol": "openid-connect",\n' +
+ ' "attributes": {\n' +
+ // eslint-disable-next-line no-template-curly-in-string
+ ' "consent.screen.text": "${addressScopeConsentText}",\n' +
+ ' "display.on.consent.screen": "true"\n' +
+ ' },\n' +
+ ' "protocolMappers": [\n' +
+ ' {\n' +
+ ' "id": "b9a92105-8ca5-45d1-8a99-626255ac174f",\n' +
+ ' "name": "address",\n' +
+ ' "protocol": "openid-connect",\n' +
+ ' "protocolMapper": "oidc-address-mapper",\n' +
+ ' "consentRequired": false,\n' +
+ ' "config": {\n' +
+ ' "user.attribute.formatted": "formatted",\n' +
+ ' "user.attribute.country": "country",\n' +
+ ' "user.attribute.postal_code": "postal_code",\n' +
+ ' "userinfo.token.claim": "true",\n' +
+ ' "user.attribute.street": "street",\n' +
+ ' "id.token.claim": "true",\n' +
+ ' "user.attribute.region": "region",\n' +
+ ' "access.token.claim": "true",\n' +
+ ' "user.attribute.locality": "locality"\n' +
+ ' }\n' +
+ ' }\n' +
+ ' ]\n' +
+ ' },',
+ );
+ });
+
+ it('Application yaml files contains Entando midification', () => {
+ assert.fileContent(
+ `${SERVER_MAIN_RES_DIR}config/application.yml`,
+ 'swagger-ui:\n client-id: swagger_ui\n client-secret: swagger_ui',
+ );
+
+ assert.fileContent(
+ `${SERVER_MAIN_RES_DIR}config/application-dev.yml`,
+ ' cors:\n' +
+ " allowed-origins: '*'\n" +
+ " allowed-methods: '*'\n" +
+ " allowed-headers: '*'\n" +
+ " exposed-headers: 'Authorization,Link,X-Total-Count'\n" +
+ ' allow-credentials: true\n' +
+ ' max-age: 1800',
+ );
+ });
+
+ it('package.json file contains Entando scripts', () => {
+ assert.fileContent(
+ 'package.json',
+ ' "scripts": {\n' +
+ ' "populate-bundle": "bash ./buildBundle.sh",\n' +
+ ' "build-all": "bash ./buildBundle.sh -d",\n' +
+ ' "keycloak": "docker-compose -f src/main/docker/keycloak.yml up"\n' +
+ ' }',
+ );
+ });
+
+ it('JwtAuthorityExtractor file contains Entando modification', () => {
+ assert.fileContent(
+ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/security/oauth2/JwtAuthorityExtractor.java`,
+ ":'internal'",
+ );
+ });
+
+ it('Main application file contains Entando modification', () => {
+ assert.fileContent(
+ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/${appBaseName}App.java`,
+ 'implements InitializingBean',
+ );
+ });
+
+ it('CacheConfiguration file contains Entando modification', () => {
+ const cacheConfigurationFileName = `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`;
+
+ assert.noFileContent(
+ cacheConfigurationFileName,
+ 'import com.mycompany.myapp.repository.UserRepository;\n',
+ );
+ assert.noFileContent(cacheConfigurationFileName, 'UserRepository.USERS_BY_LOGIN_CACHE');
+ assert.noFileContent(cacheConfigurationFileName, 'UserRepository.USERS_BY_EMAIL_CACHE');
+ assert.noFileContent(cacheConfigurationFileName, 'Authority.class.getName()');
+ assert.noFileContent(cacheConfigurationFileName, 'class.getName() + ".authorities"');
+ assert.noFileContent(cacheConfigurationFileName, 'class.getName() + ".persistentTokens"');
+ });
+
+ it('CacheConfiguration file contains Entando modification', () => {
+ assert.noFileContent(
+ `${SERVER_MAIN_RES_DIR}banner.txt`,
+ // eslint-disable-next-line no-template-curly-in-string
+ "'${AnsiColor.BRIGHT_CYAN}███████╗███╗ ██╗████████╗ █████╗ ███╗ ██╗██████╗ ██████╗ \n" +
+ '██╔════╝████╗ ██║╚══██╔══╝██╔══██╗████╗ ██║██╔══██╗██╔═══██╗\n' +
+ '█████╗ ██╔██╗ ██║ ██║ ███████║██╔██╗ ██║██║ ██║██║ ██║\n' +
+ '██╔══╝ ██║╚██╗██║ ██║ ██╔══██║██║╚██╗██║██║ ██║██║ ██║\n' +
+ '███████╗██║ ╚████║ ██║ ██║ ██║██║ ╚████║██████╔╝╚██████╔╝\n' +
+ "╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═════╝ ╚═════╝ '",
+ );
+ });
+ });
+
+ describe('With Infinispan as cache configuration', () => {
+ before(done => {
+ helpers
+ .run('generator-jhipster/generators/server')
+ .withOptions({
+ 'from-cli': true,
+ skipInstall: true,
+ blueprint: 'entando',
+ skipChecks: true,
+ })
+ .withGenerators([
+ [
+ require('../generators/server/index.js'), // eslint-disable-line global-require
+ 'jhipster-entando:server',
+ path.join(__dirname, '../generators/server/index.js'),
+ ],
+ ])
+ .withPrompts({
+ baseName: appBaseName,
+ packageName: 'com.mycompany.myapp',
+ applicationType: 'microservice',
+ databaseType: 'sql',
+ devDatabaseType: 'h2Disk',
+ prodDatabaseType: 'mysql',
+ cacheProvider: 'infinispan',
+ authenticationType: 'oauth2',
+ enableTranslation: true,
+ nativeLanguage: 'en',
+ languages: ['fr', 'de'],
+ buildTool: 'maven',
+ rememberMeKey: '2bb60a80889aa6e6767e9ccd8714982681152aa5',
+ dockerImageOrganization: 'test',
+ })
+ .on('end', done);
+ });
+
+ it('creates expected files for the blueprint', () => {
+ assert.file(expectedFiles.server);
+ assert.file(`bundle/plugins/${appBaseName.toLowerCase()}-plugin.yaml`);
+ });
+
+ it('CacheConfiguration file contains Entando modification', () => {
+ const cacheConfigurationFileName = `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/CacheConfiguration.java`;
+
+ assert.noFileContent(
+ cacheConfigurationFileName,
+ 'import com.mycompany.myapp.repository.UserRepository;\n',
+ );
+ assert.noFileContent(cacheConfigurationFileName, 'UserRepository.USERS_BY_LOGIN_CACHE');
+ assert.noFileContent(cacheConfigurationFileName, 'UserRepository.USERS_BY_EMAIL_CACHE');
+ assert.noFileContent(cacheConfigurationFileName, 'Authority.class.getName()');
+ assert.noFileContent(cacheConfigurationFileName, 'class.getName() + ".authorities"');
+ assert.noFileContent(cacheConfigurationFileName, 'class.getName() + ".persistentTokens"');
+ assert.fileContent(
+ cacheConfigurationFileName,
+ ' @Override\n' +
+ ' protected void configure(AuthenticationManagerBuilder auth)\n' +
+ ' throws Exception {\n' +
+ ' auth\n' +
+ ' .inMemoryAuthentication()\n' +
+ ' .withUser("user")\n' +
+ ' .password("password")\n' +
+ ' .roles("USER")\n' +
+ ' .and()\n' +
+ ' .withUser("admin")\n' +
+ ' .password("admin")\n' +
+ ' .roles("USER", "ADMIN");\n' +
+ ' }\n' +
+ ' \n' +
+ ' @Override\n' +
+ ' protected void configure(HttpSecurity http) throws Exception {\n' +
+ ' http\n' +
+ ' .authorizeRequests()\n' +
+ ' .anyRequest()\n' +
+ ' .authenticated()\n' +
+ ' .and()\n' +
+ ' .httpBasic();\n' +
+ ' } @Override\n' +
+ ' protected void configure(AuthenticationManagerBuilder auth)\n' +
+ ' throws Exception {\n' +
+ ' auth\n' +
+ ' .inMemoryAuthentication()\n' +
+ ' .withUser("user")\n' +
+ ' .password("password")\n' +
+ ' .roles("USER")\n' +
+ ' .and()\n' +
+ ' .withUser("admin")\n' +
+ ' .password("admin")\n' +
+ ' .roles("USER", "ADMIN");\n' +
+ ' }\n' +
+ ' \n' +
+ ' @Override\n' +
+ ' protected void configure(HttpSecurity http) throws Exception {\n' +
+ ' http\n' +
+ ' .authorizeRequests()\n' +
+ ' .anyRequest()\n' +
+ ' .authenticated()\n' +
+ ' .and()\n' +
+ ' .httpBasic();\n' +
+ ' }',
);
});
});
diff --git a/test/templates/ngx-blueprint-noDb/.yo-rc.json b/test/templates/ngx-blueprint-noDb/.yo-rc.json
new file mode 100644
index 00000000..8c106994
--- /dev/null
+++ b/test/templates/ngx-blueprint-noDb/.yo-rc.json
@@ -0,0 +1,47 @@
+{
+ "generator-jhipster-entando": {
+ "promptValues": {
+ "packageName": "com.mycompany.myapp"
+ },
+ "applicationType": "monolith",
+ "baseName": "jhipsterBlueprint",
+ "packageName": "com.mycompany.myapp",
+ "packageFolder": "com/mycompany/myapp",
+ "serverPort": "8080",
+ "authenticationType": "jwt",
+ "cacheProvider": "ehcache",
+ "enableHibernateCache": true,
+ "websocket": false,
+ "databaseType": "no",
+ "service": "serviceImpl",
+ "searchEngine": false,
+ "messageBroker": false,
+ "serviceDiscoveryType": false,
+ "buildTool": "maven",
+ "enableSwaggerCodegen": false,
+ "jwtSecretKey": "147e04cf224f52908a60d7a2902e19e0648d0a8c52503b4624f1708478dd29ba2885a9bb823c85873a76b27964a90e22f1e8",
+ "clientFramework": "angularX",
+ "useSass": false,
+ "clientPackageManager": "npm"
+ },
+ "generator-jhipster": {
+ "promptValues": {
+ "nativeLanguage": "en"
+ },
+ "applicationType": "monolith",
+ "baseName": "jhipsterBlueprint",
+ "testFrameworks": [
+ "gatling",
+ "protractor"
+ ],
+ "jhiPrefix": "jhi",
+ "enableTranslation": true,
+ "clientPackageManager": "npm",
+ "nativeLanguage": "en",
+ "languages": [
+ "en",
+ "fr"
+ ],
+ "blueprint": "generator-jhipster-entando"
+ }
+}
diff --git a/test/utils/expected-files.js b/test/utils/expected-files.js
index 8cae359f..43a698e5 100644
--- a/test/utils/expected-files.js
+++ b/test/utils/expected-files.js
@@ -1,18 +1,177 @@
const constants = require('generator-jhipster/generators/generator-constants');
-const { SERVER_MAIN_SRC_RES, SERVER_MAIN_SRC_DIR } = constants;
+const { SERVER_MAIN_RES_DIR, SERVER_MAIN_SRC_DIR, SERVER_TEST_SRC_DIR } = constants;
const expectedFiles = {
+ microservices: [`${SERVER_MAIN_RES_DIR}static/favicon.png`],
server: [
- `${SERVER_MAIN_SRC_RES}config/application.yml`,
- `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/client/EntandoAuthClient.java`,
- `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/EntandoPluginConfig.java`,
- `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/EntandoPluginConfigManager.java`,
- `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/ConfigServiceConfiguration.java`,
- `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/EntandoProperties.java`,
- `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/EntandoPluginApp.java`,
- `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/schema/EntandoPluginConfigSchemaResource.java`,
+ 'bundle/descriptor.yaml',
+ 'prepareMicrofrontends.sh',
+ 'prepareBundle.sh',
+ 'prepareDockerImage.sh',
+ 'buildBundle.sh',
+ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/config/SpringFoxConfiguration.java`,
],
+ entity: {
+ server: {
+ common: [`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/schema/FooSchemaResource.java`],
+ noDb: [
+ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/domain/Foo.java`,
+ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/FooRepository.java`,
+ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/repository/impl/FooRepositoryImpl.java`,
+ `${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/web/rest/FooResource.java`,
+ `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/domain/FooTest.java`,
+ `${SERVER_TEST_SRC_DIR}com/mycompany/myapp/web/rest/FooResourceIT.java`,
+ ],
+ serviceClass: [`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/FooService.java`],
+ serviceImpl: [`${SERVER_MAIN_SRC_DIR}com/mycompany/myapp/service/impl/FooServiceImpl.java`],
+ },
+ widget: {
+ detailsWidget: [
+ 'ui/widgets/foo/detailsWidget/bundle/foo-details-widget.ftl',
+ 'ui/widgets/foo/detailsWidget/bundle/foo-details-widget-descriptor.yaml',
+ 'ui/widgets/foo/detailsWidget/public/favicon.ico',
+ 'ui/widgets/foo/detailsWidget/public/index.html',
+ 'ui/widgets/foo/detailsWidget/public/robots.txt',
+ 'ui/widgets/foo/detailsWidget/scripts/i18next-scanner.config.js',
+ 'ui/widgets/foo/detailsWidget/src/api/foo.js',
+ 'ui/widgets/foo/detailsWidget/src/api/helpers.js',
+ 'ui/widgets/foo/detailsWidget/src/auth/KeycloakContext.js',
+ 'ui/widgets/foo/detailsWidget/src/auth/KeycloakViews.js',
+ 'ui/widgets/foo/detailsWidget/src/auth/withKeycloak.js',
+ 'ui/widgets/foo/detailsWidget/src/components/__mocks__/fooMocks.js',
+ 'ui/widgets/foo/detailsWidget/src/components/__mocks__/i18n.js',
+ 'ui/widgets/foo/detailsWidget/src/components/__tests__/FooDetails.test.js',
+ 'ui/widgets/foo/detailsWidget/src/components/__tests__/FooDetailsContainer.test.js',
+ 'ui/widgets/foo/detailsWidget/src/components/__types__/foo.js',
+ 'ui/widgets/foo/detailsWidget/src/components/__types__/keycloak.js',
+ 'ui/widgets/foo/detailsWidget/src/components/__types__/ref.js',
+ 'ui/widgets/foo/detailsWidget/src/components/common/Notification.js',
+ 'ui/widgets/foo/detailsWidget/src/components/foo-field-table/FooFieldTable.js',
+ 'ui/widgets/foo/detailsWidget/src/components/FooDetails.js',
+ 'ui/widgets/foo/detailsWidget/src/components/FooDetailsContainer.js',
+ 'ui/widgets/foo/detailsWidget/src/custom-elements/FooDetailsElement.js',
+ 'ui/widgets/foo/detailsWidget/src/custom-elements/widgetEventTypes.js',
+ 'ui/widgets/foo/detailsWidget/src/helpers/widgetEvents.js',
+ 'ui/widgets/foo/detailsWidget/src/i18n/locales/en.json',
+ 'ui/widgets/foo/detailsWidget/src/i18n/locales/index.js',
+ 'ui/widgets/foo/detailsWidget/src/i18n/locales/it.json',
+ 'ui/widgets/foo/detailsWidget/src/i18n/constants.js',
+ 'ui/widgets/foo/detailsWidget/src/i18n/i18n.js',
+ 'ui/widgets/foo/detailsWidget/src/i18n/setLocale.js',
+ 'ui/widgets/foo/detailsWidget/src/index.css',
+ 'ui/widgets/foo/detailsWidget/src/index.js',
+ 'ui/widgets/foo/detailsWidget/.env.local',
+ 'ui/widgets/foo/detailsWidget/.env.production',
+ 'ui/widgets/foo/detailsWidget/jsconfig.json',
+ 'ui/widgets/foo/detailsWidget/LICENSE',
+ 'ui/widgets/foo/detailsWidget/package.json',
+ 'ui/widgets/foo/detailsWidget/package-lock.json',
+ 'ui/widgets/foo/detailsWidget/README.md',
+ ],
+ formWidget: [
+ 'ui/widgets/foo/formWidget/bundle/foo-form-widget.ftl',
+ 'ui/widgets/foo/formWidget/bundle/foo-form-widget-descriptor.yaml',
+ 'ui/widgets/foo/formWidget/public/favicon.ico',
+ 'ui/widgets/foo/formWidget/public/index.html',
+ 'ui/widgets/foo/formWidget/public/robots.txt',
+ 'ui/widgets/foo/formWidget/scripts/i18next-scanner.config.js',
+ 'ui/widgets/foo/formWidget/src/api/foos.js',
+ 'ui/widgets/foo/formWidget/src/api/helpers.js',
+ 'ui/widgets/foo/formWidget/src/auth/KeycloakContext.js',
+ 'ui/widgets/foo/formWidget/src/auth/KeycloakViews.js',
+ 'ui/widgets/foo/formWidget/src/auth/withKeycloak.js',
+ 'ui/widgets/foo/formWidget/src/components/__mocks__/fooMocks.js',
+ 'ui/widgets/foo/formWidget/src/components/__tests__/FooAddFormContainer.test.js',
+ 'ui/widgets/foo/formWidget/src/components/__tests__/FooEditFormContainer.test.js',
+ 'ui/widgets/foo/formWidget/src/components/__tests__/FooForm.test.js',
+ 'ui/widgets/foo/formWidget/src/components/__types__/foo.js',
+ 'ui/widgets/foo/formWidget/src/components/__types__/keycloak.js',
+ 'ui/widgets/foo/formWidget/src/components/__types__/ref.js',
+ 'ui/widgets/foo/formWidget/src/components/common/ConfirmationDialogTrigger.js',
+ 'ui/widgets/foo/formWidget/src/components/common/Notification.js',
+ 'ui/widgets/foo/formWidget/src/components/FooAddFormContainer.js',
+ 'ui/widgets/foo/formWidget/src/components/FooEditFormContainer.js',
+ 'ui/widgets/foo/formWidget/src/components/FooForm.js',
+ 'ui/widgets/foo/formWidget/src/custom-elements/FooFormElement.js',
+ 'ui/widgets/foo/formWidget/src/custom-elements/widgetEventTypes.js',
+ 'ui/widgets/foo/formWidget/src/helpers/widgetEvents.js',
+ 'ui/widgets/foo/formWidget/src/i18n/__mocks__/i18nMock.js',
+ 'ui/widgets/foo/formWidget/src/i18n/locales/en.json',
+ 'ui/widgets/foo/formWidget/src/i18n/locales/index.js',
+ 'ui/widgets/foo/formWidget/src/i18n/locales/it.json',
+ 'ui/widgets/foo/formWidget/src/i18n/constants.js',
+ 'ui/widgets/foo/formWidget/src/i18n/dateFnsLocales.js',
+ 'ui/widgets/foo/formWidget/src/i18n/i18next.js',
+ 'ui/widgets/foo/formWidget/src/i18n/setLocale.js',
+ 'ui/widgets/foo/formWidget/src/i18n/yup.js',
+ 'ui/widgets/foo/formWidget/src/index.js',
+ 'ui/widgets/foo/formWidget/.env.local',
+ 'ui/widgets/foo/formWidget/.env.production',
+ 'ui/widgets/foo/formWidget/.gitignore',
+ 'ui/widgets/foo/formWidget/deploy-widget.sh',
+ 'ui/widgets/foo/formWidget/jsconfig.json',
+ 'ui/widgets/foo/formWidget/LICENSE',
+ 'ui/widgets/foo/formWidget/package.json',
+ 'ui/widgets/foo/formWidget/package-lock.json',
+ 'ui/widgets/foo/formWidget/README.md',
+ ],
+ tableWidget: [
+ 'ui/widgets/foo/tableWidget/bundle/foo-table-widget.ftl',
+ 'ui/widgets/foo/tableWidget/bundle/foo-table-widget-descriptor.yaml',
+ 'ui/widgets/foo/tableWidget/public/favicon.ico',
+ 'ui/widgets/foo/tableWidget/public/index.html',
+ 'ui/widgets/foo/tableWidget/public/robots.txt',
+ 'ui/widgets/foo/tableWidget/scripts/i18next-scanner.config.js',
+ 'ui/widgets/foo/tableWidget/src/api/foos.js',
+ 'ui/widgets/foo/tableWidget/src/api/helpers.js',
+ 'ui/widgets/foo/tableWidget/src/auth/KeycloakContext.js',
+ 'ui/widgets/foo/tableWidget/src/auth/KeycloakViews.js',
+ 'ui/widgets/foo/tableWidget/src/auth/withKeycloak.js',
+ 'ui/widgets/foo/tableWidget/src/components/__mocks__/fooMocks.js',
+ 'ui/widgets/foo/tableWidget/src/components/__mocks__/i18n.js',
+ 'ui/widgets/foo/tableWidget/src/components/__tests__/FooTable.test.js',
+ 'ui/widgets/foo/tableWidget/src/components/__tests__/FooTableContainer.test.js',
+ 'ui/widgets/foo/tableWidget/src/components/__types__/filter.js',
+ 'ui/widgets/foo/tableWidget/src/components/__types__/foo.js',
+ 'ui/widgets/foo/tableWidget/src/components/__types__/keycloak.js',
+ 'ui/widgets/foo/tableWidget/src/components/__types__/ref.js',
+ 'ui/widgets/foo/tableWidget/src/components/common/ConfirmationDialogTrigger.js',
+ 'ui/widgets/foo/tableWidget/src/components/common/Notification.js',
+ 'ui/widgets/foo/tableWidget/src/components/filters/Filter.js',
+ 'ui/widgets/foo/tableWidget/src/components/filters/FiltersContainer.js',
+ 'ui/widgets/foo/tableWidget/src/components/filters/utils.js',
+ 'ui/widgets/foo/tableWidget/src/components/pagination/PaginationContext.js',
+ 'ui/widgets/foo/tableWidget/src/components/pagination/PaginationWrapper.js',
+ 'ui/widgets/foo/tableWidget/src/components/pagination/TablePaginationActions.js',
+ 'ui/widgets/foo/tableWidget/src/components/pagination/withPagination.js',
+ 'ui/widgets/foo/tableWidget/src/components/FooTable.js',
+ 'ui/widgets/foo/tableWidget/src/components/FooTableContainer.js',
+ 'ui/widgets/foo/tableWidget/src/custom-elements/FooTableElement.js',
+ 'ui/widgets/foo/tableWidget/src/custom-elements/widgetEventTypes.js',
+ 'ui/widgets/foo/tableWidget/src/helpers/widgetEvents.js',
+ 'ui/widgets/foo/tableWidget/src/i18n/__mocks__/i18nMock.js',
+ 'ui/widgets/foo/tableWidget/src/i18n/locales/en.json',
+ 'ui/widgets/foo/tableWidget/src/i18n/locales/index.js',
+ 'ui/widgets/foo/tableWidget/src/i18n/locales/it.json',
+ 'ui/widgets/foo/tableWidget/src/i18n/constants.js',
+ 'ui/widgets/foo/tableWidget/src/i18n/i18next.js',
+ 'ui/widgets/foo/tableWidget/src/i18n/setLocale.js',
+ 'ui/widgets/foo/tableWidget/src/state/filter.types.js',
+ 'ui/widgets/foo/tableWidget/src/state/foo.reducer.js',
+ 'ui/widgets/foo/tableWidget/src/state/foo.types.js',
+ 'ui/widgets/foo/tableWidget/src/index.js',
+ 'ui/widgets/foo/tableWidget/.env.local',
+ 'ui/widgets/foo/tableWidget/.env.production',
+ 'ui/widgets/foo/tableWidget/.gitignore',
+ 'ui/widgets/foo/tableWidget/deploy-widget.sh',
+ 'ui/widgets/foo/tableWidget/jsconfig.json',
+ 'ui/widgets/foo/tableWidget/LICENSE',
+ 'ui/widgets/foo/tableWidget/package.json',
+ 'ui/widgets/foo/tableWidget/README.md',
+ ],
+ },
+ },
};
module.exports = expectedFiles;