This commit is contained in:
2024-11-18 12:49:25 +01:00
parent 14b5142394
commit 576c5155d9
6 changed files with 59 additions and 2 deletions
@@ -46,6 +46,10 @@ public class Registration implements Serializable {
@JsonIgnoreProperties(value = { "registrations", "transactions" }, allowSetters = true)
private Event event;
@ManyToOne(fetch = FetchType.EAGER)
@JsonIgnoreProperties(value = { "users", "transactionItems" }, allowSetters = true)
private UserAccount userAccount;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "registration")
@JsonIgnoreProperties(value = { "userAccount", "transaction", "event", "registration" }, allowSetters = true)
private Set<TransactionItem> transactionItems = new HashSet<>();
@@ -143,6 +147,19 @@ public class Registration implements Serializable {
return this;
}
public UserAccount getUserAccount() {
return this.userAccount;
}
public void setUserAccount(UserAccount userAccount) {
this.userAccount = userAccount;
}
public Registration userAccount(UserAccount userAccount) {
this.setUserAccount(userAccount);
return this;
}
public Set<TransactionItem> getTransactionItems() {
return this.transactionItems;
}
@@ -0,0 +1,18 @@
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
<changeSet author="Zet (generated)" id="1731926141078-7">
<addColumn tableName="registration">
<column name="user_account_id" type="bigint">
<constraints nullable="true" />
</column>
</addColumn>
</changeSet>
<changeSet author="Zet (generated)" id="1731926141078-8">
<addForeignKeyConstraint baseColumnNames="user_account_id"
baseTableName="registration"
constraintName="fk_registration__user_account_id"
referencedColumnNames="id"
referencedTableName="user_account"
/>
</changeSet>
</databaseChangeLog>
@@ -24,5 +24,6 @@
<include file="config/liquibase/changelog/20241113135042_added_entity_constraints_UserAccount.xml" relativeToChangelogFile="false"/>
<include file="config/liquibase/changelog/20241113151058_added_entity_constraints_TransactionItem.xml" relativeToChangelogFile="false"/>
<!-- jhipster-needle-liquibase-add-constraints-changelog - JHipster will add liquibase constraints changelogs here -->
<!-- jhipster-needle-liquibase-add-incremental-changelog - JHipster will add incremental liquibase changelogs here -->
<!-- jhipster-needle-liquibase-add-incremental-changelog - JHipster will add incremental liquibase changelogs here -->
<include file="config/liquibase/changelog/20241118103414_changelog.xml" relativeToChangelogFile="false"/>
</databaseChangeLog>
@@ -65,6 +65,7 @@ public class RegistrationAsserts {
public static void assertRegistrationUpdatableRelationshipsEquals(Registration expected, Registration actual) {
assertThat(expected)
.as("Verify Registration relationships")
.satisfies(e -> assertThat(e.getEvent()).as("check event").isEqualTo(actual.getEvent()));
.satisfies(e -> assertThat(e.getEvent()).as("check event").isEqualTo(actual.getEvent()))
.satisfies(e -> assertThat(e.getUserAccount()).as("check userAccount").isEqualTo(actual.getUserAccount()));
}
}
@@ -3,6 +3,7 @@ package com.sasiedzi.event.domain;
import static com.sasiedzi.event.domain.EventTestSamples.*;
import static com.sasiedzi.event.domain.RegistrationTestSamples.*;
import static com.sasiedzi.event.domain.TransactionItemTestSamples.*;
import static com.sasiedzi.event.domain.UserAccountTestSamples.*;
import static org.assertj.core.api.Assertions.assertThat;
import com.sasiedzi.event.web.rest.TestUtil;
@@ -38,6 +39,18 @@ class RegistrationTest {
assertThat(registration.getEvent()).isNull();
}
@Test
void userAccountTest() {
Registration registration = getRegistrationRandomSampleGenerator();
UserAccount userAccountBack = getUserAccountRandomSampleGenerator();
registration.setUserAccount(userAccountBack);
assertThat(registration.getUserAccount()).isEqualTo(userAccountBack);
registration.userAccount(null);
assertThat(registration.getUserAccount()).isNull();
}
@Test
void transactionItemTest() {
Registration registration = getRegistrationRandomSampleGenerator();