-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created test for OffsetDateTime instead of using Instant
- Loading branch information
Showing
3 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
...tions/jakartadata/src/io/openliberty/jpa/data/tests/models/DemographicInfoWithOffset.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package io.openliberty.jpa.data.tests.models; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.time.OffsetDateTime; | ||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
|
||
/** | ||
* Recreate from io.openliberty.data.internal_fat_jpa | ||
* Same as DemographicInfo but uses OffsetDateTime instead of Instance | ||
*/ | ||
@Entity | ||
public class DemographicInfoWithOffset { | ||
|
||
@Column | ||
public OffsetDateTime collectedOn; | ||
|
||
@GeneratedValue | ||
@Id | ||
public BigInteger id; | ||
|
||
@Column | ||
public BigDecimal publicDebt; | ||
|
||
@Column | ||
public BigDecimal intragovernmentalDebt; | ||
|
||
@Column | ||
public BigInteger numFullTimeWorkers; | ||
|
||
public static DemographicInfoWithOffset of(int year, int month, int day, | ||
long numFullTimeWorkers, | ||
double intragovernmentalDebt, double publicDebt) { | ||
DemographicInfoWithOffset inst = new DemographicInfoWithOffset(); | ||
inst.collectedOn = ZonedDateTime.of(year, month, day, 12, 0, 0, 0, ZoneId.of("America/New_York")).toOffsetDateTime(); | ||
inst.numFullTimeWorkers = BigInteger.valueOf(numFullTimeWorkers); | ||
inst.intragovernmentalDebt = BigDecimal.valueOf(intragovernmentalDebt); | ||
inst.publicDebt = BigDecimal.valueOf(publicDebt); | ||
return inst; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "DemographicInfo from " + collectedOn; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters