use of org.estatio.module.party.app.services.OrganisationNameNumberViewModel in project estatio by estatio.
the class Organisation_Test method verify_does_not_change_chamber_of_commerce_code_when_code_already_present.
@Test
public void verify_does_not_change_chamber_of_commerce_code_when_code_already_present() throws Exception {
// given
Organisation organisation = new Organisation();
organisation.clockService = mockClockService;
organisation.organisationPreviousNameRepository = mockOrganisationPreviousNameRepository;
final String oldChamberOfCommerceCode = "123456789";
organisation.setChamberOfCommerceCode(oldChamberOfCommerceCode);
final String looked_up_name = "Looked Up Name";
final String newChamberOfCommerceCode = "987654321";
OrganisationNameNumberViewModel vm = new OrganisationNameNumberViewModel(looked_up_name, newChamberOfCommerceCode);
final LocalDate previousNameEndDate = new LocalDate(2017, 01, 01);
// expect
context.checking(new Expectations() {
{
oneOf(mockClockService).now();
will(returnValue(previousNameEndDate));
oneOf(mockOrganisationPreviousNameRepository).newOrganisationPreviousName(null, previousNameEndDate);
}
});
// when
organisation.verify(vm);
// then
assertThat(organisation.getName()).isEqualTo(looked_up_name);
assertThat(organisation.getChamberOfCommerceCode()).isEqualTo(oldChamberOfCommerceCode);
assertThat(organisation.isVerified()).isTrue();
}
use of org.estatio.module.party.app.services.OrganisationNameNumberViewModel in project estatio by estatio.
the class Organisation_Test method verify_works.
@Test
public void verify_works() throws Exception {
// given
Organisation organisation = new Organisation();
organisation.clockService = mockClockService;
organisation.organisationPreviousNameRepository = mockOrganisationPreviousNameRepository;
final String looked_up_name = "Looked Up Name";
final String chamberOfCommerceCode = "123456789";
OrganisationNameNumberViewModel vm = new OrganisationNameNumberViewModel(looked_up_name, chamberOfCommerceCode);
final LocalDate previousNameEndDate = new LocalDate(2017, 01, 01);
// expect
context.checking(new Expectations() {
{
oneOf(mockClockService).now();
will(returnValue(previousNameEndDate));
oneOf(mockOrganisationPreviousNameRepository).newOrganisationPreviousName(null, previousNameEndDate);
}
});
// when
organisation.verify(vm);
// then
assertThat(organisation.getName()).isEqualTo(looked_up_name);
assertThat(organisation.getChamberOfCommerceCode()).isEqualTo(chamberOfCommerceCode);
assertThat(organisation.isVerified()).isTrue();
}
use of org.estatio.module.party.app.services.OrganisationNameNumberViewModel in project estatio by estatio.
the class IncomingDocAsInvoiceViewModel_Test method bankaccount_is_set_when_creating_seller.
@Test
public void bankaccount_is_set_when_creating_seller() {
// given
IncomingDocAsInvoiceViewModel viewModel = new IncomingDocAsInvoiceViewModel();
viewModel.organisationRepository = mockOrganisationRepo;
viewModel.bankAccountRepository = mockBankAccountRepository;
Country country = new Country();
Organisation seller = new Organisation();
BankAccount bankAccount = new BankAccount();
String sellerName = "some name";
OrganisationNameNumberViewModel candidate = new OrganisationNameNumberViewModel(sellerName, null);
String iban = "NL02RABO0313246581";
// expect
context.checking(new Expectations() {
{
oneOf(mockOrganisationRepo).newOrganisation(null, true, sellerName, country);
will(returnValue(seller));
oneOf(mockBankAccountRepository).newBankAccount(seller, iban, null);
will(returnValue(bankAccount));
oneOf(mockBankAccountRepository).getFirstBankAccountOfPartyOrNull(seller);
will(returnValue(bankAccount));
}
});
// when
viewModel.createSeller(candidate, country, iban);
// then
Assertions.assertThat(viewModel.getSeller()).isEqualTo(seller);
Assertions.assertThat(viewModel.getBankAccount()).isEqualTo(bankAccount);
}
use of org.estatio.module.party.app.services.OrganisationNameNumberViewModel in project estatio by estatio.
the class IncomingDocViewModel method autoComplete0CreateSeller.
public List<OrganisationNameNumberViewModel> autoComplete0CreateSeller(@MinLength(3) final String search) {
// TODO: take atPath from country - but how?
String atPath = "/FRA";
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
// nothing
}
List<OrganisationNameNumberViewModel> result = chamberOfCommerceCodeLookUpService.getChamberOfCommerceCodeCandidatesByOrganisation(search, atPath);
result.add(new OrganisationNameNumberViewModel(search, null));
return result;
}
use of org.estatio.module.party.app.services.OrganisationNameNumberViewModel in project estatio by estatio.
the class Order method autoComplete0CreateSeller.
public List<OrganisationNameNumberViewModel> autoComplete0CreateSeller(@MinLength(3) final String search) {
// TODO: take atPath from country - but how?
String atPath = "/FRA";
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
// nothing
}
List<OrganisationNameNumberViewModel> result = chamberOfCommerceCodeLookUpService.getChamberOfCommerceCodeCandidatesByOrganisation(search, atPath);
result.add(new OrganisationNameNumberViewModel(search, null));
return result;
}
Aggregations