mirror of
https://github.com/google/nomulus.git
synced 2025-04-29 19:47:51 +02:00
Fix id generation in PackagePromotion (#1788)
* Fix id generation in PackagePromotion * Fix update command tests
This commit is contained in:
parent
2139dd3a4a
commit
7f0ffb3d0b
4 changed files with 20 additions and 13 deletions
|
@ -29,6 +29,8 @@ import java.util.Optional;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import org.hibernate.annotations.Columns;
|
import org.hibernate.annotations.Columns;
|
||||||
import org.hibernate.annotations.Type;
|
import org.hibernate.annotations.Type;
|
||||||
|
@ -41,7 +43,9 @@ import org.joda.time.DateTime;
|
||||||
public class PackagePromotion extends ImmutableObject implements Buildable {
|
public class PackagePromotion extends ImmutableObject implements Buildable {
|
||||||
|
|
||||||
/** An autogenerated identifier for the package promotion. */
|
/** An autogenerated identifier for the package promotion. */
|
||||||
@Id long packagePromotionId;
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
long packagePromotionId;
|
||||||
|
|
||||||
/** The allocation token string for the package. */
|
/** The allocation token string for the package. */
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
|
|
|
@ -15,8 +15,9 @@
|
||||||
package google.registry.model.domain.token;
|
package google.registry.model.domain.token;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static google.registry.model.ImmutableObjectSubject.assertAboutImmutableObjects;
|
||||||
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static google.registry.testing.DatabaseHelper.createTld;
|
import static google.registry.testing.DatabaseHelper.createTld;
|
||||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
|
||||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
|
||||||
|
@ -57,16 +58,18 @@ public class PackagePromotionTest extends EntityTestCase {
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
PackagePromotion packagePromotion =
|
PackagePromotion packagePromotion =
|
||||||
persistResource(
|
new PackagePromotion.Builder()
|
||||||
new PackagePromotion.Builder()
|
.setToken(token)
|
||||||
.setToken(token)
|
.setPackagePrice(Money.of(CurrencyUnit.USD, 10000))
|
||||||
.setPackagePrice(Money.of(CurrencyUnit.USD, 10000))
|
.setMaxCreates(40)
|
||||||
.setMaxCreates(40)
|
.setMaxDomains(10)
|
||||||
.setMaxDomains(10)
|
.setNextBillingDate(DateTime.parse("2011-11-12T05:00:00Z"))
|
||||||
.setNextBillingDate(DateTime.parse("2011-11-12T05:00:00Z"))
|
.build();
|
||||||
.build());
|
|
||||||
|
|
||||||
assertThat(loadByEntity(packagePromotion)).isEqualTo(packagePromotion);
|
jpaTm().transact(() -> jpaTm().put(packagePromotion));
|
||||||
|
assertAboutImmutableObjects()
|
||||||
|
.that(jpaTm().transact(() -> PackagePromotion.loadByTokenString("abc123")).get())
|
||||||
|
.isEqualExceptFields(packagePromotion, "packagePromotionId");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class UpdatePackagePromotionCommandTest
|
||||||
.setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z"))
|
.setNextBillingDate(DateTime.parse("2012-11-12T05:00:00Z"))
|
||||||
.setLastNotificationSent(DateTime.parse("2010-11-12T05:00:00Z"))
|
.setLastNotificationSent(DateTime.parse("2010-11-12T05:00:00Z"))
|
||||||
.build();
|
.build();
|
||||||
persistResource(packagePromotion);
|
jpaTm().transact(() -> jpaTm().put(packagePromotion));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -492,7 +492,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
create table "PackagePromotion" (
|
create table "PackagePromotion" (
|
||||||
package_promotion_id int8 not null,
|
package_promotion_id bigserial not null,
|
||||||
last_notification_sent timestamptz,
|
last_notification_sent timestamptz,
|
||||||
max_creates int4 not null,
|
max_creates int4 not null,
|
||||||
max_domains int4 not null,
|
max_domains int4 not null,
|
||||||
|
|
Loading…
Add table
Reference in a new issue