-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MODORDERS-1185. mod-orders 12.8.10 bug fix release
- Loading branch information
1 parent
f7ab95f
commit 381c546
Showing
3 changed files
with
46 additions
and
34 deletions.
There are no files selected for viewing
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
54 changes: 21 additions & 33 deletions
54
src/test/java/org/folio/helper/PurchaseOrderLineHelperTest.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 |
---|---|---|
@@ -1,44 +1,32 @@ | ||
package org.folio.helper; | ||
|
||
import static org.folio.TestConfig.clearServiceInteractions; | ||
import static org.folio.TestConfig.initSpringContext; | ||
import static org.folio.TestConfig.isVerticleNotDeployed; | ||
import static org.folio.rest.impl.MockServer.BASE_MOCK_DATA_PATH; | ||
import org.folio.rest.jaxrs.model.Cost; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeoutException; | ||
import java.util.stream.Stream; | ||
|
||
import org.folio.ApiTestSuite; | ||
import org.folio.config.ApplicationConfig; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class PurchaseOrderLineHelperTest { | ||
private static final String ORDER_ID = "1ab7ef6a-d1d4-4a4f-90a2-882aed18af14"; | ||
private static final String ORDER_PATH = BASE_MOCK_DATA_PATH + "compositeOrders/" + ORDER_ID + ".json"; | ||
|
||
private static boolean runningOnOwn; | ||
|
||
@BeforeAll | ||
static void before() throws InterruptedException, ExecutionException, TimeoutException { | ||
if (isVerticleNotDeployed()) { | ||
ApiTestSuite.before(); | ||
runningOnOwn = true; | ||
} | ||
initSpringContext(ApplicationConfig.class); | ||
} | ||
|
||
@AfterEach | ||
void afterEach() { | ||
clearServiceInteractions(); | ||
private static Stream<Arguments> testHasAlteredExchangeRateArgs() { | ||
return Stream.of( | ||
Arguments.of(false, 0.7d, 0.7d), | ||
Arguments.of(false, null, null), | ||
Arguments.of(true, 0.7d, 0.8d), | ||
Arguments.of(true, null, 0.8d), | ||
Arguments.of(true, 0.7d, null) | ||
); | ||
} | ||
|
||
@AfterAll | ||
static void after() { | ||
if (runningOnOwn) { | ||
ApiTestSuite.after(); | ||
} | ||
@ParameterizedTest | ||
@MethodSource("testHasAlteredExchangeRateArgs") | ||
void testHasAlteredExchangeRate(boolean expected, Double oldExchangeRate, Double newExchangeRate) { | ||
var currencyCode = "AUD"; | ||
var oldCost = new Cost().withCurrency(currencyCode).withExchangeRate(newExchangeRate); | ||
var newCost = new Cost().withCurrency(currencyCode).withExchangeRate(oldExchangeRate); | ||
assertEquals(expected, PurchaseOrderLineHelper.hasAlteredExchangeRate(oldCost, newCost)); | ||
} | ||
|
||
} |