diff --git a/ramls/fund_update_log.raml b/ramls/fund_update_log.raml index 9072c127..8f091177 100644 --- a/ramls/fund_update_log.raml +++ b/ramls/fund_update_log.raml @@ -11,6 +11,8 @@ types: errors: !include raml-util/schemas/errors.schema fund-update-log: !include acq-models/mod-finance/schemas/fund_update_log.json fund-update-log-collection: !include acq-models/mod-finance/schemas/fund_update_log_collection.json + example-fund-update-log: !include acq-models/mod-finance/examples/fund_update_log.sample + example-fund-update-log-collection: !include acq-models/mod-finance/examples/fund_update_log_collection.sample UUID: type: string pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$ @@ -25,11 +27,11 @@ resourceTypes: collection-item: !include raml-util/rtypes/item-collection.raml -/finance-storage/fund-update_log: +/finance-storage/fund-update-logs: type: collection: - exampleCollection: !include acq-models/mod-finance/examples/fund_update_log_collection.sample - exampleItem: !include acq-models/mod-finance/examples/fund_update_log.sample + exampleCollection: example-fund-update-log-collection + exampleItem: example-fund-update-log schemaCollection: fund-update-log-collection schemaItem: fund-update-log is: [validate] @@ -46,6 +48,6 @@ resourceTypes: type: UUID type: collection-item: - exampleItem: !include acq-models/mod-finance/examples/fund_update_log.sample + exampleItem: example-fund-update-log schema: fund-update-log is: [validate] diff --git a/src/main/java/org/folio/rest/impl/FundUpdateLogAPI.java b/src/main/java/org/folio/rest/impl/FundUpdateLogAPI.java index b3d05f78..37348752 100644 --- a/src/main/java/org/folio/rest/impl/FundUpdateLogAPI.java +++ b/src/main/java/org/folio/rest/impl/FundUpdateLogAPI.java @@ -9,43 +9,51 @@ import org.folio.rest.annotations.Validate; import org.folio.rest.jaxrs.model.FundUpdateLog; import org.folio.rest.jaxrs.model.FundUpdateLogCollection; -import org.folio.rest.jaxrs.resource.FinanceStorageFundUpdateLog; +import org.folio.rest.jaxrs.resource.FinanceStorageFundUpdateLogs; import org.folio.rest.persist.PgUtil; -public class FundUpdateLogAPI implements FinanceStorageFundUpdateLog { +public class FundUpdateLogAPI implements FinanceStorageFundUpdateLogs { public static final String FUND_UPDATE_LOG_TABLE = "fund_update_log"; @Override @Validate - public void getFinanceStorageFundUpdateLog(String query, String totalRecords, int offset, int limit, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { + public void getFinanceStorageFundUpdateLogs(String query, String totalRecords, int offset, int limit, + Map okapiHeaders, Handler> asyncResultHandler, + Context vertxContext) { PgUtil.get(FUND_UPDATE_LOG_TABLE, FundUpdateLog.class, FundUpdateLogCollection.class, query, offset, limit, - okapiHeaders, vertxContext, GetFinanceStorageFundUpdateLogResponse.class, asyncResultHandler); + okapiHeaders, vertxContext, GetFinanceStorageFundUpdateLogsResponse.class, asyncResultHandler); } @Override @Validate - public void postFinanceStorageFundUpdateLog(FundUpdateLog entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - PgUtil.post(FUND_UPDATE_LOG_TABLE, entity, okapiHeaders, vertxContext, PostFinanceStorageFundUpdateLogResponse.class, asyncResultHandler); + public void postFinanceStorageFundUpdateLogs(FundUpdateLog entity, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + PgUtil.post(FUND_UPDATE_LOG_TABLE, entity, okapiHeaders, vertxContext, + PostFinanceStorageFundUpdateLogsResponse.class, asyncResultHandler); } @Override @Validate - public void getFinanceStorageFundUpdateLogById(String id, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { + public void getFinanceStorageFundUpdateLogsById(String id, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { PgUtil.getById(FUND_UPDATE_LOG_TABLE, FundUpdateLog.class, String.valueOf(id), okapiHeaders, vertxContext, - GetFinanceStorageFundUpdateLogByIdResponse.class, asyncResultHandler); + GetFinanceStorageFundUpdateLogsByIdResponse.class, asyncResultHandler); } @Override @Validate - public void deleteFinanceStorageFundUpdateLogById(String id, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - PgUtil.deleteById(FUND_UPDATE_LOG_TABLE, String.valueOf(id), okapiHeaders, vertxContext, DeleteFinanceStorageFundUpdateLogByIdResponse.class, - asyncResultHandler); + public void deleteFinanceStorageFundUpdateLogsById(String id, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + PgUtil.deleteById(FUND_UPDATE_LOG_TABLE, String.valueOf(id), okapiHeaders, vertxContext, + DeleteFinanceStorageFundUpdateLogsByIdResponse.class, asyncResultHandler); } @Override @Validate - public void putFinanceStorageFundUpdateLogById(String id, FundUpdateLog entity, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - PgUtil.put(FUND_UPDATE_LOG_TABLE, entity, String.valueOf(id), okapiHeaders, vertxContext, PutFinanceStorageFundUpdateLogByIdResponse.class, asyncResultHandler); + public void putFinanceStorageFundUpdateLogsById(String id, FundUpdateLog entity, Map okapiHeaders, + Handler> asyncResultHandler, Context vertxContext) { + PgUtil.put(FUND_UPDATE_LOG_TABLE, entity, String.valueOf(id), okapiHeaders, vertxContext, + PutFinanceStorageFundUpdateLogsByIdResponse.class, asyncResultHandler); } } diff --git a/src/main/resources/data/fund-update-log-8.7.0/monthly-fund-update.json b/src/main/resources/data/fund-update-log-8.7.0/monthly-fund-update.json deleted file mode 100644 index a8799d3b..00000000 --- a/src/main/resources/data/fund-update-log-8.7.0/monthly-fund-update.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "123e4567-e89b-12d3-a456-426614174000", - "jobNumber": 1, - "jobName": "Monthly Fund Update", - "jobDetails": { - "description": "Updating fund details for the month", - "startTime": "2023-10-01T00:00:00Z", - "endTime": "2023-10-01T01:00:00Z" - }, - "status": "COMPLETED", - "recordsCount": 100 -} diff --git a/src/test/java/org/folio/StorageTestSuite.java b/src/test/java/org/folio/StorageTestSuite.java index ce230c3a..82cdd2c6 100644 --- a/src/test/java/org/folio/StorageTestSuite.java +++ b/src/test/java/org/folio/StorageTestSuite.java @@ -22,7 +22,6 @@ import org.folio.rest.core.RestClientTest; import org.folio.rest.impl.BudgetTest; import org.folio.rest.impl.EntitiesCrudTest; -import org.folio.rest.impl.FundUpdateLogTest; import org.folio.rest.impl.GroupBudgetTest; import org.folio.rest.impl.GroupFundFYTest; import org.folio.rest.impl.GroupTest; @@ -31,7 +30,6 @@ import org.folio.rest.impl.LedgerRolloverBudgetTest; import org.folio.rest.impl.TenantSampleDataTest; import org.folio.rest.impl.TransactionTest; -import org.folio.rest.jaxrs.model.FundUpdateLog; import org.folio.rest.jaxrs.model.TenantJob; import org.folio.rest.persist.PostgresClient; import org.folio.rest.tools.utils.NetworkUtils; @@ -218,7 +216,4 @@ class PaymentCreditTestNested extends PaymentCreditTest {} @Nested class PendingPaymentTestNested extends PendingPaymentTest {} - - @Nested - class FundUpdateLogTestNested extends FundUpdateLogTest {} } diff --git a/src/test/java/org/folio/rest/impl/EntitiesCrudTest.java b/src/test/java/org/folio/rest/impl/EntitiesCrudTest.java index 0719c0b4..9dc3cedd 100644 --- a/src/test/java/org/folio/rest/impl/EntitiesCrudTest.java +++ b/src/test/java/org/folio/rest/impl/EntitiesCrudTest.java @@ -7,7 +7,6 @@ import static org.folio.rest.utils.TestEntities.FISCAL_YEAR; import static org.folio.rest.utils.TestEntities.FUND; import static org.folio.rest.utils.TestEntities.FUND_TYPE; -import static org.folio.rest.utils.TestEntities.FUND_UPDATE_LOG; import static org.folio.rest.utils.TestEntities.GROUP; import static org.folio.rest.utils.TestEntities.GROUP_FUND_FY; import static org.folio.rest.utils.TestEntities.LEDGER; @@ -52,7 +51,7 @@ public class EntitiesCrudTest extends TestBase { */ static Stream deleteOrder() { return Stream.of(GROUP_FUND_FY, BUDGET_EXPENSE_CLASS, BUDGET, LEDGER_FISCAL_YEAR_ROLLOVER_ERROR, - LEDGER_FISCAL_YEAR_ROLLOVER, FUND, FUND_TYPE, FUND_UPDATE_LOG, LEDGER, FISCAL_YEAR, GROUP, EXPENSE_CLASS); + LEDGER_FISCAL_YEAR_ROLLOVER, FUND, FUND_TYPE, LEDGER, FISCAL_YEAR, GROUP, EXPENSE_CLASS); } static Stream deleteFailOrder() { diff --git a/src/test/java/org/folio/rest/impl/FundUpdateLogTest.java b/src/test/java/org/folio/rest/impl/FundUpdateLogTest.java deleted file mode 100644 index 16fd5f94..00000000 --- a/src/test/java/org/folio/rest/impl/FundUpdateLogTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.folio.rest.impl; - -import io.vertx.junit5.VertxExtension; -import io.vertx.junit5.VertxTestContext; -import org.folio.StorageTestSuite; -import org.folio.rest.jaxrs.model.FundUpdateLog; -import org.folio.rest.jaxrs.resource.FinanceStorageFundUpdateLog; -import org.folio.rest.persist.HelperUtils; -import org.folio.rest.persist.PostgresClient; -import org.folio.utils.CopilotGenerated; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; - -import static org.folio.rest.impl.FundUpdateLogAPI.FUND_UPDATE_LOG_TABLE; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; - -import java.util.UUID; - -@ExtendWith(VertxExtension.class) -@CopilotGenerated(partiallyGenerated = true) -public class FundUpdateLogTest extends TestBase { - - private static final String ID = UUID.randomUUID().toString(); - private static final String ENTITY_NAME = "FUND_UPDATE_LOG"; - private static final String FUND_UPDATE_LOG_ENDPOINT = HelperUtils.getEndpoint(FinanceStorageFundUpdateLog.class); - - @BeforeEach - void saveFundUpdateLogData(VertxTestContext context) { - PostgresClient.getInstance(StorageTestSuite.getVertx(), TENANT_NAME) - .saveAndReturnUpdatedEntity(FUND_UPDATE_LOG_TABLE, ID, new FundUpdateLog()) - .onComplete(context.succeedingThenComplete()); - } - - @AfterEach - void deleteFundUpdateLogData(VertxTestContext context) { - PostgresClient.getInstance(StorageTestSuite.getVertx(), TENANT_NAME) - .delete(FUND_UPDATE_LOG_TABLE, ID) - .onComplete(context.succeedingThenComplete()); - } - - @Test - void getCollection() { - logger.info(String.format("--- mod-finance-storage %s test: Verifying only 1 log was created ... ", ENTITY_NAME)); - verifyCollectionQuantity(FUND_UPDATE_LOG_ENDPOINT, 1); - } - - @Test - void getById() { - logger.info(String.format("--- mod-finance-storage %1$s test: Fetching %1$s with ID %2$s", ENTITY_NAME, ID)); - testEntitySuccessfullyFetched(FUND_UPDATE_LOG_ENDPOINT + "/{id}", String.valueOf(ID)); - } - - @Test - void createFundUpdateLog(VertxTestContext context) { - var jobId = UUID.randomUUID().toString(); - var jobNumber = 1; - var jobName = "Update Fund"; - - FundUpdateLog newLog = new FundUpdateLog().withId(jobId).withJobNumber(jobNumber).withJobName(jobName); - PostgresClient.getInstance(StorageTestSuite.getVertx(), TENANT_NAME) - .saveAndReturnUpdatedEntity(FUND_UPDATE_LOG_TABLE, String.valueOf(newLog.getId()), newLog) - .onComplete(context.succeeding(result -> { - assertNotNull(result); - context.completeNow(); - })); - } - - @Test - void updateFundUpdateLog(VertxTestContext context) { - FundUpdateLog updatedLog = new FundUpdateLog().withId(ID).withJobName("Updated JobName"); - PostgresClient.getInstance(StorageTestSuite.getVertx(), TENANT_NAME) - .update(FUND_UPDATE_LOG_TABLE, updatedLog, ID) - .onComplete(context.succeeding(result -> { - assertEquals(1, result.rowCount()); - context.completeNow(); - })); - } - - @Test - void deleteFundUpdateLog(VertxTestContext context) { - PostgresClient.getInstance(StorageTestSuite.getVertx(), TENANT_NAME) - .delete(FUND_UPDATE_LOG_TABLE, ID) - .onComplete(context.succeeding(result -> { - assertEquals(1, result.rowCount()); - context.completeNow(); - })); - } -} diff --git a/src/test/java/org/folio/rest/utils/TestEntities.java b/src/test/java/org/folio/rest/utils/TestEntities.java index 092c8877..ec6a055d 100644 --- a/src/test/java/org/folio/rest/utils/TestEntities.java +++ b/src/test/java/org/folio/rest/utils/TestEntities.java @@ -18,8 +18,8 @@ public enum TestEntities { LEDGER_FISCAL_YEAR_ROLLOVER(HelperUtils.getEndpoint(FinanceStorageLedgerRollovers.class), LedgerFiscalYearRollover.class, "data/ledger-fiscal-year-rollovers/", "main-library.json", "restrictEncumbrance", "true", 0, true), LEDGER_FISCAL_YEAR_ROLLOVER_LOG(HelperUtils.getEndpoint(FinanceStorageLedgerRolloversLogs.class), LedgerFiscalYearRolloverLog.class, null, null, null, null, 0, false), LEDGER_FISCAL_YEAR_ROLLOVER_PROGRESS(HelperUtils.getEndpoint(FinanceStorageLedgerRolloversProgress.class), LedgerFiscalYearRolloverProgress.class, "data/ledger-fiscal-year-rollovers/", "main-library-progress.json", "financialRolloverStatus", "Success", 0, false), - LEDGER_FISCAL_YEAR_ROLLOVER_ERROR(HelperUtils.getEndpoint(FinanceStorageLedgerRolloversErrors.class), LedgerFiscalYearRolloverError.class, "data/ledger-fiscal-year-rollovers/", "main-library-errors.json", "errorType", "Fund", 0, false), - FUND_UPDATE_LOG(HelperUtils.getEndpoint(FinanceStorageFundUpdateLog.class), FundUpdateLog.class, "data/fund-update-log/", "monthly-fund-update.json", "jobName", "Weekly Fund Update", 0, true); + LEDGER_FISCAL_YEAR_ROLLOVER_ERROR(HelperUtils.getEndpoint(FinanceStorageLedgerRolloversErrors.class), LedgerFiscalYearRolloverError.class, "data/ledger-fiscal-year-rollovers/", "main-library-errors.json", "errorType", "Fund", 0, false); + TestEntities(String endpoint, Class clazz, String pathToSamples, String sampleFileName, String updatedFieldName, String updatedFieldValue, int initialQuantity, boolean isOptLockingEnabled) { diff --git a/src/test/java/org/folio/utils/CopilotGenerated.java b/src/test/java/org/folio/utils/CopilotGenerated.java deleted file mode 100644 index 2ba9c581..00000000 --- a/src/test/java/org/folio/utils/CopilotGenerated.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.folio.utils; - -import org.springframework.core.annotation.AliasFor; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation to indicate that test(s) in the class are generated by GitHub Copilot. - *

- * Set value or partiallyGenerated attribute to true - * if the generated test(s) were significantly modified/altered by the developer. - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.SOURCE) -public @interface CopilotGenerated { - - @AliasFor("partiallyGenerated") - boolean value() default false; - - @AliasFor("value") - boolean partiallyGenerated() default false; -}