Skip to content

Commit

Permalink
use generatePKeyValue in ResourceIT tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tcharl committed Apr 14, 2021
1 parent 0aa5542 commit 9cca793
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
-%>
// Initialize the database
<%_ if (!primaryKey.autoGenerate && !databaseTypeSql) { _%>
<%_ if (primaryKey.typeUUID) { _%>
<%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(UUID.randomUUID());
<%_ } _%>
<%= persistInstance %>.set<%= primaryKey.nameCapitalized %>(<%- getPrimaryKeyValue(primaryKey.type, databaseType) -%>);
<%_ } _%>
<%= entityInstance %>Repository.<%= saveMethod %>(<%= persistInstance %>)<%= callBlock %>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1515,13 +1515,13 @@ class <%= entityClass %>ResourceIT <% if (databaseType === 'cassandra') { %>exte
@Test<%= transactionalAnnotation %>
void partialUpdate<%= entityClass %>WithPatch() throws Exception {
<% const fieldsToIncludeInPartialPatchTest = fields.filter(field => !field.id && !field.transient).map(field => prepareFieldForPatchTest(field, () => faker.datatype.boolean())); %>
<%- include('/partials/it_patch_update.partial.java.ejs', {fields: fieldsToIncludeInPartialPatchTest, saveMethod, asEntity, callBlock, callListBlock}); -%>
<%- include('/partials/it_patch_update.partial.java.ejs', {fields: fieldsToIncludeInPartialPatchTest, saveMethod, asEntity, callBlock, callListBlock, getPrimaryKeyValue}); -%>
}

@Test<%= transactionalAnnotation %>
void fullUpdate<%= entityClass %>WithPatch() throws Exception {
<% const fieldsToIncludeInFullPatchTest = fields.filter(field => !field.id && !field.transient).map(field => prepareFieldForPatchTest(field, () => true)); %>
<%- include('/partials/it_patch_update.partial.java.ejs', {fields: fieldsToIncludeInFullPatchTest, saveMethod, asEntity, callBlock, callListBlock}); -%>
<%- include('/partials/it_patch_update.partial.java.ejs', {fields: fieldsToIncludeInFullPatchTest, saveMethod, asEntity, callBlock, callListBlock, getPrimaryKeyValue}); -%>
}

@Test<%= transactionalAnnotation %>
Expand Down
3 changes: 1 addition & 2 deletions utils/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const { MapperTypes } = require('../jdl/jhipster/entity-options');
const { OAUTH2 } = require('../jdl/jhipster/authentication-types');
const { CommonDBTypes } = require('../jdl/jhipster/field-types');

const { BOOLEAN, LONG, UUID } = CommonDBTypes;
const { BOOLEAN, LONG } = CommonDBTypes;
const { MAPSTRUCT } = MapperTypes;
const { PAGINATION, INFINITE_SCROLL } = PaginationTypes;
const NO_PAGINATION = PaginationTypes.NO;
Expand Down Expand Up @@ -358,7 +358,6 @@ function prepareEntityPrimaryKeyForTemplates(entityWithConfig, generator, enable
name: primaryKeyName,
nameCapitalized: _.upperFirst(primaryKeyName),
type: primaryKeyType,
typeUUID: primaryKeyType === UUID,
tsType: generator.getTypescriptKeyType(primaryKeyType),
composite,
relationships: idRelationships,
Expand Down

0 comments on commit 9cca793

Please sign in to comment.