public void shouldCloseProductInstance()

in component-test/src/main/java/org/apache/fineract/cn/deposit/TestProductInstance.java [102:128]


  public void shouldCloseProductInstance() throws Exception {
    final ProductDefinition productDefinition = Fixture.productDefinition();
    super.depositAccountManager.create(productDefinition);

    super.eventRecorder.wait(EventConstants.POST_PRODUCT_DEFINITION, productDefinition.getIdentifier());

    final ProductInstance productInstance = Fixture.productInstance(productDefinition.getIdentifier());
    final String openedOn = "2013-05-08";
    productInstance.setOpenedOn(openedOn);

    super.depositAccountManager.create(productInstance);

    super.eventRecorder.wait(EventConstants.POST_PRODUCT_INSTANCE, productInstance.getCustomerIdentifier());

    final List<ProductInstance> productInstances = super.depositAccountManager.findProductInstances(productDefinition.getIdentifier());
    Assert.assertNotNull(productInstances);
    Assert.assertEquals(1, productInstances.size());
    final ProductInstance foundProductInstance = productInstances.get(0);
    Assert.assertEquals(openedOn, foundProductInstance.getOpenedOn());

    super.depositAccountManager.postProductInstanceCommand(
        foundProductInstance.getAccountIdentifier(), EventConstants.CLOSE_PRODUCT_INSTANCE_COMMAND);

    Assert.assertTrue(
        super.eventRecorder.wait(EventConstants.CLOSE_PRODUCT_INSTANCE,
            foundProductInstance.getAccountIdentifier()));
  }