removing duplicate userId from entity UserRoleAssignment

(it comes implicitly through the relationship)
This commit is contained in:
Michael Hoennig 2019-04-30 18:04:25 +02:00
commit 4529527e3b
23 changed files with 42 additions and 180 deletions

View File

@ -49,7 +49,7 @@
"otherEntityField": "admissionDocumentDate" "otherEntityField": "admissionDocumentDate"
} }
], ],
"changelogDate": "20190430152139", "changelogDate": "20190430154657",
"entityTableName": "asset", "entityTableName": "asset",
"dto": "mapstruct", "dto": "mapstruct",
"pagination": "infinite-scroll", "pagination": "infinite-scroll",

View File

@ -142,7 +142,7 @@
"relationshipName": "sepamandate" "relationshipName": "sepamandate"
} }
], ],
"changelogDate": "20190430152136", "changelogDate": "20190430154654",
"entityTableName": "customer", "entityTableName": "customer",
"dto": "mapstruct", "dto": "mapstruct",
"pagination": "infinite-scroll", "pagination": "infinite-scroll",

View File

@ -54,7 +54,7 @@
"otherEntityField": "prefix" "otherEntityField": "prefix"
} }
], ],
"changelogDate": "20190430152137", "changelogDate": "20190430154655",
"entityTableName": "membership", "entityTableName": "membership",
"dto": "mapstruct", "dto": "mapstruct",
"pagination": "infinite-scroll", "pagination": "infinite-scroll",

View File

@ -72,7 +72,7 @@
"otherEntityField": "prefix" "otherEntityField": "prefix"
} }
], ],
"changelogDate": "20190430152140", "changelogDate": "20190430154658",
"entityTableName": "sepa_mandate", "entityTableName": "sepa_mandate",
"dto": "mapstruct", "dto": "mapstruct",
"pagination": "infinite-scroll", "pagination": "infinite-scroll",

View File

@ -49,7 +49,7 @@
"otherEntityField": "admissionDocumentDate" "otherEntityField": "admissionDocumentDate"
} }
], ],
"changelogDate": "20190430152138", "changelogDate": "20190430154656",
"entityTableName": "share", "entityTableName": "share",
"dto": "mapstruct", "dto": "mapstruct",
"pagination": "infinite-scroll", "pagination": "infinite-scroll",

View File

@ -9,13 +9,6 @@
"fieldName": "entityObjectId", "fieldName": "entityObjectId",
"fieldType": "Long" "fieldType": "Long"
}, },
{
"fieldName": "userId",
"fieldType": "Long",
"fieldValidateRules": [
"required"
]
},
{ {
"fieldName": "assignedRole", "fieldName": "assignedRole",
"fieldType": "UserRole", "fieldType": "UserRole",
@ -34,7 +27,7 @@
"otherEntityField": "login" "otherEntityField": "login"
} }
], ],
"changelogDate": "20190430152204", "changelogDate": "20190430154711",
"entityTableName": "user_role_assignment", "entityTableName": "user_role_assignment",
"dto": "no", "dto": "no",
"pagination": "infinite-scroll", "pagination": "infinite-scroll",

View File

@ -0,0 +1,31 @@
git checkout jhipster-generated
git pull
git tag REAL-HEAD
git reset --hard jdl-base
git clean -f -d
git cherry-pick -n spotless
git reset --soft REAL-HEAD
git checkout REAL-HEAD src/main/jdl/customer.jdl # AND OTHERS!
git tag -d REAL-HEAD
# MANUAL STEP: Apply changes to the jdl file!
# (Re-) Importing
jhipster import-jdl src/main/jdl/customer.jdl
jhipster import-jdl src/main/jdl/accessrights.jdl
# AND OTHERS!
# add @formatter:off to src/main/java/org/hostsharing/hsadminng/config/SecurityConfiguration.java
# I will add this change to the commit with the spotless commit to get rid of this.
gw spotlessApply
git add .
git commit -m"..."
# MANUAL STEP:
# - if you've renamed any identifiers, use refactoring to rename in master as well BEFORE MERGING!
# Merge changeset into master branch
git checkout master
git merge jhipster-generated

View File

@ -35,8 +35,6 @@ apply plugin: 'java'
apply plugin: 'org.owasp.dependencycheck' apply plugin: 'org.owasp.dependencycheck'
sourceCompatibility=1.8 sourceCompatibility=1.8
targetCompatibility=1.8 targetCompatibility=1.8
// Until JHipster supports JDK 9
assert System.properties['java.specification.version'] == '1.8'
apply plugin: 'maven' apply plugin: 'maven'
apply plugin: 'org.springframework.boot' apply plugin: 'org.springframework.boot'

View File

@ -31,10 +31,6 @@ public class UserRoleAssignment implements Serializable {
@Column(name = "entity_object_id") @Column(name = "entity_object_id")
private Long entityObjectId; private Long entityObjectId;
@NotNull
@Column(name = "user_id", nullable = false)
private Long userId;
@NotNull @NotNull
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
@Column(name = "assigned_role", nullable = false) @Column(name = "assigned_role", nullable = false)
@ -79,19 +75,6 @@ public class UserRoleAssignment implements Serializable {
this.entityObjectId = entityObjectId; this.entityObjectId = entityObjectId;
} }
public Long getUserId() {
return userId;
}
public UserRoleAssignment userId(Long userId) {
this.userId = userId;
return this;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public UserRole getAssignedRole() { public UserRole getAssignedRole() {
return assignedRole; return assignedRole;
} }
@ -145,7 +128,6 @@ public class UserRoleAssignment implements Serializable {
"id=" + getId() + "id=" + getId() +
", entityTypeId='" + getEntityTypeId() + "'" + ", entityTypeId='" + getEntityTypeId() + "'" +
", entityObjectId=" + getEntityObjectId() + ", entityObjectId=" + getEntityObjectId() +
", userId=" + getUserId() +
", assignedRole='" + getAssignedRole() + "'" + ", assignedRole='" + getAssignedRole() + "'" +
"}"; "}";
} }

View File

@ -96,9 +96,6 @@ public class UserRoleAssignmentQueryService extends QueryService<UserRoleAssignm
specification = specification specification = specification
.and(buildRangeSpecification(criteria.getEntityObjectId(), UserRoleAssignment_.entityObjectId)); .and(buildRangeSpecification(criteria.getEntityObjectId(), UserRoleAssignment_.entityObjectId));
} }
if (criteria.getUserId() != null) {
specification = specification.and(buildRangeSpecification(criteria.getUserId(), UserRoleAssignment_.userId));
}
if (criteria.getAssignedRole() != null) { if (criteria.getAssignedRole() != null) {
specification = specification specification = specification
.and(buildSpecification(criteria.getAssignedRole(), UserRoleAssignment_.assignedRole)); .and(buildSpecification(criteria.getAssignedRole(), UserRoleAssignment_.assignedRole));

View File

@ -34,8 +34,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
private LongFilter entityObjectId; private LongFilter entityObjectId;
private LongFilter userId;
private UserRoleFilter assignedRole; private UserRoleFilter assignedRole;
private LongFilter userId; private LongFilter userId;
@ -64,14 +62,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
this.entityObjectId = entityObjectId; this.entityObjectId = entityObjectId;
} }
public LongFilter getUserId() {
return userId;
}
public void setUserId(LongFilter userId) {
this.userId = userId;
}
public UserRoleFilter getAssignedRole() { public UserRoleFilter getAssignedRole() {
return assignedRole; return assignedRole;
} }
@ -100,7 +90,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
return Objects.equals(id, that.id) && return Objects.equals(id, that.id) &&
Objects.equals(entityTypeId, that.entityTypeId) && Objects.equals(entityTypeId, that.entityTypeId) &&
Objects.equals(entityObjectId, that.entityObjectId) && Objects.equals(entityObjectId, that.entityObjectId) &&
Objects.equals(userId, that.userId) &&
Objects.equals(assignedRole, that.assignedRole) && Objects.equals(assignedRole, that.assignedRole) &&
Objects.equals(userId, that.userId); Objects.equals(userId, that.userId);
} }
@ -111,7 +100,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
id, id,
entityTypeId, entityTypeId,
entityObjectId, entityObjectId,
userId,
assignedRole, assignedRole,
userId); userId);
} }
@ -122,7 +110,6 @@ public class UserRoleAssignmentCriteria implements Serializable {
(id != null ? "id=" + id + ", " : "") + (id != null ? "id=" + id + ", " : "") +
(entityTypeId != null ? "entityTypeId=" + entityTypeId + ", " : "") + (entityTypeId != null ? "entityTypeId=" + entityTypeId + ", " : "") +
(entityObjectId != null ? "entityObjectId=" + entityObjectId + ", " : "") + (entityObjectId != null ? "entityObjectId=" + entityObjectId + ", " : "") +
(userId != null ? "userId=" + userId + ", " : "") +
(assignedRole != null ? "assignedRole=" + assignedRole + ", " : "") + (assignedRole != null ? "assignedRole=" + assignedRole + ", " : "") +
(userId != null ? "userId=" + userId + ", " : "") + (userId != null ? "userId=" + userId + ", " : "") +
"}"; "}";

View File

@ -14,7 +14,6 @@ enum UserRole {
entity UserRoleAssignment { entity UserRoleAssignment {
entityTypeId String, entityTypeId String,
entityObjectId Long, entityObjectId Long,
userId Long required,
assignedRole UserRole required assignedRole UserRole required
} }

View File

@ -16,7 +16,7 @@
<!-- <!--
Added the entity UserRoleAssignment. Added the entity UserRoleAssignment.
--> -->
<changeSet id="20190430152204-1" author="jhipster"> <changeSet id="20190430154711-1" author="jhipster">
<createTable tableName="user_role_assignment"> <createTable tableName="user_role_assignment">
<column name="id" type="bigint" autoIncrement="${autoIncrement}"> <column name="id" type="bigint" autoIncrement="${autoIncrement}">
<constraints primaryKey="true" nullable="false"/> <constraints primaryKey="true" nullable="false"/>
@ -29,10 +29,6 @@
<constraints nullable="true" /> <constraints nullable="true" />
</column> </column>
<column name="user_id" type="bigint">
<constraints nullable="false" />
</column>
<column name="assigned_role" type="varchar(255)"> <column name="assigned_role" type="varchar(255)">
<constraints nullable="false" /> <constraints nullable="false" />
</column> </column>

View File

@ -6,7 +6,7 @@
<!-- <!--
Added the constraints for entity UserRoleAssignment. Added the constraints for entity UserRoleAssignment.
--> -->
<changeSet id="20190430152204-2" author="jhipster"> <changeSet id="20190430154711-2" author="jhipster">
<addForeignKeyConstraint baseColumnNames="user_id" <addForeignKeyConstraint baseColumnNames="user_id"
baseTableName="user_role_assignment" baseTableName="user_role_assignment"

View File

@ -10,13 +10,13 @@
<include file="config/liquibase/changelog/20190430152138_added_entity_Share.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190430152138_added_entity_Share.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152139_added_entity_Asset.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190430152139_added_entity_Asset.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152140_added_entity_SepaMandate.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190430152140_added_entity_SepaMandate.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152204_added_entity_UserRoleAssignment.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190430154711_added_entity_UserRoleAssignment.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here --> <!-- jhipster-needle-liquibase-add-changelog - JHipster will add liquibase changelogs here -->
<include file="config/liquibase/changelog/20190430152137_added_entity_constraints_Membership.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190430152137_added_entity_constraints_Membership.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152138_added_entity_constraints_Share.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190430152138_added_entity_constraints_Share.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152139_added_entity_constraints_Asset.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190430152139_added_entity_constraints_Asset.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152140_added_entity_constraints_SepaMandate.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190430152140_added_entity_constraints_SepaMandate.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20190430152204_added_entity_constraints_UserRoleAssignment.xml" relativeToChangelogFile="false"/> <include file="config/liquibase/changelog/20190430154711_added_entity_constraints_UserRoleAssignment.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here --> <!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
<!-- sample data --> <!-- sample data -->

View File

@ -13,10 +13,6 @@
<dd> <dd>
<span>{{userRoleAssignment.entityObjectId}}</span> <span>{{userRoleAssignment.entityObjectId}}</span>
</dd> </dd>
<dt><span jhiTranslate="hsadminNgApp.userRoleAssignment.userId">User Id</span></dt>
<dd>
<span>{{userRoleAssignment.userId}}</span>
</dd>
<dt><span jhiTranslate="hsadminNgApp.userRoleAssignment.assignedRole">Assigned Role</span></dt> <dt><span jhiTranslate="hsadminNgApp.userRoleAssignment.assignedRole">Assigned Role</span></dt>
<dd> <dd>
<span jhiTranslate="{{'hsadminNgApp.UserRole.' + userRoleAssignment.assignedRole}}">{{userRoleAssignment.assignedRole}}</span> <span jhiTranslate="{{'hsadminNgApp.UserRole.' + userRoleAssignment.assignedRole}}">{{userRoleAssignment.assignedRole}}</span>

View File

@ -19,21 +19,6 @@
<input type="number" class="form-control" name="entityObjectId" id="field_entityObjectId" <input type="number" class="form-control" name="entityObjectId" id="field_entityObjectId"
[(ngModel)]="userRoleAssignment.entityObjectId" /> [(ngModel)]="userRoleAssignment.entityObjectId" />
</div> </div>
<div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.userRoleAssignment.userId" for="field_userId">User Id</label>
<input type="number" class="form-control" name="userId" id="field_userId"
[(ngModel)]="userRoleAssignment.userId" required/>
<div [hidden]="!(editForm.controls.userId?.dirty && editForm.controls.userId?.invalid)">
<small class="form-text text-danger"
[hidden]="!editForm.controls.userId?.errors?.required" jhiTranslate="entity.validation.required">
This field is required.
</small>
<small class="form-text text-danger"
[hidden]="!editForm.controls.userId?.errors?.number" jhiTranslate="entity.validation.number">
This field should be a number.
</small>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="form-control-label" jhiTranslate="hsadminNgApp.userRoleAssignment.assignedRole" for="field_assignedRole">Assigned Role</label> <label class="form-control-label" jhiTranslate="hsadminNgApp.userRoleAssignment.assignedRole" for="field_assignedRole">Assigned Role</label>
<select class="form-control" name="assignedRole" [(ngModel)]="userRoleAssignment.assignedRole" id="field_assignedRole" required> <select class="form-control" name="assignedRole" [(ngModel)]="userRoleAssignment.assignedRole" id="field_assignedRole" required>

View File

@ -17,7 +17,6 @@
<th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <fa-icon [icon]="'sort'"></fa-icon></th> <th jhiSortBy="id"><span jhiTranslate="global.field.id">ID</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="entityTypeId"><span jhiTranslate="hsadminNgApp.userRoleAssignment.entityTypeId">Entity Type Id</span> <fa-icon [icon]="'sort'"></fa-icon></th> <th jhiSortBy="entityTypeId"><span jhiTranslate="hsadminNgApp.userRoleAssignment.entityTypeId">Entity Type Id</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="entityObjectId"><span jhiTranslate="hsadminNgApp.userRoleAssignment.entityObjectId">Entity Object Id</span> <fa-icon [icon]="'sort'"></fa-icon></th> <th jhiSortBy="entityObjectId"><span jhiTranslate="hsadminNgApp.userRoleAssignment.entityObjectId">Entity Object Id</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="userId"><span jhiTranslate="hsadminNgApp.userRoleAssignment.userId">User Id</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="assignedRole"><span jhiTranslate="hsadminNgApp.userRoleAssignment.assignedRole">Assigned Role</span> <fa-icon [icon]="'sort'"></fa-icon></th> <th jhiSortBy="assignedRole"><span jhiTranslate="hsadminNgApp.userRoleAssignment.assignedRole">Assigned Role</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th jhiSortBy="user.login"><span jhiTranslate="hsadminNgApp.userRoleAssignment.user">User</span> <fa-icon [icon]="'sort'"></fa-icon></th> <th jhiSortBy="user.login"><span jhiTranslate="hsadminNgApp.userRoleAssignment.user">User</span> <fa-icon [icon]="'sort'"></fa-icon></th>
<th></th> <th></th>
@ -28,7 +27,6 @@
<td><a [routerLink]="['/user-role-assignment', userRoleAssignment.id, 'view' ]">{{userRoleAssignment.id}}</a></td> <td><a [routerLink]="['/user-role-assignment', userRoleAssignment.id, 'view' ]">{{userRoleAssignment.id}}</a></td>
<td>{{userRoleAssignment.entityTypeId}}</td> <td>{{userRoleAssignment.entityTypeId}}</td>
<td>{{userRoleAssignment.entityObjectId}}</td> <td>{{userRoleAssignment.entityObjectId}}</td>
<td>{{userRoleAssignment.userId}}</td>
<td jhiTranslate="{{'hsadminNgApp.UserRole.' + userRoleAssignment.assignedRole}}">{{userRoleAssignment.assignedRole}}</td> <td jhiTranslate="{{'hsadminNgApp.UserRole.' + userRoleAssignment.assignedRole}}">{{userRoleAssignment.assignedRole}}</td>
<td> <td>
{{userRoleAssignment.user?.login}} {{userRoleAssignment.user?.login}}

View File

@ -14,7 +14,6 @@ export interface IUserRoleAssignment {
id?: number; id?: number;
entityTypeId?: string; entityTypeId?: string;
entityObjectId?: number; entityObjectId?: number;
userId?: number;
assignedRole?: UserRole; assignedRole?: UserRole;
user?: IUser; user?: IUser;
} }
@ -24,7 +23,6 @@ export class UserRoleAssignment implements IUserRoleAssignment {
public id?: number, public id?: number,
public entityTypeId?: string, public entityTypeId?: string,
public entityObjectId?: number, public entityObjectId?: number,
public userId?: number,
public assignedRole?: UserRole, public assignedRole?: UserRole,
public user?: IUser public user?: IUser
) {} ) {}

View File

@ -17,7 +17,6 @@
}, },
"entityTypeId": "Entity Type Id", "entityTypeId": "Entity Type Id",
"entityObjectId": "Entity Object Id", "entityObjectId": "Entity Object Id",
"userId": "User Id",
"assignedRole": "Assigned Role", "assignedRole": "Assigned Role",
"user": "User" "user": "User"
} }

View File

@ -17,7 +17,6 @@
}, },
"entityTypeId": "Entity Type Id", "entityTypeId": "Entity Type Id",
"entityObjectId": "Entity Object Id", "entityObjectId": "Entity Object Id",
"userId": "User Id",
"assignedRole": "Assigned Role", "assignedRole": "Assigned Role",
"user": "User" "user": "User"
} }

View File

@ -50,9 +50,6 @@ public class UserRoleAssignmentResourceIntTest {
private static final Long DEFAULT_ENTITY_OBJECT_ID = 1L; private static final Long DEFAULT_ENTITY_OBJECT_ID = 1L;
private static final Long UPDATED_ENTITY_OBJECT_ID = 2L; private static final Long UPDATED_ENTITY_OBJECT_ID = 2L;
private static final Long DEFAULT_USER_ID = 1L;
private static final Long UPDATED_USER_ID = 2L;
private static final UserRole DEFAULT_ASSIGNED_ROLE = UserRole.HOSTMASTER; private static final UserRole DEFAULT_ASSIGNED_ROLE = UserRole.HOSTMASTER;
private static final UserRole UPDATED_ASSIGNED_ROLE = UserRole.ADMIN; private static final UserRole UPDATED_ASSIGNED_ROLE = UserRole.ADMIN;
@ -109,7 +106,6 @@ public class UserRoleAssignmentResourceIntTest {
UserRoleAssignment userRoleAssignment = new UserRoleAssignment() UserRoleAssignment userRoleAssignment = new UserRoleAssignment()
.entityTypeId(DEFAULT_ENTITY_TYPE_ID) .entityTypeId(DEFAULT_ENTITY_TYPE_ID)
.entityObjectId(DEFAULT_ENTITY_OBJECT_ID) .entityObjectId(DEFAULT_ENTITY_OBJECT_ID)
.userId(DEFAULT_USER_ID)
.assignedRole(DEFAULT_ASSIGNED_ROLE); .assignedRole(DEFAULT_ASSIGNED_ROLE);
return userRoleAssignment; return userRoleAssignment;
} }
@ -137,7 +133,6 @@ public class UserRoleAssignmentResourceIntTest {
UserRoleAssignment testUserRoleAssignment = userRoleAssignmentList.get(userRoleAssignmentList.size() - 1); UserRoleAssignment testUserRoleAssignment = userRoleAssignmentList.get(userRoleAssignmentList.size() - 1);
assertThat(testUserRoleAssignment.getEntityTypeId()).isEqualTo(DEFAULT_ENTITY_TYPE_ID); assertThat(testUserRoleAssignment.getEntityTypeId()).isEqualTo(DEFAULT_ENTITY_TYPE_ID);
assertThat(testUserRoleAssignment.getEntityObjectId()).isEqualTo(DEFAULT_ENTITY_OBJECT_ID); assertThat(testUserRoleAssignment.getEntityObjectId()).isEqualTo(DEFAULT_ENTITY_OBJECT_ID);
assertThat(testUserRoleAssignment.getUserId()).isEqualTo(DEFAULT_USER_ID);
assertThat(testUserRoleAssignment.getAssignedRole()).isEqualTo(DEFAULT_ASSIGNED_ROLE); assertThat(testUserRoleAssignment.getAssignedRole()).isEqualTo(DEFAULT_ASSIGNED_ROLE);
} }
@ -161,25 +156,6 @@ public class UserRoleAssignmentResourceIntTest {
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeCreate); assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeCreate);
} }
@Test
@Transactional
public void checkUserIdIsRequired() throws Exception {
int databaseSizeBeforeTest = userRoleAssignmentRepository.findAll().size();
// set the field null
userRoleAssignment.setUserId(null);
// Create the UserRoleAssignment, which fails.
restUserRoleAssignmentMockMvc.perform(
post("/api/user-role-assignments")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(userRoleAssignment)))
.andExpect(status().isBadRequest());
List<UserRoleAssignment> userRoleAssignmentList = userRoleAssignmentRepository.findAll();
assertThat(userRoleAssignmentList).hasSize(databaseSizeBeforeTest);
}
@Test @Test
@Transactional @Transactional
public void checkAssignedRoleIsRequired() throws Exception { public void checkAssignedRoleIsRequired() throws Exception {
@ -212,7 +188,6 @@ public class UserRoleAssignmentResourceIntTest {
.andExpect(jsonPath("$.[*].id").value(hasItem(userRoleAssignment.getId().intValue()))) .andExpect(jsonPath("$.[*].id").value(hasItem(userRoleAssignment.getId().intValue())))
.andExpect(jsonPath("$.[*].entityTypeId").value(hasItem(DEFAULT_ENTITY_TYPE_ID.toString()))) .andExpect(jsonPath("$.[*].entityTypeId").value(hasItem(DEFAULT_ENTITY_TYPE_ID.toString())))
.andExpect(jsonPath("$.[*].entityObjectId").value(hasItem(DEFAULT_ENTITY_OBJECT_ID.intValue()))) .andExpect(jsonPath("$.[*].entityObjectId").value(hasItem(DEFAULT_ENTITY_OBJECT_ID.intValue())))
.andExpect(jsonPath("$.[*].userId").value(hasItem(DEFAULT_USER_ID.intValue())))
.andExpect(jsonPath("$.[*].assignedRole").value(hasItem(DEFAULT_ASSIGNED_ROLE.toString()))); .andExpect(jsonPath("$.[*].assignedRole").value(hasItem(DEFAULT_ASSIGNED_ROLE.toString())));
} }
@ -229,7 +204,6 @@ public class UserRoleAssignmentResourceIntTest {
.andExpect(jsonPath("$.id").value(userRoleAssignment.getId().intValue())) .andExpect(jsonPath("$.id").value(userRoleAssignment.getId().intValue()))
.andExpect(jsonPath("$.entityTypeId").value(DEFAULT_ENTITY_TYPE_ID.toString())) .andExpect(jsonPath("$.entityTypeId").value(DEFAULT_ENTITY_TYPE_ID.toString()))
.andExpect(jsonPath("$.entityObjectId").value(DEFAULT_ENTITY_OBJECT_ID.intValue())) .andExpect(jsonPath("$.entityObjectId").value(DEFAULT_ENTITY_OBJECT_ID.intValue()))
.andExpect(jsonPath("$.userId").value(DEFAULT_USER_ID.intValue()))
.andExpect(jsonPath("$.assignedRole").value(DEFAULT_ASSIGNED_ROLE.toString())); .andExpect(jsonPath("$.assignedRole").value(DEFAULT_ASSIGNED_ROLE.toString()));
} }
@ -338,71 +312,6 @@ public class UserRoleAssignmentResourceIntTest {
defaultUserRoleAssignmentShouldBeFound("entityObjectId.lessThan=" + UPDATED_ENTITY_OBJECT_ID); defaultUserRoleAssignmentShouldBeFound("entityObjectId.lessThan=" + UPDATED_ENTITY_OBJECT_ID);
} }
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsEqualToSomething() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId equals to DEFAULT_USER_ID
defaultUserRoleAssignmentShouldBeFound("userId.equals=" + DEFAULT_USER_ID);
// Get all the userRoleAssignmentList where userId equals to UPDATED_USER_ID
defaultUserRoleAssignmentShouldNotBeFound("userId.equals=" + UPDATED_USER_ID);
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsInShouldWork() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId in DEFAULT_USER_ID or UPDATED_USER_ID
defaultUserRoleAssignmentShouldBeFound("userId.in=" + DEFAULT_USER_ID + "," + UPDATED_USER_ID);
// Get all the userRoleAssignmentList where userId equals to UPDATED_USER_ID
defaultUserRoleAssignmentShouldNotBeFound("userId.in=" + UPDATED_USER_ID);
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsNullOrNotNull() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId is not null
defaultUserRoleAssignmentShouldBeFound("userId.specified=true");
// Get all the userRoleAssignmentList where userId is null
defaultUserRoleAssignmentShouldNotBeFound("userId.specified=false");
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId greater than or equals to DEFAULT_USER_ID
defaultUserRoleAssignmentShouldBeFound("userId.greaterOrEqualThan=" + DEFAULT_USER_ID);
// Get all the userRoleAssignmentList where userId greater than or equals to UPDATED_USER_ID
defaultUserRoleAssignmentShouldNotBeFound("userId.greaterOrEqualThan=" + UPDATED_USER_ID);
}
@Test
@Transactional
public void getAllUserRoleAssignmentsByUserIdIsLessThanSomething() throws Exception {
// Initialize the database
userRoleAssignmentRepository.saveAndFlush(userRoleAssignment);
// Get all the userRoleAssignmentList where userId less than or equals to DEFAULT_USER_ID
defaultUserRoleAssignmentShouldNotBeFound("userId.lessThan=" + DEFAULT_USER_ID);
// Get all the userRoleAssignmentList where userId less than or equals to UPDATED_USER_ID
defaultUserRoleAssignmentShouldBeFound("userId.lessThan=" + UPDATED_USER_ID);
}
@Test @Test
@Transactional @Transactional
public void getAllUserRoleAssignmentsByAssignedRoleIsEqualToSomething() throws Exception { public void getAllUserRoleAssignmentsByAssignedRoleIsEqualToSomething() throws Exception {
@ -470,7 +379,6 @@ public class UserRoleAssignmentResourceIntTest {
.andExpect(jsonPath("$.[*].id").value(hasItem(userRoleAssignment.getId().intValue()))) .andExpect(jsonPath("$.[*].id").value(hasItem(userRoleAssignment.getId().intValue())))
.andExpect(jsonPath("$.[*].entityTypeId").value(hasItem(DEFAULT_ENTITY_TYPE_ID))) .andExpect(jsonPath("$.[*].entityTypeId").value(hasItem(DEFAULT_ENTITY_TYPE_ID)))
.andExpect(jsonPath("$.[*].entityObjectId").value(hasItem(DEFAULT_ENTITY_OBJECT_ID.intValue()))) .andExpect(jsonPath("$.[*].entityObjectId").value(hasItem(DEFAULT_ENTITY_OBJECT_ID.intValue())))
.andExpect(jsonPath("$.[*].userId").value(hasItem(DEFAULT_USER_ID.intValue())))
.andExpect(jsonPath("$.[*].assignedRole").value(hasItem(DEFAULT_ASSIGNED_ROLE.toString()))); .andExpect(jsonPath("$.[*].assignedRole").value(hasItem(DEFAULT_ASSIGNED_ROLE.toString())));
// Check, that the count call also returns 1 // Check, that the count call also returns 1
@ -520,7 +428,6 @@ public class UserRoleAssignmentResourceIntTest {
updatedUserRoleAssignment updatedUserRoleAssignment
.entityTypeId(UPDATED_ENTITY_TYPE_ID) .entityTypeId(UPDATED_ENTITY_TYPE_ID)
.entityObjectId(UPDATED_ENTITY_OBJECT_ID) .entityObjectId(UPDATED_ENTITY_OBJECT_ID)
.userId(UPDATED_USER_ID)
.assignedRole(UPDATED_ASSIGNED_ROLE); .assignedRole(UPDATED_ASSIGNED_ROLE);
restUserRoleAssignmentMockMvc.perform( restUserRoleAssignmentMockMvc.perform(
@ -535,7 +442,6 @@ public class UserRoleAssignmentResourceIntTest {
UserRoleAssignment testUserRoleAssignment = userRoleAssignmentList.get(userRoleAssignmentList.size() - 1); UserRoleAssignment testUserRoleAssignment = userRoleAssignmentList.get(userRoleAssignmentList.size() - 1);
assertThat(testUserRoleAssignment.getEntityTypeId()).isEqualTo(UPDATED_ENTITY_TYPE_ID); assertThat(testUserRoleAssignment.getEntityTypeId()).isEqualTo(UPDATED_ENTITY_TYPE_ID);
assertThat(testUserRoleAssignment.getEntityObjectId()).isEqualTo(UPDATED_ENTITY_OBJECT_ID); assertThat(testUserRoleAssignment.getEntityObjectId()).isEqualTo(UPDATED_ENTITY_OBJECT_ID);
assertThat(testUserRoleAssignment.getUserId()).isEqualTo(UPDATED_USER_ID);
assertThat(testUserRoleAssignment.getAssignedRole()).isEqualTo(UPDATED_ASSIGNED_ROLE); assertThat(testUserRoleAssignment.getAssignedRole()).isEqualTo(UPDATED_ASSIGNED_ROLE);
} }

View File

@ -21,7 +21,7 @@ describe('Service Tests', () => {
service = injector.get(UserRoleAssignmentService); service = injector.get(UserRoleAssignmentService);
httpMock = injector.get(HttpTestingController); httpMock = injector.get(HttpTestingController);
elemDefault = new UserRoleAssignment(0, 'AAAAAAA', 0, 0, UserRole.HOSTMASTER); elemDefault = new UserRoleAssignment(0, 'AAAAAAA', 0, UserRole.HOSTMASTER);
}); });
describe('Service methods', async () => { describe('Service methods', async () => {
@ -57,7 +57,6 @@ describe('Service Tests', () => {
{ {
entityTypeId: 'BBBBBB', entityTypeId: 'BBBBBB',
entityObjectId: 1, entityObjectId: 1,
userId: 1,
assignedRole: 'BBBBBB' assignedRole: 'BBBBBB'
}, },
elemDefault elemDefault
@ -77,7 +76,6 @@ describe('Service Tests', () => {
{ {
entityTypeId: 'BBBBBB', entityTypeId: 'BBBBBB',
entityObjectId: 1, entityObjectId: 1,
userId: 1,
assignedRole: 'BBBBBB' assignedRole: 'BBBBBB'
}, },
elemDefault elemDefault