|
| 1 | +package org.folio.fqm.migration.strategies.impl; |
| 2 | + |
| 3 | +import java.util.List; |
| 4 | +import java.util.UUID; |
| 5 | +import org.folio.fqm.migration.MigratableQueryInformation; |
| 6 | +import org.folio.fqm.migration.strategies.MigrationStrategy; |
| 7 | +import org.folio.fqm.migration.warnings.RemovedFieldWarning; |
| 8 | +import org.junit.jupiter.params.provider.Arguments; |
| 9 | + |
| 10 | +public class V24InvoiceSimpleToCompositeMigrationTest extends TestTemplate { |
| 11 | + |
| 12 | + private static final UUID SIMPLE_INVOICE_ID = UUID.fromString("4d626ce1-1880-48d2-9d4c-81667fdc5dbb"); |
| 13 | + private static final UUID COMPOSITE_INVOICE_ID = UUID.fromString("5c4cb0c9-c8bf-4fe5-b844-4de90ca445dc"); |
| 14 | + private static final UUID COMPOSITE_INVOICE_LINE_ID = UUID.fromString("a2ea9d7a-3ed3-41c7-9cdd-f433e029ea0f"); |
| 15 | + private static final UUID COMPOSITE_ORDER_INVOICE_ANALYTICS_ID = UUID.fromString("f3ccbf49-8e3e-4f5c-a60e-04ad80543a4a"); |
| 16 | + private static final UUID COMPOSITE_INVOICE_VOUCHER_LINE_LEDGER_FUND_ORG_ID = UUID.fromString("8ddd1e32-5c85-46ab-8bf3-1ec9a76c18cf"); |
| 17 | + private static final UUID COMPOSITE_INVOICE_VOUCHER_LINE_ORG_ID = UUID.fromString("2028a343-5603-4e86-99d5-c7de322c1709"); |
| 18 | + |
| 19 | + @Override |
| 20 | + public MigrationStrategy getStrategy() { |
| 21 | + return new V24InvoiceSimpleToCompositeMigration(); |
| 22 | + } |
| 23 | + |
| 24 | + @Override |
| 25 | + public List<Arguments> getExpectedTransformations() { |
| 26 | + return List.of( |
| 27 | + Arguments.of( |
| 28 | + "Migrate bill_to to bill_to.address and other fields to invoice.field", |
| 29 | + MigratableQueryInformation |
| 30 | + .builder() |
| 31 | + .entityTypeId(SIMPLE_INVOICE_ID) |
| 32 | + .fqlQuery( |
| 33 | + "{\"bill_to\": {\"$eq\": \"some address\"}, \"accounting_code\": {\"$eq\": \"abc\"}, \"bill_to_id\": {\"$eq\": \"some-uuid\"}}" |
| 34 | + ) |
| 35 | + .fields(List.of("bill_to", "accounting_code", "bill_to_id")) |
| 36 | + .build(), |
| 37 | + MigratableQueryInformation |
| 38 | + .builder() |
| 39 | + .entityTypeId(COMPOSITE_INVOICE_ID) |
| 40 | + .fqlQuery( |
| 41 | + "{\"$and\": [{\"bill_to.address\": {\"$eq\": \"some address\"}}, {\"invoice.accounting_code\": {\"$eq\": \"abc\"}}, {\"invoice.bill_to_id\": {\"$eq\": \"some-uuid\"}}]}" |
| 42 | + ) |
| 43 | + .fields(List.of("bill_to.address", "invoice.accounting_code", "invoice.bill_to_id")) |
| 44 | + .build() |
| 45 | + ), |
| 46 | + Arguments.of( |
| 47 | + "Warn for bill_to and do not migrate other fields in a composite containing simple_invoice (invoice_line case)", |
| 48 | + MigratableQueryInformation |
| 49 | + .builder() |
| 50 | + .entityTypeId(COMPOSITE_INVOICE_LINE_ID) |
| 51 | + .fqlQuery( |
| 52 | + "{\"invoice.bill_to\": {\"$eq\": \"some address\"}, \"invoice.accounting_code\": {\"$eq\": \"abc\"}}" |
| 53 | + ) |
| 54 | + .fields(List.of("invoice.bill_to", "invoice.accounting_code")) |
| 55 | + .build(), |
| 56 | + MigratableQueryInformation |
| 57 | + .builder() |
| 58 | + .entityTypeId(COMPOSITE_INVOICE_LINE_ID) |
| 59 | + .fqlQuery( |
| 60 | + "{\"invoice.accounting_code\": {\"$eq\": \"abc\"}}" |
| 61 | + ) |
| 62 | + .fields(List.of("invoice.accounting_code")) |
| 63 | + .warnings(List.of( |
| 64 | + RemovedFieldWarning.withoutAlternative().apply("", "invoice.bill_to", "{\n \"$eq\" : \"some address\"\n}"), |
| 65 | + RemovedFieldWarning.withoutAlternative().apply("", "invoice.bill_to", null) |
| 66 | + )) |
| 67 | + .hadBreakingChanges(true) |
| 68 | + .build() |
| 69 | + ), |
| 70 | + Arguments.of( |
| 71 | + "Warn for bill_to and do not migrate other fields in a composite containing simple_invoice (analytics case)", |
| 72 | + MigratableQueryInformation |
| 73 | + .builder() |
| 74 | + .entityTypeId(COMPOSITE_ORDER_INVOICE_ANALYTICS_ID) |
| 75 | + .fqlQuery( |
| 76 | + "{\"invoice.bill_to\": {\"$eq\": \"some address\"}, \"invoice.accounting_code\": {\"$eq\": \"abc\"}}" |
| 77 | + ) |
| 78 | + .fields(List.of("invoice.bill_to", "invoice.accounting_code")) |
| 79 | + .build(), |
| 80 | + MigratableQueryInformation |
| 81 | + .builder() |
| 82 | + .entityTypeId(COMPOSITE_ORDER_INVOICE_ANALYTICS_ID) |
| 83 | + .fqlQuery( |
| 84 | + "{\"invoice.accounting_code\": {\"$eq\": \"abc\"}}" |
| 85 | + ) |
| 86 | + .fields(List.of("invoice.accounting_code")) |
| 87 | + .warnings(List.of( |
| 88 | + RemovedFieldWarning.withoutAlternative().apply("", "invoice.bill_to", "{\n \"$eq\" : \"some address\"\n}"), |
| 89 | + RemovedFieldWarning.withoutAlternative().apply("", "invoice.bill_to", null) |
| 90 | + )) |
| 91 | + .hadBreakingChanges(true) |
| 92 | + .build() |
| 93 | + ), |
| 94 | + Arguments.of( |
| 95 | + "Warn for bill_to and do not migrate other fields in a composite containing simple_invoice (voucher line ledger fund org case)", |
| 96 | + MigratableQueryInformation |
| 97 | + .builder() |
| 98 | + .entityTypeId(COMPOSITE_INVOICE_VOUCHER_LINE_LEDGER_FUND_ORG_ID) |
| 99 | + .fqlQuery( |
| 100 | + "{\"invoice.bill_to\": {\"$eq\": \"some address\"}, \"invoice.accounting_code\": {\"$eq\": \"abc\"}}" |
| 101 | + ) |
| 102 | + .fields(List.of("invoice.bill_to", "invoice.accounting_code")) |
| 103 | + .build(), |
| 104 | + MigratableQueryInformation |
| 105 | + .builder() |
| 106 | + .entityTypeId(COMPOSITE_INVOICE_VOUCHER_LINE_LEDGER_FUND_ORG_ID) |
| 107 | + .fqlQuery( |
| 108 | + "{\"invoice.accounting_code\": {\"$eq\": \"abc\"}}" |
| 109 | + ) |
| 110 | + .fields(List.of("invoice.accounting_code")) |
| 111 | + .warnings(List.of( |
| 112 | + RemovedFieldWarning.withoutAlternative().apply("", "invoice.bill_to", "{\n \"$eq\" : \"some address\"\n}"), |
| 113 | + RemovedFieldWarning.withoutAlternative().apply("", "invoice.bill_to", null) |
| 114 | + )) |
| 115 | + .hadBreakingChanges(true) |
| 116 | + .build() |
| 117 | + ), |
| 118 | + Arguments.of( |
| 119 | + "Warn for bill_to and do not migrate other fields in a composite containing simple_invoice (voucher line org case)", |
| 120 | + MigratableQueryInformation |
| 121 | + .builder() |
| 122 | + .entityTypeId(COMPOSITE_INVOICE_VOUCHER_LINE_ORG_ID) |
| 123 | + .fqlQuery( |
| 124 | + "{\"invoice.bill_to\": {\"$eq\": \"some address\"}, \"invoice.accounting_code\": {\"$eq\": \"abc\"}}" |
| 125 | + ) |
| 126 | + .fields(List.of("invoice.bill_to", "invoice.accounting_code")) |
| 127 | + .build(), |
| 128 | + MigratableQueryInformation |
| 129 | + .builder() |
| 130 | + .entityTypeId(COMPOSITE_INVOICE_VOUCHER_LINE_ORG_ID) |
| 131 | + .fqlQuery( |
| 132 | + "{\"invoice.accounting_code\": {\"$eq\": \"abc\"}}" |
| 133 | + ) |
| 134 | + .fields(List.of("invoice.accounting_code")) |
| 135 | + .warnings(List.of( |
| 136 | + RemovedFieldWarning.withoutAlternative().apply("", "invoice.bill_to", "{\n \"$eq\" : \"some address\"\n}"), |
| 137 | + RemovedFieldWarning.withoutAlternative().apply("", "invoice.bill_to", null) |
| 138 | + )) |
| 139 | + .hadBreakingChanges(true) |
| 140 | + .build() |
| 141 | + ), |
| 142 | + Arguments.of( |
| 143 | + "Do not over-migrate already-migrated fields in composite_invoice", |
| 144 | + MigratableQueryInformation |
| 145 | + .builder() |
| 146 | + .entityTypeId(COMPOSITE_INVOICE_ID) |
| 147 | + .fqlQuery( |
| 148 | + "{\"bill_to.address\": {\"$eq\": \"some address\"}, \"invoice.accounting_code\": {\"$eq\": \"abc\"}}" |
| 149 | + ) |
| 150 | + .fields(List.of("bill_to.address", "invoice.accounting_code")) |
| 151 | + .build(), |
| 152 | + MigratableQueryInformation |
| 153 | + .builder() |
| 154 | + .entityTypeId(COMPOSITE_INVOICE_ID) |
| 155 | + .fqlQuery( |
| 156 | + "{\"$and\": [{\"bill_to.address\": {\"$eq\": \"some address\"}}, {\"invoice.accounting_code\": {\"$eq\": \"abc\"}}]}" |
| 157 | + ) |
| 158 | + .fields(List.of("bill_to.address", "invoice.accounting_code")) |
| 159 | + .build() |
| 160 | + ) |
| 161 | + ); |
| 162 | + } |
| 163 | +} |
0 commit comments