TestData

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.9 kB
3
Indexable
const FormalValidationData = require("../../formal-validation/test-data/validate-auction-bid-message.test-data");
const AuctionData = require("../../../mock-data/auction-mock-data");
const CcmData = require("../../../mock-data/ccm-mock-data");
const MasterData = require("../../../mock-data/master-data-mock-data/auction-participant");
const AuctionBid = require("../../../mock-data/auction-bid-mock-data");
const TimeSeriesMockData = require("../../../mock-data/time-series-mock-data");

function dtoIn() {
  let dtoIn = FormalValidationData.dtoIn;
  dtoIn.list[0].itemList[0].timeInterval = {
    from: "2021-11-17T23:00:00.000Z",
    to: "2021-11-17T23:15:00.000Z",
  };
  return {
    ...dtoIn,
  };
}

function auction() {
  let auctionData = AuctionData.auction;
  auctionData.id = "RO-RS-Y-01012022-00001";
  auctionData.timescale = "dayAhead";
  auctionData.timeInterval = dtoIn().list[0].itemList[0].timeInterval;
  auctionData.auctionState = "biddingOpen";
  return {
    ...auctionData,
  };
}

function listMarketParticipant() {
  let list = _copyData(CcmData.marketParticipantList);
  list.itemList[0].id = dtoIn().senderMarketParticipantId;
  list.itemList[0].eic = "businessApplicationEIC";
  list.itemList[1].id = dtoIn().marketParticipantId;
  list.itemList[1].eic = "marketParticipantEIC";
  return {
    ...list,
  };
}

function auctionParticipant() {
  return { ...MasterData.auctionParticipant, border: { borderCode: "rohu" } };
}

function auctionBidList() {
  let auctionBid = AuctionBid.auctionBidList.itemList[0];
  auctionBid.documentCode = "28X-INTERENERGO8_20210729BGRO";
  return {
    itemList: [auctionBid],
  };
}

function auctionBid() {
  let list = _copyData(AuctionBid.auctionBidList);
  list.itemList[0].auctionId = auction().id;
  list.itemList[0].marketParticipantId = dtoIn().marketParticipantId;
  list.itemList[0].documentCode = "28X-INTERENERGO8_20210729BGRO";
  return { ...list.itemList[0] };
}

function tsListData() {
  let list = _copyData(TimeSeriesMockData.auctionBidTimeSeries);
  list.tsList.forEach((item, index) => {
    item.tsId.tsDefinitionCode = "oc_aucCat_pt15m";
    if (index === 0) {
      item.tsId.tsDimensionValueIdList = [auction().id];
      item.timeInterval = {
        from: "2021-11-17T23:00:00.000Z",
        to: "2021-11-18T00:00:00.000Z",
      };
      item.tsValueList = [
        {
          value: 99,
          timestamp: "2021-11-17T23:00:00.000Z",
        },
        {
          value: 99,
          timestamp: "2021-11-17T23:15:00.000Z",
        },
        {
          value: 99,
          timestamp: "2021-11-17T23:30:00.000Z",
        },
        {
          value: 99,
          timestamp: "2021-11-17T23:45:00.000Z",
        },
      ];
    }
    if (index === 1) {
      item.timeInterval = {
        from: "2021-11-17T23:00:00.000Z",
        to: "2021-11-18T00:00:00.000Z",
      };
      item.tsValueList = [
        {
          value: 91,
          timestamp: "2021-11-17T23:00:00.000Z",
        },
        {
          value: 99,
          timestamp: "2021-11-17T23:15:00.000Z",
        },
        {
          value: 84,
          timestamp: "2021-11-17T23:30:00.000Z",
        },
        {
          value: 105,
          timestamp: "2021-11-17T23:45:00.000Z",
        },
      ];
    }
  });
  return { ...list };
}

function _copyData(data) {
  return JSON.parse(JSON.stringify(data));
}

module.exports = {
  get dtoIn() {
    return dtoIn();
  },
  get auction() {
    return auction();
  },
  get listMarketParticipant() {
    return listMarketParticipant();
  },
  get auctionParticipant() {
    return auctionParticipant();
  },
  get auctionBid() {
    return auctionBid();
  },
  get tsListData() {
    return tsListData();
  },
  get auctionBidList() {
    return auctionBidList();
  },
};