Search in sources :

Example 46 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class Property_vacantUnits_Test method vacant_Units_works.

@Test
public void vacant_Units_works() throws Exception {
    // given
    Property property = new Property();
    Unit unit1 = new Unit();
    Unit unit2 = new Unit();
    Property_vacantUnits mixin = new Property_vacantUnits(property);
    mixin.unitRepository = mockUnitRepository;
    mixin.occupancyRepository = mockOccupancyRepository;
    mixin.clockService = mockClockService;
    LocalDate now = new LocalDate(2017, 01, 01);
    // expect
    context.checking(new Expectations() {

        {
            allowing(mockOccupancyRepository).findByProperty(property);
            oneOf(mockUnitRepository).findByProperty(property);
            will(returnValue(Arrays.asList(unit1, unit2)));
        }
    });
    // when
    List<Unit> expectedVacantUnits = mixin.$$();
    // then
    Assertions.assertThat(expectedVacantUnits.size()).isEqualTo(2);
    // and expect
    context.checking(new Expectations() {

        {
            allowing(mockOccupancyRepository).findByProperty(property);
            oneOf(mockUnitRepository).findByProperty(property);
            will(returnValue(Arrays.asList(unit1, unit2)));
            oneOf(mockClockService).now();
            will(returnValue(now));
        }
    });
    // when
    unit1.setEndDate(now.plusDays(1));
    expectedVacantUnits = mixin.$$();
    // then
    Assertions.assertThat(expectedVacantUnits.size()).isEqualTo(2);
    // and expect
    context.checking(new Expectations() {

        {
            allowing(mockOccupancyRepository).findByProperty(property);
            oneOf(mockUnitRepository).findByProperty(property);
            will(returnValue(Arrays.asList(unit1, unit2)));
            oneOf(mockClockService).now();
            will(returnValue(now));
        }
    });
    // when
    unit1.setEndDate(now);
    expectedVacantUnits = mixin.$$();
    // then
    Assertions.assertThat(expectedVacantUnits.size()).isEqualTo(1);
    Assertions.assertThat(expectedVacantUnits).doesNotContain(unit1);
}
Also used : Expectations(org.jmock.Expectations) Unit(org.estatio.module.asset.dom.Unit) Property(org.estatio.module.asset.dom.Property) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 47 with Property

use of org.estatio.module.asset.dom.Property in project estatio by estatio.

the class EstatioApplicationTenancyRepositoryForLease_Test method testPathForPartyProperty.

@Test
public void testPathForPartyProperty() throws Exception {
    // given
    final Property p = propertyWith("ITA", "GRA");
    final Party pa = partyWith("HELLO");
    // then
    assertThat(estatioApplicationTenancyRepositoryForLease.pathFor(p, pa)).isEqualTo("/ITA/GRA/HELLO");
}
Also used : Party(org.estatio.module.party.dom.Party) Property(org.estatio.module.asset.dom.Property) EstatioApplicationTenancyRepositoryForProperty(org.estatio.module.asset.dom.EstatioApplicationTenancyRepositoryForProperty) Test(org.junit.Test)

Aggregations

Property (org.estatio.module.asset.dom.Property)47 LocalDate (org.joda.time.LocalDate)19 Test (org.junit.Test)19 Party (org.estatio.module.party.dom.Party)12 BudgetItem (org.estatio.module.budget.dom.budgetitem.BudgetItem)11 Programmatic (org.apache.isis.applib.annotation.Programmatic)10 Budget (org.estatio.module.budget.dom.budget.Budget)8 InvoiceForLease (org.estatio.module.lease.dom.invoicing.InvoiceForLease)8 BigDecimal (java.math.BigDecimal)7 List (java.util.List)6 Charge (org.estatio.module.charge.dom.Charge)6 Lease (org.estatio.module.lease.dom.Lease)6 InvoiceItemForLease (org.estatio.module.lease.dom.invoicing.InvoiceItemForLease)6 Expectations (org.jmock.Expectations)6 Before (org.junit.Before)6 Unit (org.estatio.module.asset.dom.Unit)5 Project (org.estatio.module.capex.dom.project.Project)5 Organisation (org.estatio.module.party.dom.Organisation)5 BudgetItemValue (org.estatio.module.budget.dom.budgetitem.BudgetItemValue)4 BankAccount (org.estatio.module.financial.dom.BankAccount)4