jhipster-core
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -46,3 +46,3 @@ 'use strict'; | ||
if (this.comment) { | ||
string += `/**\n * ${this.comment}\n */\n`; | ||
string += '/**\n' + this.comment.split('\n').map( line => ` * ${line}\n` ).join('') + ` */\n`; | ||
} | ||
@@ -49,0 +49,0 @@ string += `entity ${this.name} (${this.tableName})`; |
@@ -51,3 +51,3 @@ 'use strict'; | ||
if (this.comment) { | ||
string += `/**\n * ${this.comment}\n */\n`; | ||
string += '/**\n' + this.comment.split('\n').map( line => ` * ${line}\n` ).join('') + ` */\n`; | ||
} | ||
@@ -54,0 +54,0 @@ string += `${this.name} ${this.type}`; |
@@ -65,5 +65,3 @@ 'use strict'; | ||
if (this.commentInFrom) { | ||
string += `/** | ||
* ${this.commentInFrom} | ||
*/\n `; | ||
string += `/**\n${this.commentInFrom.split('\n').map( line => ` * ${line}\n` ).join('')} */\n `; | ||
} | ||
@@ -76,6 +74,3 @@ string += `${this.from.name}`; | ||
if (this.commentInTo) { | ||
string += ` | ||
/** | ||
* ${this.commentInTo} | ||
*/\n `; | ||
string += `\n /**\n${this.commentInTo.split('\n').map( line => ` * ${line}\n` ).join('')} */\n `; | ||
} else { | ||
@@ -157,2 +152,2 @@ string += ' '; | ||
relationship.injectedFieldInTo = _.lowerFirst(relationship.from.name); | ||
} | ||
} |
@@ -63,3 +63,3 @@ 'use strict'; | ||
lines = lines.slice(1, lines.length - 1); | ||
relationship += `${lines.join('')},\n`; | ||
relationship += `${lines.join('\n')},\n`; | ||
} | ||
@@ -66,0 +66,0 @@ } |
@@ -7,2 +7,3 @@ 'use strict'; | ||
JHIPSTER: ['ACCOUNT'], | ||
ANGULAR: ['NODENAME', 'NODETYPE'], | ||
JAVA: ['ABSTRACT', 'CONTINUE', 'FOR', 'NEW', 'SWITCH', 'ASSERT', 'DEFAULT', 'GOTO', 'PACKAGE', 'SYNCHRONIZED', 'BOOLEAN', 'DO', 'IF', 'PRIVATE', 'THIS', 'BREAK', 'DOUBLE', 'IMPLEMENTS', 'PROTECTED', 'THROW', 'BYTE', 'ELSE', 'IMPORT', 'PUBLIC', 'THROWS', 'CASE', 'ENUM', 'INSTANCEOF', 'RETURN', 'TRANSIENT', 'CATCH', 'EXTENDS', 'INT', 'SHORT', 'TRY', 'CHAR', 'FINAL', 'INTERFACE', 'STATIC', 'VOID', 'CLASS', 'FINALLY', 'LONG', 'STRICTFP', 'VOLATILE', 'CONST', 'FLOAT', 'NATIVE', 'SUPER', 'WHILE'], | ||
@@ -33,3 +34,3 @@ MYSQL: MYSQL_RESERVED_WORDS, | ||
function isReservedFieldName(keyword, databaseType) { | ||
return isReserved(keyword, 'JAVA') || isReservedTableName(keyword, databaseType); | ||
return isReserved(keyword, 'ANGULAR') || isReserved(keyword, 'JAVA') || isReservedTableName(keyword, databaseType); | ||
} | ||
@@ -43,2 +44,3 @@ | ||
JHIPSTER: RESERVED_WORDS.JHIPSTER, | ||
ANGULAR: RESERVED_WORDS.ANGULAR, | ||
JAVA: RESERVED_WORDS.JAVA, | ||
@@ -45,0 +47,0 @@ MYSQL: RESERVED_WORDS.MYSQL, |
@@ -6,2 +6,3 @@ 'use strict'; | ||
SKIP_SERVER: 'skipServer', | ||
SKIP_USER_MANAGEMENT: 'skipUserManagement', | ||
NO_FLUENT_METHOD: 'noFluentMethod' | ||
@@ -8,0 +9,0 @@ }; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
_ = require('lodash'), | ||
camelCase = require('../utils/string_utils').camelCase, | ||
merge = require('../utils/object_utils').merge, | ||
@@ -147,3 +148,3 @@ FieldTypes = require('../core/jhipster/field_types'), | ||
let fieldData = { | ||
fieldName: _.camelCase(fieldName) | ||
fieldName: camelCase(fieldName) | ||
}; | ||
@@ -246,6 +247,9 @@ let comment = formatComment(jdlField.comment); | ||
} | ||
if (relatedRelationship.commentInFrom) { | ||
relationship.javadoc = relatedRelationship.commentInFrom; | ||
} | ||
if (relatedRelationship.type === RelationshipTypes.ONE_TO_ONE) { | ||
splitField = extractField(relatedRelationship.injectedFieldInFrom); | ||
relationship.relationshipName = _.camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = _.lowerFirst(_.camelCase(relatedRelationship.to.name)); | ||
relationship.relationshipName = camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = camelCase(relatedRelationship.to.name); | ||
relationship.otherEntityField = _.lowerFirst(splitField.otherEntityField); | ||
@@ -257,4 +261,4 @@ relationship.ownerSide = true; | ||
otherSplitField = extractField(relatedRelationship.injectedFieldInTo); | ||
relationship.relationshipName = _.lowerFirst(_.camelCase(splitField.relationshipName || relatedRelationship.to.name)); | ||
relationship.otherEntityName = _.lowerFirst(_.camelCase(relatedRelationship.to.name)); | ||
relationship.relationshipName = camelCase(splitField.relationshipName || relatedRelationship.to.name); | ||
relationship.otherEntityName = camelCase(relatedRelationship.to.name); | ||
relationship.otherEntityRelationshipName = _.lowerFirst(otherSplitField.relationshipName); | ||
@@ -265,4 +269,4 @@ if (!relatedRelationship.injectedFieldInTo) { | ||
let otherSideRelationship = { | ||
relationshipName: _.camelCase(_.lowerFirst(relatedRelationship.from.name)), | ||
otherEntityName: _.lowerFirst(_.camelCase(relatedRelationship.from.name)), | ||
relationshipName: camelCase(relatedRelationship.from.name), | ||
otherEntityName: camelCase(relatedRelationship.from.name), | ||
relationshipType: _.kebabCase(RelationshipTypes.MANY_TO_ONE), | ||
@@ -276,4 +280,4 @@ otherEntityField: _.lowerFirst(otherSplitField.otherEntityField) | ||
splitField = extractField(relatedRelationship.injectedFieldInFrom); | ||
relationship.relationshipName = _.camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = _.lowerFirst(_.camelCase(relatedRelationship.to.name)); | ||
relationship.relationshipName = camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = camelCase(relatedRelationship.to.name); | ||
relationship.otherEntityField = _.lowerFirst(splitField.otherEntityField); | ||
@@ -283,4 +287,4 @@ } else if (relatedRelationship.type === RelationshipTypes.MANY_TO_MANY) { | ||
relationship.otherEntityRelationshipName = _.lowerFirst(extractField(relatedRelationship.injectedFieldInTo).relationshipName); | ||
relationship.relationshipName = _.camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = _.lowerFirst(_.camelCase(relatedRelationship.to.name)); | ||
relationship.relationshipName = camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = camelCase(relatedRelationship.to.name); | ||
relationship.otherEntityField = _.lowerFirst(splitField.otherEntityField); | ||
@@ -305,7 +309,10 @@ relationship.ownerSide = true; | ||
} | ||
if (relatedRelationship.commentInTo) { | ||
relationship.javadoc = relatedRelationship.commentInTo; | ||
} | ||
if (relatedRelationship.type === RelationshipTypes.ONE_TO_ONE) { | ||
splitField = extractField(relatedRelationship.injectedFieldInTo); | ||
otherSplitField = extractField(relatedRelationship.injectedFieldInFrom); | ||
relationship.relationshipName = _.camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = _.lowerFirst(_.camelCase(relatedRelationship.from.name)); | ||
relationship.relationshipName = camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = camelCase(relatedRelationship.from.name); | ||
relationship.ownerSide = false; | ||
@@ -316,9 +323,9 @@ relationship.otherEntityRelationshipName = _.lowerFirst(otherSplitField.relationshipName); | ||
splitField = extractField(relatedRelationship.injectedFieldInTo); | ||
relationship.relationshipName = _.lowerFirst(_.camelCase(splitField.relationshipName || relatedRelationship.from.name)); | ||
relationship.otherEntityName = _.lowerFirst(_.camelCase(relatedRelationship.from.name)); | ||
relationship.relationshipName = camelCase(splitField.relationshipName || relatedRelationship.from.name); | ||
relationship.otherEntityName = camelCase(relatedRelationship.from.name); | ||
relationship.otherEntityField = _.lowerFirst(splitField.otherEntityField); | ||
} else if (relatedRelationship.type === RelationshipTypes.MANY_TO_ONE && relatedRelationship.injectedFieldInTo) { | ||
splitField = extractField(relatedRelationship.injectedFieldInTo); | ||
relationship.relationshipName = _.camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = _.lowerFirst(_.camelCase(relatedRelationship.from.name)); | ||
relationship.relationshipName = camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = camelCase(relatedRelationship.from.name); | ||
relationship.relationshipType = 'one-to-many'; | ||
@@ -329,4 +336,4 @@ otherSplitField = extractField(relatedRelationship.injectedFieldInFrom); | ||
splitField = extractField(relatedRelationship.injectedFieldInTo); | ||
relationship.relationshipName = _.camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = _.lowerFirst(_.camelCase(relatedRelationship.from.name)); | ||
relationship.relationshipName = camelCase(splitField.relationshipName); | ||
relationship.otherEntityName = camelCase(relatedRelationship.from.name); | ||
relationship.ownerSide = false; | ||
@@ -333,0 +340,0 @@ relationship.otherEntityRelationshipName = _.lowerFirst(extractField(relatedRelationship.injectedFieldInFrom).relationshipName); |
@@ -16,3 +16,5 @@ 'use strict'; | ||
UnaryOptions = require('../core/jhipster/unary_options').UNARY_OPTIONS, | ||
BinaryOptions = require('../core/jhipster/binary_options').BINARY_OPTIONS; | ||
BinaryOptions = require('../core/jhipster/binary_options').BINARY_OPTIONS, | ||
buildException = require('../exceptions/exception_factory').buildException, | ||
exceptions = require('../exceptions/exception_factory').exceptions; | ||
@@ -24,2 +26,5 @@ module.exports = { | ||
const USER = 'User'; | ||
const USER_ENTITY = new JDLEntity({name: USER}); | ||
/* | ||
@@ -45,4 +50,10 @@ * Parses the json entities into JDL | ||
} | ||
let skipUserManagement = hasSkipUserManagement(jdl); | ||
for (let i = 0, entityNames = Object.keys(entities); i < entityNames.length; i++) { | ||
let entityName = entityNames[i]; | ||
if (entityName === USER && !skipUserManagement) { | ||
throw new buildException( | ||
exceptions.IllegalName, | ||
'User entity name is reserved if skipUserManagement is not set.'); | ||
} | ||
let entity = entities[entityName]; | ||
@@ -53,3 +64,3 @@ jdl.addEntity(jsonToJDLEntity(entity, entityName)); | ||
} | ||
addRelationshipsToJDL(jdl, entities); | ||
addRelationshipsToJDL(jdl, entities, skipUserManagement); | ||
return jdl; | ||
@@ -59,8 +70,8 @@ } | ||
/* | ||
* Parses the yo-rc.json into JDL | ||
* yoRcJson: a yo-rc.json content containing a jhipster app configuration | ||
* Parses the jhipster configuration into JDL | ||
* jhConfig: the jhipster config ('generator-jhipster' in .yo-rc.json) | ||
* jdl: JDLObject to which the parsed options are added. If undefined a new JDLObject is created. | ||
* returns the JDLObject | ||
*/ | ||
function parseServerOptions(yoRcJson, jdl) { | ||
function parseServerOptions(jhConfig, jdl) { | ||
if (jdl === undefined) { | ||
@@ -74,5 +85,5 @@ jdl = new JDLObject(); | ||
} | ||
for (let option of [UnaryOptions.SKIP_CLIENT, UnaryOptions.SKIP_SERVER]) | ||
if (yoRcJson['generator-jhipster'][option] === true) { | ||
jdl.addOption( new JDLUnaryOption({name: option, value: yoRcJson['generator-jhipster'][option]}) ); | ||
for (let option of [UnaryOptions.SKIP_CLIENT, UnaryOptions.SKIP_SERVER, UnaryOptions.SKIP_USER_MANAGEMENT]) | ||
if (jhConfig[option] === true) { | ||
jdl.addOption( new JDLUnaryOption({name: option, value: jhConfig[option]}) ); | ||
} | ||
@@ -116,3 +127,3 @@ return jdl; | ||
*/ | ||
function addRelationshipsToJDL(jdl, entities) { | ||
function addRelationshipsToJDL(jdl, entities, skipUserManagement) { | ||
for (let i = 0, entityNames = Object.keys(entities); i < entityNames.length; i++) { | ||
@@ -129,17 +140,28 @@ let entityName = entityNames[i]; | ||
let isInjectedFieldInToRequired; | ||
let otherEntity = entities[_.upperFirst(relationship.otherEntityName)]; | ||
if (otherEntity === undefined) { | ||
continue; | ||
} | ||
for (let relationship2 of otherEntity.relationships) { | ||
if (_.upperFirst(relationship2.otherEntityName) === entityName | ||
&& relationship2.otherEntityRelationshipName === relationship.relationshipName) { | ||
// Bidirectional relationship | ||
injectedFieldInTo = relationship2.relationshipName; | ||
if (relationship2.otherEntityField !== undefined && relationship2.otherEntityField !== 'id') { | ||
injectedFieldInTo += '(' + relationship2.otherEntityField + ')'; | ||
let commentInTo; | ||
let otherEntity; | ||
let toJdlEntity; | ||
if (relationship.otherEntityName.toLowerCase() === USER.toLowerCase() && !skipUserManagement) { | ||
toJdlEntity = USER_ENTITY; | ||
} else { | ||
otherEntity = entities[_.upperFirst(relationship.otherEntityName)]; | ||
if (otherEntity === undefined) { | ||
continue; | ||
} | ||
toJdlEntity = jdl.entities[_.upperFirst(relationship.otherEntityName)]; | ||
for (let relationship2 of otherEntity.relationships) { | ||
if (_.upperFirst(relationship2.otherEntityName) === entityName | ||
&& relationship2.otherEntityRelationshipName === relationship.relationshipName) { | ||
// Bidirectional relationship | ||
injectedFieldInTo = relationship2.relationshipName; | ||
if (relationship2.otherEntityField !== undefined && relationship2.otherEntityField !== 'id') { | ||
injectedFieldInTo += '(' + relationship2.otherEntityField + ')'; | ||
} | ||
if (relationship2.relationshipValidateRules) { | ||
isInjectedFieldInToRequired = true; | ||
} | ||
commentInTo = relationship2.javadoc; | ||
break; | ||
} | ||
if (relationship2.relationshipValidateRules) { | ||
isInjectedFieldInToRequired = true; | ||
} | ||
} | ||
@@ -163,3 +185,5 @@ } | ||
isInjectedFieldInFromRequired: isInjectedFieldInToRequired, | ||
isInjectedFieldInToRequired: relationship.relationshipValidateRules | ||
isInjectedFieldInToRequired: relationship.relationshipValidateRules, | ||
commentInFrom: commentInTo, | ||
commentInTo: relationship.javadoc | ||
})); | ||
@@ -174,3 +198,3 @@ } else { | ||
from: jdl.entities[entityName], | ||
to: jdl.entities[_.upperFirst(relationship.otherEntityName)], | ||
to: toJdlEntity, | ||
type: type, | ||
@@ -180,3 +204,5 @@ injectedFieldInFrom: injectedFieldInFrom, | ||
isInjectedFieldInFromRequired: relationship.relationshipValidateRules, | ||
isInjectedFieldInToRequired: isInjectedFieldInToRequired | ||
isInjectedFieldInToRequired: isInjectedFieldInToRequired, | ||
commentInFrom: relationship.javadoc, | ||
commentInTo: commentInTo | ||
})); | ||
@@ -206,1 +232,5 @@ } | ||
} | ||
function hasSkipUserManagement(jdl) { | ||
return jdl.options.filter( o => o.name == UnaryOptions.SKIP_USER_MANAGEMENT ).length > 0; | ||
} |
@@ -30,3 +30,3 @@ 'use strict'; | ||
} | ||
var jdl = Parser.parseServerOptions(Reader.readEntityJSON(dir + '/.yo-rc.json')); | ||
var jdl = Parser.parseServerOptions(Reader.readEntityJSON(dir + '/.yo-rc.json')['generator-jhipster']); | ||
var entityDir = dir + '/.jhipster'; | ||
@@ -33,0 +33,0 @@ var isJhipsterDirectory = false; |
'use strict'; | ||
const buildException = require('../exceptions/exception_factory').buildException, | ||
exceptions = require('../exceptions/exception_factory').exceptions; | ||
module.exports = { | ||
isNilOrEmpty: isNilOrEmpty | ||
isNilOrEmpty: isNilOrEmpty, | ||
camelCase: camelCase | ||
}; | ||
@@ -10,1 +14,12 @@ | ||
} | ||
function camelCase(string) { | ||
if (string == null) { | ||
throw new buildException(exceptions.NullPointer, 'The passed string cannot be nil.'); | ||
} | ||
if (string === '') { | ||
return string; | ||
} | ||
string = string.replace(/[\W_]/g, ''); | ||
return `${string[0].toLowerCase()}${string.slice(1, string.length)}`; | ||
} |
@@ -30,2 +30,3 @@ 'use strict'; | ||
ObjectUtils = require('../lib/utils/object_utils'), | ||
StringUtils = require('../lib/utils/string_utils'), | ||
Set = require('../lib/utils/objects/set'); | ||
@@ -78,3 +79,5 @@ | ||
/* Objects */ | ||
Set: Set | ||
Set: Set, | ||
/* Utils */ | ||
camelCase: StringUtils.camelCase | ||
}; |
{ | ||
"name": "jhipster-core", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "JHipster's own domain language and core objects", | ||
@@ -11,4 +11,4 @@ "main": "module/index.js", | ||
"scripts": { | ||
"test": "mocha test/**/*.js", | ||
"coverage": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha test/**/*.js -- --ui bdd -R spec -t 5000", | ||
"test": "mocha test", | ||
"coverage": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha test -- -t 5000", | ||
"peg-parse": "pegjs lib/dsl/grammar.txt lib/dsl/pegjs_parser.js" | ||
@@ -36,9 +36,10 @@ }, | ||
"dependencies": { | ||
"lodash": "4.16.4" | ||
"lodash": "4.17.2" | ||
}, | ||
"devDependencies": { | ||
"pegjs": "0.10.0", | ||
"mocha": "3.1.0", | ||
"mocha": "3.1.2", | ||
"chai": "3.5.0", | ||
"istanbul": "0.4.5" | ||
"istanbul": "0.4.5", | ||
"mocha-clean": "1.0.0" | ||
}, | ||
@@ -45,0 +46,0 @@ "peerDependencies": {}, |
@@ -50,2 +50,3 @@ 'use strict'; | ||
"relationshipType": "one-to-many", | ||
"javadoc": "A relationship", | ||
"relationshipName": "employee", | ||
@@ -52,0 +53,0 @@ "otherEntityName": "employee", |
@@ -56,2 +56,3 @@ 'use strict'; | ||
expect(content.Department.relationships.length).to.eq(2); | ||
expect(content.Department.relationships[1].javadoc).to.eq('A relationship'); | ||
expect(content.Department.fields.length).to.eq(2); | ||
@@ -61,2 +62,3 @@ expect(content.Department.entityTableName).to.eq('department'); | ||
expect(content.Employee.pagination).to.eq('infinite-scroll'); | ||
expect(content.Employee.relationships[3].javadoc).to.eq('Another side of the same relationship'); | ||
expect(content.Job.relationships[0].otherEntityRelationshipName).to.eq('job'); | ||
@@ -63,0 +65,0 @@ expect(content.Task.relationships[0].otherEntityRelationshipName).to.eq('chore'); |
@@ -130,2 +130,22 @@ 'use strict'; | ||
}); | ||
it('parses comments in relationships for owner', function () { | ||
var entities = { | ||
'Department': Reader.readEntityJSON('./test/test_files/jhipster_app/.jhipster/Department.json'), | ||
'Employee': Reader.readEntityJSON('./test/test_files/jhipster_app/.jhipster/Employee.json') | ||
}; | ||
entities.Employee.relationships.filter(r => r.relationshipName === 'department')[0].javadoc = undefined; | ||
var content = Parser.parseEntities(entities); | ||
expect(content.relationships.relationships.OneToMany['OneToMany_Department{employee}_Employee{department(foo)}'].commentInFrom).to.eq('A relationship'); | ||
expect(content.relationships.relationships.OneToMany['OneToMany_Department{employee}_Employee{department(foo)}'].commentInTo).to.be.undefined; | ||
}); | ||
it('parses comments in relationships for owned', function () { | ||
var entities = { | ||
'Department': Reader.readEntityJSON('./test/test_files/jhipster_app/.jhipster/Department.json'), | ||
'Employee': Reader.readEntityJSON('./test/test_files/jhipster_app/.jhipster/Employee.json') | ||
}; | ||
entities.Department.relationships.filter(r => r.relationshipName === 'employee')[0].javadoc = undefined; | ||
var content = Parser.parseEntities(entities); | ||
expect(content.relationships.relationships.OneToMany['OneToMany_Department{employee}_Employee{department(foo)}'].commentInFrom).to.be.undefined; | ||
expect(content.relationships.relationships.OneToMany['OneToMany_Department{employee}_Employee{department(foo)}'].commentInTo).to.eq('Another side of the same relationship'); | ||
}); | ||
it('parses required relationships in owner', function () { | ||
@@ -154,3 +174,3 @@ var entities = { | ||
var yoRcJson = Reader.readEntityJSON('./test/test_files/jhipster_app/.yo-rc.json'); | ||
var content = Parser.parseServerOptions(yoRcJson); | ||
var content = Parser.parseServerOptions(yoRcJson['generator-jhipster']); | ||
expect(content.options.filter( o => o.name === UnaryOptions.SKIP_CLIENT && o.entityNames.has('*')).length).eq(1); | ||
@@ -161,2 +181,47 @@ expect(content.options.filter( o => o.name === UnaryOptions.SKIP_SERVER && o.entityNames.has('*')).length).eq(1); | ||
describe('when parsing entities with relationships to User', function () { | ||
describe('when skipUserManagement flag is not set', function () { | ||
describe('when there is no User.json entity', function () { | ||
it('parses relationships to the JHipster managed User entity', function () { | ||
var entities = { | ||
Country: Reader.readEntityJSON('./test/test_files/jhipster_app/.jhipster/Country.json') | ||
}; | ||
var content = Parser.parseEntities(entities); | ||
expect(content.relationships.relationships.OneToOne).has.property('OneToOne_Country{user}_User'); | ||
}); | ||
}); | ||
describe('when there is a User.json entity', function () { | ||
it('throws an error ', function () { | ||
try { | ||
var entities = { | ||
Country: Reader.readEntityJSON('./test/test_files/jhipster_app/.jhipster/Country.json'), | ||
User: Reader.readEntityJSON('./test/test_files/jhipster_app/.jhipster/Region.json') | ||
}; | ||
Parser.parseEntities(entities); | ||
fail(); | ||
} catch (error) { | ||
expect(error.name).to.eq('IllegalNameException') | ||
} | ||
}); | ||
}); | ||
}); | ||
describe('when skipUserManagement flag is set', function () { | ||
it('parses the User.json entity if skipUserManagement flag is set', function () { | ||
var entities = { | ||
Country: Reader.readEntityJSON('./test/test_files/jhipster_app/.jhipster/Country.json'), | ||
User: Reader.readEntityJSON('./test/test_files/jhipster_app/.jhipster/Region.json') | ||
}; | ||
entities.User.relationships[0].otherEntityRelationshipName = 'user'; | ||
var yoRcJson = Reader.readEntityJSON('./test/test_files/jhipster_app/.yo-rc.json'); | ||
yoRcJson['generator-jhipster'].skipUserManagement = true; | ||
var content = Parser.parseServerOptions(yoRcJson['generator-jhipster']); | ||
Parser.parseEntities(entities, content); | ||
expect(content.entities.Country).not.to.be.undefined; | ||
expect(content.entities.User).not.to.be.undefined; | ||
expect(content.entities.User.fields.regionId).not.to.be.undefined; | ||
expect(content.relationships.relationships.OneToOne).has.property('OneToOne_Country{user}_User{country}'); | ||
}); | ||
}); | ||
}); | ||
}); |
'use strict'; | ||
const expect = require('chai').expect, | ||
fail = expect.fail, | ||
camelCase = require('../../../lib/utils/string_utils').camelCase, | ||
isNilOrEmpty = require('../../../lib/utils/string_utils').isNilOrEmpty; | ||
describe('::isNilOrEmpty', function() { | ||
describe('when passing a nil object', function() { | ||
it('returns true', function() { | ||
expect(isNilOrEmpty(null)).to.be.true; | ||
describe('StringUtils', () => { | ||
describe('::camelCase', () => { | ||
describe('when passing a valid string', () => { | ||
it('camel-cases it', () => { | ||
expect(camelCase('e')).to.eq('e'); | ||
expect(camelCase('entity')).to.eq('entity'); | ||
expect(camelCase('Entity')).to.eq('entity'); | ||
expect(camelCase('EntityA')).to.eq('entityA'); | ||
expect(camelCase('EntityAN')).to.eq('entityAN'); | ||
expect(camelCase('Entity_AN')).to.eq('entityAN'); | ||
expect(camelCase('_entity_AN')).to.eq('entityAN'); | ||
expect(camelCase('_entit--y_AN---')).to.eq('entityAN'); | ||
expect(camelCase('En tity_AN ')).to.eq('entityAN'); | ||
}); | ||
}); | ||
}); | ||
describe('when passing an undefined object', function() { | ||
it('returns true', function() { | ||
expect(isNilOrEmpty(undefined)).to.be.true; | ||
describe('when passing an invalid parameter', () => { | ||
describe('as it is nil', () => { | ||
it('fails', () => { | ||
try { | ||
camelCase(); | ||
fail(); | ||
} catch (error) { | ||
expect(error.name).to.eq('NullPointerException'); | ||
} | ||
}); | ||
}); | ||
describe('as it is empty', () => { | ||
it('returns it', () => { | ||
expect(camelCase('')).to.eq(''); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('when passing an empty string', function() { | ||
it('returns true', function() { | ||
expect(isNilOrEmpty('')).to.be.true; | ||
describe('::isNilOrEmpty', () => { | ||
describe('when passing a nil object', () => { | ||
it('returns true', () => { | ||
expect(isNilOrEmpty(null)).to.be.true; | ||
}); | ||
}); | ||
}); | ||
describe('when passing a valid string', function() { | ||
it('returns false', function() { | ||
expect(isNilOrEmpty('ABC')).to.be.false; | ||
describe('when passing an undefined object', () => { | ||
it('returns true', () => { | ||
expect(isNilOrEmpty(undefined)).to.be.true; | ||
}); | ||
}); | ||
describe('when passing an empty string', () => { | ||
it('returns true', () => { | ||
expect(isNilOrEmpty('')).to.be.true; | ||
}); | ||
}); | ||
describe('when passing a valid string', () => { | ||
it('returns false', () => { | ||
expect(isNilOrEmpty('ABC')).to.be.false; | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -11,2 +11,10 @@ { | ||
"otherEntityRelationshipName": "country" | ||
}, | ||
{ | ||
"relationshipType": "one-to-one", | ||
"relationshipName": "user", | ||
"otherEntityName": "user", | ||
"otherEntityField": "id", | ||
"ownerSide": true, | ||
"otherEntityRelationshipName": "country" | ||
} | ||
@@ -13,0 +21,0 @@ ], |
@@ -17,2 +17,3 @@ { | ||
"otherEntityName": "employee", | ||
"javadoc": "A relationship", | ||
"otherEntityRelationshipName": "department" | ||
@@ -38,4 +39,3 @@ } | ||
"pagination": "no", | ||
"service": "no", | ||
"fluentMethods": false | ||
"service": "no" | ||
} |
@@ -6,2 +6,3 @@ { | ||
"otherEntityName": "department", | ||
"javadoc": "Another side of the same relationship", | ||
"relationshipType": "many-to-one", | ||
@@ -8,0 +9,0 @@ "otherEntityField": "foo" |
@@ -28,2 +28,3 @@ { | ||
], | ||
"skipUserManagement": false, | ||
"skipClient": true, | ||
@@ -30,0 +31,0 @@ "skipServer": true |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
487453
102
12415
5
+ Addedlodash@4.17.2(transitive)
- Removedlodash@4.16.4(transitive)
Updatedlodash@4.17.2