Search in sources :

Example 1 with OrganisationNameNumberViewModel

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();
}
Also used : OrganisationNameNumberViewModel(org.estatio.module.party.app.services.OrganisationNameNumberViewModel) Expectations(org.jmock.Expectations) LocalDate(org.joda.time.LocalDate) AbstractBeanPropertiesTest(org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest) Test(org.junit.Test)

Example 2 with OrganisationNameNumberViewModel

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();
}
Also used : OrganisationNameNumberViewModel(org.estatio.module.party.app.services.OrganisationNameNumberViewModel) Expectations(org.jmock.Expectations) LocalDate(org.joda.time.LocalDate) AbstractBeanPropertiesTest(org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest) Test(org.junit.Test)

Example 3 with OrganisationNameNumberViewModel

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);
}
Also used : OrganisationNameNumberViewModel(org.estatio.module.party.app.services.OrganisationNameNumberViewModel) Expectations(org.jmock.Expectations) Organisation(org.estatio.module.party.dom.Organisation) Country(org.incode.module.country.dom.impl.Country) BankAccount(org.estatio.module.financial.dom.BankAccount) Test(org.junit.Test)

Example 4 with OrganisationNameNumberViewModel

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;
}
Also used : OrganisationNameNumberViewModel(org.estatio.module.party.app.services.OrganisationNameNumberViewModel)

Example 5 with OrganisationNameNumberViewModel

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;
}
Also used : OrganisationNameNumberViewModel(org.estatio.module.party.app.services.OrganisationNameNumberViewModel)

Aggregations

OrganisationNameNumberViewModel (org.estatio.module.party.app.services.OrganisationNameNumberViewModel)5 Expectations (org.jmock.Expectations)3 Test (org.junit.Test)3 AbstractBeanPropertiesTest (org.incode.module.unittestsupport.dom.bean.AbstractBeanPropertiesTest)2 LocalDate (org.joda.time.LocalDate)2 BankAccount (org.estatio.module.financial.dom.BankAccount)1 Organisation (org.estatio.module.party.dom.Organisation)1 Country (org.incode.module.country.dom.impl.Country)1