use of org.estatio.module.capex.dom.documents.BuyerFinder in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_Test method notification_BuyerBarcodeMatchValidation_works.
@Test
public void notification_BuyerBarcodeMatchValidation_works() {
String notification;
// given
IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel();
Party buyerDerived = new Organisation();
BuyerFinder buyerFinder = new BuyerFinder() {
@Override
public Party buyerDerivedFromDocumentName(final IncomingInvoice incomingInvoice) {
return buyerDerived;
}
};
IncomingInvoice invoice = new IncomingInvoice();
Party buyerOnViewmodel = new Organisation();
viewModel.setDomainObject(invoice);
viewModel.buyerFinder = buyerFinder;
viewModel.setBuyer(buyerOnViewmodel);
// when
notification = viewModel.getNotification();
// then
Assertions.assertThat(notification).isEqualTo("Buyer does not match barcode (document name); ");
// and given (buyers matching)
viewModel.setBuyer(buyerDerived);
// when
notification = viewModel.getNotification();
// then
Assertions.assertThat(notification).isNull();
// and given (no buyer derived)
BuyerFinder buyerFinderReturningNull = new BuyerFinder() {
@Override
public Party buyerDerivedFromDocumentName(final IncomingInvoice incomingInvoice) {
return null;
}
};
viewModel.buyerFinder = buyerFinderReturningNull;
// when
notification = viewModel.getNotification();
// then
Assertions.assertThat(notification).isNull();
}
use of org.estatio.module.capex.dom.documents.BuyerFinder in project estatio by estatio.
the class BuyerFinder_Test method testWhenParamIsDocument.
private void testWhenParamIsDocument(final String documentName, final String derivedPartyReference) {
// given
Document document = new Document(null, null, documentName, null, null);
BuyerFinder finder = new BuyerFinder();
finder.partyRepository = mockPartyRepository;
// expect
context.checking(new Expectations() {
{
oneOf(mockPartyRepository).findPartyByReference(derivedPartyReference);
}
});
// when
finder.buyerDerivedFromDocumentName(document);
}
use of org.estatio.module.capex.dom.documents.BuyerFinder in project estatio by estatio.
the class BuyerFinder_Test method testerWhenNullOrTooShort.
private void testerWhenNullOrTooShort(final String documentName) {
// given
IncomingInvoice invoice = new IncomingInvoice();
BuyerFinder finder = new BuyerFinder();
finder.partyRepository = mockPartyRepository;
finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
// expect
context.checking(new Expectations() {
{
oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
will(returnValue(optional));
}
});
// when
finder.buyerDerivedFromDocumentName(invoice);
}
use of org.estatio.module.capex.dom.documents.BuyerFinder in project estatio by estatio.
the class BuyerFinder_Test method testWhenParamIsInvoice.
private void testWhenParamIsInvoice(final String documentName, final String derivedPartyReference) {
// given
IncomingInvoice invoice = new IncomingInvoice();
BuyerFinder finder = new BuyerFinder();
finder.partyRepository = mockPartyRepository;
finder.lookupAttachedPdfService = mockLookupAttachedPdfService;
Optional<Document> optional = Optional.of(new Document(null, null, documentName, null, null));
// expect
context.checking(new Expectations() {
{
oneOf(mockLookupAttachedPdfService).lookupIncomingInvoicePdfFrom(invoice);
will(returnValue(optional));
oneOf(mockPartyRepository).findPartyByReference(derivedPartyReference);
}
});
// when
finder.buyerDerivedFromDocumentName(invoice);
}
Aggregations