Skip to content

Commit

Permalink
PO-359: auto-create success and error sub directories for inbound loc…
Browse files Browse the repository at this point in the history
…a… (#366)
  • Loading branch information
sabahirfan authored May 17, 2024
1 parent 6589e33 commit 73a7923
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 9 deletions.
14 changes: 14 additions & 0 deletions src/main/java/uk/gov/hmcts/opal/sftp/SftpLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,24 @@
public enum SftpLocation {

AUTO_CHEQUES(INBOUND, "auto-cheque", "Comes from OAGS (pushed)"),
AUTO_CHEQUES_SUCCESS(INBOUND, "auto-cheque/success", "Successfully processed for auto-check"),
AUTO_CHEQUES_ERROR(INBOUND, "auto-cheque/error", "Error processing for auto-check"),

AUTO_CASH(INBOUND, "auto-cash", "Comes from OAGS (pushed)"),
AUTO_CASH_SUCCESS(INBOUND, "auto-cash/success", "Successfully processed for auto-cash"),
AUTO_CASH_ERROR(INBOUND, "auto-cash/error", "Error processing for auto-cash"),

NATWEST(INBOUND, "natwest", "Comes from BAIS (pulled)"),
NATWEST_SUCCESS(INBOUND, "natwest/success", "Successfully processed for natwest"),
NATWEST_ERROR(INBOUND, "natwest/error", "Error processing for natwest"),

ALL_PAY_BT_BARCLAY_CARD(INBOUND, "allpay", "Comes from BAIS (pulled)"),
ALL_PAY_BT_BARCLAY_CARD_SUCCESS(INBOUND, "allpay/success", "Successfully processed for all pay"),
ALL_PAY_BT_BARCLAY_CARD_ERROR(INBOUND, "allpay/error", "Error processing for all pay"),

DWP_BAILIFFS(INBOUND, "dwp-bailiffs", "Comes from BAIS (pulled)"),
DWP_BAILIFFS_SUCCESS(INBOUND, "dwp-bailiffs/success", "Successfully processed for DWP bailiffs"),
DWP_BAILIFFS_ERROR(INBOUND, "dwp-bailiffs/error", "Error processing for DWP bailiffs"),

ALL_PAY(OUTBOUND, "allpay", "Goes to BAIS (pushed)"),
ARCHIVE(OUTBOUND, "allpay-archive", "Goes to OAGS (pushed)");
Expand Down
102 changes: 93 additions & 9 deletions src/test/java/uk/gov/hmcts/opal/sftp/SftpLocationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,113 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;

import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static uk.gov.hmcts.opal.sftp.SftpDirection.INBOUND;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@ExtendWith(MockitoExtension.class)
class SftpLocationTest {

@Test
void testGetOutboundLocations() {
List<SftpLocation> outboundLocations = Arrays.asList(
SftpLocation.ALL_PAY,
SftpLocation.ARCHIVE
);

List<SftpLocation> result = SftpLocation.getOutboundLocations();
assertEquals(2, outboundLocations.size());
assertEquals(outboundLocations, result);
}

@Test
void testGetInboundLocations() {
List<SftpLocation> inboundLocations = SftpLocation.getInboundLocations();
assertEquals(5, inboundLocations.size());
List<SftpLocation> inboundLocations = Arrays.asList(
SftpLocation.AUTO_CHEQUES,
SftpLocation.AUTO_CHEQUES_SUCCESS,
SftpLocation.AUTO_CHEQUES_ERROR,
SftpLocation.AUTO_CASH,
SftpLocation.AUTO_CASH_SUCCESS,
SftpLocation.AUTO_CASH_ERROR,
SftpLocation.NATWEST,
SftpLocation.NATWEST_SUCCESS,
SftpLocation.NATWEST_ERROR,
SftpLocation.ALL_PAY_BT_BARCLAY_CARD,
SftpLocation.ALL_PAY_BT_BARCLAY_CARD_SUCCESS,
SftpLocation.ALL_PAY_BT_BARCLAY_CARD_ERROR,
SftpLocation.DWP_BAILIFFS,
SftpLocation.DWP_BAILIFFS_SUCCESS,
SftpLocation.DWP_BAILIFFS_ERROR
);
List<SftpLocation> outboundLocations = Arrays.asList(SftpLocation.ALL_PAY, SftpLocation.ARCHIVE);

assertEquals(15, SftpLocation.getInboundLocations().size());
assertEquals(inboundLocations, SftpLocation.getInboundLocations());
assertEquals(outboundLocations, SftpLocation.getOutboundLocations());
}

@Test
void testGetOutboundLocations() {
List<SftpLocation> outboundLocations = SftpLocation.getOutboundLocations();
assertEquals(2, outboundLocations.size());
void testGetDirection() {
assertEquals(SftpDirection.INBOUND, SftpLocation.AUTO_CHEQUES.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.AUTO_CHEQUES_SUCCESS.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.AUTO_CHEQUES_ERROR.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.AUTO_CASH.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.AUTO_CASH_SUCCESS.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.AUTO_CASH_ERROR.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.NATWEST.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.NATWEST_SUCCESS.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.NATWEST_ERROR.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.ALL_PAY_BT_BARCLAY_CARD.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.ALL_PAY_BT_BARCLAY_CARD_SUCCESS.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.ALL_PAY_BT_BARCLAY_CARD_ERROR.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.DWP_BAILIFFS.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.DWP_BAILIFFS_SUCCESS.getDirection());
assertEquals(SftpDirection.INBOUND, SftpLocation.DWP_BAILIFFS_ERROR.getDirection());
assertEquals(SftpDirection.OUTBOUND, SftpLocation.ALL_PAY.getDirection());
assertEquals(SftpDirection.OUTBOUND, SftpLocation.ARCHIVE.getDirection());
}

@Test
void testGetPath() {
assertEquals("auto-cheque", SftpLocation.AUTO_CHEQUES.getPath());
assertEquals("auto-cheque/success", SftpLocation.AUTO_CHEQUES_SUCCESS.getPath());
assertEquals("auto-cheque/error", SftpLocation.AUTO_CHEQUES_ERROR.getPath());
assertEquals("auto-cash", SftpLocation.AUTO_CASH.getPath());
assertEquals("auto-cash/success", SftpLocation.AUTO_CASH_SUCCESS.getPath());
assertEquals("auto-cash/error", SftpLocation.AUTO_CASH_ERROR.getPath());
assertEquals("natwest", SftpLocation.NATWEST.getPath());
assertEquals("natwest/success", SftpLocation.NATWEST_SUCCESS.getPath());
assertEquals("natwest/error", SftpLocation.NATWEST_ERROR.getPath());
assertEquals("allpay", SftpLocation.ALL_PAY_BT_BARCLAY_CARD.getPath());
assertEquals("allpay/success", SftpLocation.ALL_PAY_BT_BARCLAY_CARD_SUCCESS.getPath());
assertEquals("allpay/error", SftpLocation.ALL_PAY_BT_BARCLAY_CARD_ERROR.getPath());
assertEquals("dwp-bailiffs", SftpLocation.DWP_BAILIFFS.getPath());
assertEquals("dwp-bailiffs/success", SftpLocation.DWP_BAILIFFS_SUCCESS.getPath());
assertEquals("dwp-bailiffs/error", SftpLocation.DWP_BAILIFFS_ERROR.getPath());
assertEquals("allpay", SftpLocation.ALL_PAY.getPath());
assertEquals("allpay-archive", SftpLocation.ARCHIVE.getPath());
}

@Test
void testGetLocations() {
List<SftpLocation> locations = SftpLocation.getLocations(INBOUND);
assertEquals(5, locations.size());
void testGetDescription() {
assertNotNull(SftpLocation.AUTO_CHEQUES.getDescription());
assertNotNull(SftpLocation.AUTO_CHEQUES_SUCCESS.getDescription());
assertNotNull(SftpLocation.AUTO_CHEQUES_ERROR.getDescription());
assertNotNull(SftpLocation.AUTO_CASH.getDescription());
assertNotNull(SftpLocation.AUTO_CASH_SUCCESS.getDescription());
assertNotNull(SftpLocation.AUTO_CASH_ERROR.getDescription());
assertNotNull(SftpLocation.NATWEST.getDescription());
assertNotNull(SftpLocation.NATWEST_SUCCESS.getDescription());
assertNotNull(SftpLocation.NATWEST_ERROR.getDescription());
assertNotNull(SftpLocation.ALL_PAY_BT_BARCLAY_CARD.getDescription());
assertNotNull(SftpLocation.ALL_PAY_BT_BARCLAY_CARD_SUCCESS.getDescription());
assertNotNull(SftpLocation.ALL_PAY_BT_BARCLAY_CARD_ERROR.getDescription());
assertNotNull(SftpLocation.DWP_BAILIFFS.getDescription());
assertNotNull(SftpLocation.DWP_BAILIFFS_SUCCESS.getDescription());
assertNotNull(SftpLocation.DWP_BAILIFFS_ERROR.getDescription());
assertNotNull(SftpLocation.ALL_PAY.getDescription());
assertNotNull(SftpLocation.ARCHIVE.getDescription());
}
}

0 comments on commit 73a7923

Please sign in to comment.