@Test public void test_to_contract() { InstrumentContract expectedContract = instrumentMapper.toContract(domain()); assertEquals(expectedContract.getId(), contract().getId()); assertEquals(expectedContract.getAmount(), contract().getAmount()); assertEquals(expectedContract.getBank().getId(), contract().getBank().getId()); assertEquals(expectedContract.getBankAccount().getId(), contract().getBankAccount().getId()); assertEquals(expectedContract.getBranchName(), contract().getBranchName()); assertEquals(expectedContract.getDrawer(), contract().getDrawer()); assertEquals(expectedContract.getFinancialStatus().getCode(), contract().getFinancialStatus().getCode()); assertEquals(expectedContract.getInstrumentType().getId(), contract().getInstrumentType().getId()); assertEquals(expectedContract.getSurrenderReason().getId(), contract().getSurrenderReason().getId()); assertEquals(expectedContract.getInstrumentVouchers().iterator().next().getInstrument(), contract().getInstrumentVouchers().iterator().next().getInstrument()); assertEquals(expectedContract.getInstrumentVouchers().iterator().next().getVoucherHeaderId(), contract().getInstrumentVouchers().iterator().next().getVoucherHeaderId()); assertEquals(expectedContract.getPayee(), contract().getPayee()); assertEquals(expectedContract.getSerialNo(), contract().getSerialNo()); assertEquals(expectedContract.getTransactionNumber(), contract().getTransactionNumber()); assertEquals(expectedContract.getTransactionType(), contract().getTransactionType()); assertEquals(expectedContract.getCreatedBy().getId(), contract().getCreatedBy().getId()); assertEquals(expectedContract.getLastModifiedBy().getId(), contract().getLastModifiedBy().getId()); assertEquals(expectedContract.getTenantId(), contract().getTenantId()); }
public InstrumentContract toContract(Instrument instrument) { InstrumentContract contract = new InstrumentContract(); contract.setId(instrument.getId()); contract.setAmount(instrument.getAmount()); contract.setBank(instrument.getBank()); contract.setBankAccount(instrument.getBankAccount()); contract.setBranchName(instrument.getBranchName()); contract.setDrawer(instrument.getDrawer()); contract.setFinancialStatus(instrument.getFinancialStatus()); contract.setRemittanceVoucherId(instrument.getRemittanceVoucherId()); if (instrument.getInstrumentType() != null) contract.setInstrumentType(typeMapper.toContract(instrument.getInstrumentType())); if (instrument.getSurrenderReason() != null) contract.setSurrenderReason(srMapper.toContract(instrument.getSurrenderReason())); if (instrument.getInstrumentVouchers() != null) { List<InstrumentVoucherContract> instrumentVouchers = new ArrayList<>(); if (instrument.getInstrumentVouchers() != null) for (InstrumentVoucher iv : instrument.getInstrumentVouchers()) instrumentVouchers .add(InstrumentVoucherContract.builder().instrument(contract.getId()) .voucherHeaderId(iv.getVoucherHeaderId()).receiptHeaderId(iv.getReceiptHeaderId()).build()); contract.setInstrumentVouchers(instrumentVouchers); } contract.setPayee(instrument.getPayee()); contract.setSerialNo(instrument.getSerialNo()); contract.setTransactionDate(instrument.getTransactionDate()); contract.setTransactionNumber(instrument.getTransactionNumber()); contract.setTransactionType(instrument.getTransactionType() != null ? TransactionTypeContract.valueOf(instrument.getTransactionType().name()) : null); contract.setPayinSlipId(instrument.getPayinSlipId()); contract.setReconciledAmount(instrument.getReconciledAmount()); contract.setReconciledOn(instrument.getReconciledOn()); contract.setCreatedBy(instrument.getCreatedBy()); contract.setCreatedDate(instrument.getCreatedDate()); contract.setLastModifiedBy(instrument.getLastModifiedBy()); contract.setLastModifiedDate(instrument.getLastModifiedDate()); contract.setTenantId(instrument.getTenantId()); contract.setDeleteReason(instrument.getDeleteReason()); return contract; }
InstrumentMapper { public InstrumentContract toContract(Instrument instrument) { InstrumentContract contract = new InstrumentContract(); contract.setId(instrument.getId()); contract.setAmount(instrument.getAmount()); contract.setBank(instrument.getBank()); contract.setBankAccount(instrument.getBankAccount()); contract.setBranchName(instrument.getBranchName()); contract.setDrawer(instrument.getDrawer()); contract.setFinancialStatus(instrument.getFinancialStatus()); contract.setRemittanceVoucherId(instrument.getRemittanceVoucherId()); if (instrument.getInstrumentType() != null) contract.setInstrumentType(typeMapper.toContract(instrument.getInstrumentType())); if (instrument.getSurrenderReason() != null) contract.setSurrenderReason(srMapper.toContract(instrument.getSurrenderReason())); if (instrument.getInstrumentVouchers() != null) { List<InstrumentVoucherContract> instrumentVouchers = new ArrayList<>(); if (instrument.getInstrumentVouchers() != null) for (InstrumentVoucher iv : instrument.getInstrumentVouchers()) instrumentVouchers .add(InstrumentVoucherContract.builder().instrument(contract.getId()) .voucherHeaderId(iv.getVoucherHeaderId()).receiptHeaderId(iv.getReceiptHeaderId()).build()); contract.setInstrumentVouchers(instrumentVouchers); } contract.setPayee(instrument.getPayee()); contract.setSerialNo(instrument.getSerialNo()); contract.setTransactionDate(instrument.getTransactionDate()); contract.setTransactionNumber(instrument.getTransactionNumber()); contract.setTransactionType(instrument.getTransactionType() != null ? TransactionTypeContract.valueOf(instrument.getTransactionType().name()) : null); contract.setPayinSlipId(instrument.getPayinSlipId()); contract.setReconciledAmount(instrument.getReconciledAmount()); contract.setReconciledOn(instrument.getReconciledOn()); contract.setCreatedBy(instrument.getCreatedBy()); contract.setCreatedDate(instrument.getCreatedDate()); contract.setLastModifiedBy(instrument.getLastModifiedBy()); contract.setLastModifiedDate(instrument.getLastModifiedDate()); contract.setTenantId(instrument.getTenantId()); contract.setDeleteReason(instrument.getDeleteReason()); return contract; } }
InstrumentMapper { public InstrumentContract toContract(Instrument instrument) { InstrumentContract contract = new InstrumentContract(); contract.setId(instrument.getId()); contract.setAmount(instrument.getAmount()); contract.setBank(instrument.getBank()); contract.setBankAccount(instrument.getBankAccount()); contract.setBranchName(instrument.getBranchName()); contract.setDrawer(instrument.getDrawer()); contract.setFinancialStatus(instrument.getFinancialStatus()); contract.setRemittanceVoucherId(instrument.getRemittanceVoucherId()); if (instrument.getInstrumentType() != null) contract.setInstrumentType(typeMapper.toContract(instrument.getInstrumentType())); if (instrument.getSurrenderReason() != null) contract.setSurrenderReason(srMapper.toContract(instrument.getSurrenderReason())); if (instrument.getInstrumentVouchers() != null) { List<InstrumentVoucherContract> instrumentVouchers = new ArrayList<>(); if (instrument.getInstrumentVouchers() != null) for (InstrumentVoucher iv : instrument.getInstrumentVouchers()) instrumentVouchers .add(InstrumentVoucherContract.builder().instrument(contract.getId()) .voucherHeaderId(iv.getVoucherHeaderId()).receiptHeaderId(iv.getReceiptHeaderId()).build()); contract.setInstrumentVouchers(instrumentVouchers); } contract.setPayee(instrument.getPayee()); contract.setSerialNo(instrument.getSerialNo()); contract.setTransactionDate(instrument.getTransactionDate()); contract.setTransactionNumber(instrument.getTransactionNumber()); contract.setTransactionType(instrument.getTransactionType() != null ? TransactionTypeContract.valueOf(instrument.getTransactionType().name()) : null); contract.setPayinSlipId(instrument.getPayinSlipId()); contract.setReconciledAmount(instrument.getReconciledAmount()); contract.setReconciledOn(instrument.getReconciledOn()); contract.setCreatedBy(instrument.getCreatedBy()); contract.setCreatedDate(instrument.getCreatedDate()); contract.setLastModifiedBy(instrument.getLastModifiedBy()); contract.setLastModifiedDate(instrument.getLastModifiedDate()); contract.setTenantId(instrument.getTenantId()); contract.setDeleteReason(instrument.getDeleteReason()); return contract; }  }
InstrumentMapper { public InstrumentContract toContract(Instrument instrument) { InstrumentContract contract = new InstrumentContract(); contract.setId(instrument.getId()); contract.setAmount(instrument.getAmount()); contract.setBank(instrument.getBank()); contract.setBankAccount(instrument.getBankAccount()); contract.setBranchName(instrument.getBranchName()); contract.setDrawer(instrument.getDrawer()); contract.setFinancialStatus(instrument.getFinancialStatus()); contract.setRemittanceVoucherId(instrument.getRemittanceVoucherId()); if (instrument.getInstrumentType() != null) contract.setInstrumentType(typeMapper.toContract(instrument.getInstrumentType())); if (instrument.getSurrenderReason() != null) contract.setSurrenderReason(srMapper.toContract(instrument.getSurrenderReason())); if (instrument.getInstrumentVouchers() != null) { List<InstrumentVoucherContract> instrumentVouchers = new ArrayList<>(); if (instrument.getInstrumentVouchers() != null) for (InstrumentVoucher iv : instrument.getInstrumentVouchers()) instrumentVouchers .add(InstrumentVoucherContract.builder().instrument(contract.getId()) .voucherHeaderId(iv.getVoucherHeaderId()).receiptHeaderId(iv.getReceiptHeaderId()).build()); contract.setInstrumentVouchers(instrumentVouchers); } contract.setPayee(instrument.getPayee()); contract.setSerialNo(instrument.getSerialNo()); contract.setTransactionDate(instrument.getTransactionDate()); contract.setTransactionNumber(instrument.getTransactionNumber()); contract.setTransactionType(instrument.getTransactionType() != null ? TransactionTypeContract.valueOf(instrument.getTransactionType().name()) : null); contract.setPayinSlipId(instrument.getPayinSlipId()); contract.setReconciledAmount(instrument.getReconciledAmount()); contract.setReconciledOn(instrument.getReconciledOn()); contract.setCreatedBy(instrument.getCreatedBy()); contract.setCreatedDate(instrument.getCreatedDate()); contract.setLastModifiedBy(instrument.getLastModifiedBy()); contract.setLastModifiedDate(instrument.getLastModifiedDate()); contract.setTenantId(instrument.getTenantId()); contract.setDeleteReason(instrument.getDeleteReason()); return contract; }  Instrument toDomain(InstrumentContract contract); InstrumentContract toContract(Instrument instrument); InstrumentSearch toSearchDomain(InstrumentSearchContract contract); InstrumentSearchContract toSearchContract(InstrumentSearch instrumentSearch); }
InstrumentMapper { public InstrumentContract toContract(Instrument instrument) { InstrumentContract contract = new InstrumentContract(); contract.setId(instrument.getId()); contract.setAmount(instrument.getAmount()); contract.setBank(instrument.getBank()); contract.setBankAccount(instrument.getBankAccount()); contract.setBranchName(instrument.getBranchName()); contract.setDrawer(instrument.getDrawer()); contract.setFinancialStatus(instrument.getFinancialStatus()); contract.setRemittanceVoucherId(instrument.getRemittanceVoucherId()); if (instrument.getInstrumentType() != null) contract.setInstrumentType(typeMapper.toContract(instrument.getInstrumentType())); if (instrument.getSurrenderReason() != null) contract.setSurrenderReason(srMapper.toContract(instrument.getSurrenderReason())); if (instrument.getInstrumentVouchers() != null) { List<InstrumentVoucherContract> instrumentVouchers = new ArrayList<>(); if (instrument.getInstrumentVouchers() != null) for (InstrumentVoucher iv : instrument.getInstrumentVouchers()) instrumentVouchers .add(InstrumentVoucherContract.builder().instrument(contract.getId()) .voucherHeaderId(iv.getVoucherHeaderId()).receiptHeaderId(iv.getReceiptHeaderId()).build()); contract.setInstrumentVouchers(instrumentVouchers); } contract.setPayee(instrument.getPayee()); contract.setSerialNo(instrument.getSerialNo()); contract.setTransactionDate(instrument.getTransactionDate()); contract.setTransactionNumber(instrument.getTransactionNumber()); contract.setTransactionType(instrument.getTransactionType() != null ? TransactionTypeContract.valueOf(instrument.getTransactionType().name()) : null); contract.setPayinSlipId(instrument.getPayinSlipId()); contract.setReconciledAmount(instrument.getReconciledAmount()); contract.setReconciledOn(instrument.getReconciledOn()); contract.setCreatedBy(instrument.getCreatedBy()); contract.setCreatedDate(instrument.getCreatedDate()); contract.setLastModifiedBy(instrument.getLastModifiedBy()); contract.setLastModifiedDate(instrument.getLastModifiedDate()); contract.setTenantId(instrument.getTenantId()); contract.setDeleteReason(instrument.getDeleteReason()); return contract; }  Instrument toDomain(InstrumentContract contract); InstrumentContract toContract(Instrument instrument); InstrumentSearch toSearchDomain(InstrumentSearchContract contract); InstrumentSearchContract toSearchContract(InstrumentSearch instrumentSearch);  }