Example usage for java.math BigDecimal TEN

List of usage examples for java.math BigDecimal TEN

Introduction

In this page you can find the example usage for java.math BigDecimal TEN.

Prototype

BigDecimal TEN

To view the source code for java.math BigDecimal TEN.

Click Source Link

Document

The value 10, with a scale of 0.

Usage

From source file:org.dhatim.fastexcel.Correctness.java

@Test
public void singleWorksheet() throws Exception {
    String sheetName = "Worksheet 1";
    String stringValue = "Sample text with chars to escape : < > & \\ \" ' ~        ";
    Date dateValue = new Date();
    LocalDateTime localDateTimeValue = LocalDateTime.now();
    ZoneId timezone = ZoneId.of("Australia/Sydney");
    ZonedDateTime zonedDateValue = ZonedDateTime.ofInstant(dateValue.toInstant(), timezone);
    double doubleValue = 1.234;
    int intValue = 2_016;
    long longValue = 2_016_000_000_000L;
    BigDecimal bigDecimalValue = BigDecimal.TEN;
    byte[] data = writeWorkbook(wb -> {
        Worksheet ws = wb.newWorksheet(sheetName);
        int i = 1;
        ws.value(i, i++, stringValue);/*from w ww.  ja  v a  2 s  .c  o m*/
        ws.value(i, i++, dateValue);
        ws.value(i, i++, localDateTimeValue);
        ws.value(i, i++, zonedDateValue);
        ws.value(i, i++, doubleValue);
        ws.value(i, i++, intValue);
        ws.value(i, i++, longValue);
        ws.value(i, i++, bigDecimalValue);
        try {
            ws.finish();
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    });

    // Check generated workbook with Apache POI
    XSSFWorkbook xwb = new XSSFWorkbook(new ByteArrayInputStream(data));
    assertThat(xwb.getActiveSheetIndex()).isEqualTo(0);
    assertThat(xwb.getNumberOfSheets()).isEqualTo(1);
    XSSFSheet xws = xwb.getSheet(sheetName);
    @SuppressWarnings("unchecked")
    Comparable<XSSFRow> row = (Comparable) xws.getRow(0);
    assertThat(row).isNull();
    int i = 1;
    assertThat(xws.getRow(i).getCell(i++).getStringCellValue()).isEqualTo(stringValue);
    assertThat(xws.getRow(i).getCell(i++).getDateCellValue()).isEqualTo(dateValue);
    // Check zoned timestamps have the same textual representation as the Dates extracted from the workbook
    // (Excel date serial numbers do not carry timezone information)
    assertThat(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(ZonedDateTime
            .ofInstant(xws.getRow(i).getCell(i++).getDateCellValue().toInstant(), ZoneId.systemDefault())))
                    .isEqualTo(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(localDateTimeValue));
    assertThat(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(ZonedDateTime
            .ofInstant(xws.getRow(i).getCell(i++).getDateCellValue().toInstant(), ZoneId.systemDefault())))
                    .isEqualTo(DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(zonedDateValue));
    assertThat(xws.getRow(i).getCell(i++).getNumericCellValue()).isEqualTo(doubleValue);
    assertThat(xws.getRow(i).getCell(i++).getNumericCellValue()).isEqualTo(intValue);
    assertThat(xws.getRow(i).getCell(i++).getNumericCellValue()).isEqualTo(longValue);
    assertThat(new BigDecimal(xws.getRow(i).getCell(i++).getRawValue())).isEqualTo(bigDecimalValue);
}

From source file:org.voltdb.TestParameterSet.java

public void testNullInObjectArray() throws IOException {
    // This test passes nulls and VoltType nulls in Object[] arrays where the arrays contain
    // all supported datatypes (with the exception that we currently don't support Timestamp or varbinary in Object arrays).
    // Each Object[] type passes in "null" and the VoltType Null equivalent.  Note that Object[] containing Strings will
    // support null and VoltType nulls as array elements.  But any other Sigil type class (big decimal, timestamp, varbinary)
    // DO NOT support nulls or VoltType nulls in Object[] arrays.

    Object o_array[] = null;//from ww  w . j av a2  s.c om
    ParameterSet p1 = null;
    Object first_param[] = null;
    boolean failed = false;

    // SHOULD FAIL: Object array of nulls
    o_array = new Object[] { null, null, null };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // SHOULD SUCCEED: Empty Object array of null
    o_array = new Object[] {};
    p1 = ParameterSet.fromArrayNoCopy(new Object[] {});
    first_param = p1.toArray();
    assertEquals(first_param.length, p1.toArray().length);

    // SHOULD SUCCEED: Object array of Strings - pass null
    o_array = new Object[] { "Null", null, "not null" };
    p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    first_param = p1.toArray();
    assertEquals(first_param.length, p1.toArray().length);

    // SHOULD SUCCEED: Object array of Strings - pass VoltType null
    o_array = new Object[] { "Null", VoltType.NULL_STRING_OR_VARBINARY, "not null" };
    p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    first_param = p1.toArray();
    assertEquals(first_param.length, p1.toArray().length);

    // SHOULD FAIL: Object array of BigDecimal - pass both null
    o_array = new Object[] { BigDecimal.ONE, null, BigDecimal.TEN };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // SHOULD FAIL: Object array of BigDecimal - pass both VoltType null
    o_array = new Object[] { BigDecimal.ONE, VoltType.NULL_DECIMAL, BigDecimal.TEN };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // SHOULD FAIL: Object array of Byte - pass null
    o_array = new Object[] { new Byte((byte) 3), null, new Byte((byte) 15) };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // SHOULD SUCCEED: Object array of Byte - pass VoltType null
    o_array = new Object[] { new Byte((byte) 3), VoltType.NULL_TINYINT, new Byte((byte) 15) };
    p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    first_param = p1.toArray();
    assertEquals(first_param.length, p1.toArray().length);

    // SHOULD FAIL: Object array of Short - pass null
    o_array = new Object[] { new Short((short) 3), null, new Short((short) 15) };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // SHOULD SUCCEED: Object array of Short - pass VoltType null
    o_array = new Object[] { new Short((short) 3), VoltType.NULL_SMALLINT, new Short((short) 15) };
    p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    first_param = p1.toArray();
    assertEquals(first_param.length, p1.toArray().length);

    // SHOULD FAIL: Object array of Integer - pass null
    o_array = new Object[] { new Integer(3), null, new Integer(15) };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // SHOULD SUCCEED: Integer array, pass VoltType null
    o_array = new Object[] { new Integer(3), VoltType.NULL_SMALLINT, new Integer(15) };
    p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    first_param = p1.toArray();
    assertEquals(first_param.length, p1.toArray().length);

    // SHOULD FAIL: Object array of Long - pass null
    o_array = new Object[] { new Long(3), null };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // SHOULD SUCCEED: Object array of Long - pass VoltType null
    o_array = new Object[] { VoltType.NULL_BIGINT, new Long(15) };
    p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    first_param = p1.toArray();
    assertEquals(first_param.length, p1.toArray().length);

    // SHOULD FAIL: Object array of Float - pass null
    o_array = new Object[] { null, new Double(3.1415) };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // SHOULD SUCCEED: Object array of Float - pass VoltType null
    o_array = new Object[] { new Double(3.1415), VoltType.NULL_FLOAT };
    p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    first_param = p1.toArray();
    assertEquals(first_param.length, p1.toArray().length);

    // SHOULD FAIL: Object array of Decimal - pass null
    o_array = new Object[] { new Double(3.1415), null, new Double(3.1415) };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // Object array of Timestamp - pass both null and VoltType null
    // Currently not supported
    o_array = new Object[] { new org.voltdb.types.TimestampType(123432), null,
            new org.voltdb.types.TimestampType(1233) };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // SHOULD FAIL: not supported
    o_array = new Object[] { new org.voltdb.types.TimestampType(123432), VoltType.NULL_TIMESTAMP,
            new org.voltdb.types.TimestampType(1233) };
    failed = false;
    try {
        p1 = ParameterSet.fromArrayNoCopy(o_array, 1);
    } catch (Exception ex) {
        failed = true;
    }
    assert (failed);

    // Object array of varbinary (byte array) - pass both null and VoltType null

    // Currently not supported
}

From source file:alfio.manager.system.DataMigratorIntegrationTest.java

@Test
public void testMigrationWithExistingRecord() {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()),
            new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "",
            false, null, null, null, null, null));
    Pair<Event, String> eventUsername = initEvent(categories);
    Event event = eventUsername.getKey();

    try {/*from w  ww .j a  v a 2 s  . c om*/
        eventMigrationRepository.insertMigrationData(event.getId(), "1.4",
                ZonedDateTime.now(ZoneId.of("UTC")).minusDays(1), EventMigration.Status.COMPLETE.toString());
        eventRepository.updatePrices("CHF", 40, false, BigDecimal.ONE, "STRIPE", event.getId(),
                PriceContainer.VatStatus.NOT_INCLUDED, 1000);
        dataMigrator.migrateEventsToCurrentVersion();
        EventMigration eventMigration = eventMigrationRepository.loadEventMigration(event.getId());
        assertNotNull(eventMigration);
        //assertEquals(buildTimestamp, eventMigration.getBuildTimestamp().toString());
        assertEquals(currentVersion, eventMigration.getCurrentVersion());

        List<Ticket> tickets = ticketRepository.findFreeByEventId(event.getId());
        assertNotNull(tickets);
        assertFalse(tickets.isEmpty());
        assertEquals(20, tickets.size());
        assertTrue(tickets.stream().allMatch(t -> t.getCategoryId() == null));
    } finally {
        eventManager.deleteEvent(event.getId(), eventUsername.getValue());
    }
}

From source file:alfio.manager.AdminReservationManagerIntegrationTest.java

@Test
public void testReserveFromExistingCategoryNotEnoughSeatsNoExtensionAllowedNotBounded() throws Exception {
    List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null,
            "default", AVAILABLE_SEATS, new DateTimeModification(LocalDate.now(), LocalTime.now()),
            new DateTimeModification(LocalDate.now(), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "",
            false, null, null, null, null, null));
    performExistingCategoryTest(categories, true, Collections.singletonList(AVAILABLE_SEATS + 1), false, false,
            0, AVAILABLE_SEATS);// w  w  w .ja v  a2 s . co m
}

From source file:org.openhab.binding.denonmarantz.internal.connector.telnet.DenonMarantzTelnetConnector.java

private BigDecimal fromDenonValue(String string) {
    /*/*ww  w. jav a2  s .  co m*/
     * 455 = 45,5
     * 45 = 45
     * 045 = 4,5
     * 04 = 4
     */
    BigDecimal value = new BigDecimal(string);
    if (value.compareTo(NINETYNINE) == 1 || (string.startsWith("0") && string.length() > 2)) {
        value = value.divide(BigDecimal.TEN);
    }
    return value;
}

From source file:org.mifos.framework.components.batchjobs.helpers.BranchReportClientSummaryHelperIntegrationTest.java

private CustomerBusinessService getCustomerBusinessServiceStub() {
    return new CustomerBusinessService() {

        @Override/*w ww. j  av  a 2s . c o m*/
        public Integer getActiveBorrowersCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getActiveClientCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getActiveSaversCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getCustomerReplacementsCountForOffice(OfficeBO office, Short fieldId, String fieldValue)
                throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getCustomerVeryPoorReplacementsCountForOffice(OfficeBO office, Short fieldId,
                String fieldValue) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getDropOutClientsCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public BigDecimal getClientDropOutRateForOffice(OfficeBO office) throws ServiceException {
            return BigDecimal.valueOf(1.34);
        }

        @Override
        public Integer getGroupCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getOnHoldClientsCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getVeryPoorActiveBorrowersCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getVeryPoorActiveSaversCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getVeryPoorClientCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getVeryPoorDropOutClientsCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getVeryPoorOnHoldClientsCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getCenterCountForOffice(OfficeBO office) throws ServiceException {
            return ONE;
        }

        @Override
        public Integer getDormantClientsCountByLoanAccountForOffice(OfficeBO office, Integer loanCyclePeriod)
                throws ServiceException {
            return TEN;
        }

        @Override
        public Integer getVeryPoorDormantClientsCountByLoanAccountForOffice(OfficeBO office,
                Integer loanCyclePeriod) throws ServiceException {
            return FIVE;
        }

        @Override
        public BigDecimal getVeryPoorClientDropoutRateForOffice(OfficeBO office) throws ServiceException {
            return BigDecimal.TEN;
        }

        @Override
        public Integer getVeryPoorDormantClientsCountBySavingAccountForOffice(OfficeBO office,
                Integer loanCyclePeriod) throws ServiceException {
            return FIVE;
        }

        @Override
        public Integer getDormantClientsCountBySavingAccountForOffice(OfficeBO office, Integer loanCyclePeriod)
                throws ServiceException {
            return TEN;
        }
    };
}

From source file:io.coala.time.TimeSpan.java

/**
 * Parse duration as {@link DecimalMeasure JSR-275} measure (e.g.
 * {@code "123 ms"}) or as ISO Period with
 * {@link org.threeten.bp.Duration#parse(CharSequence) JSR-310} or
 * {@link Period#parse(String) Joda}./*from w  w w . jav a  2  s. co  m*/
 * 
 * Examples of ISO period:
 * 
 * <pre>
 *    "PT20.345S" -> parses as "20.345 seconds"
 *    "PT15M"     -> parses as "15 minutes" (where a minute is 60 seconds)
 *    "PT10H"     -> parses as "10 hours" (where an hour is 3600 seconds)
 *    "P2D"       -> parses as "2 days" (where a day is 24 hours or 86400 seconds)
 *    "P2DT3H4M"  -> parses as "2 days, 3 hours and 4 minutes"
 *    "P-6H3M"    -> parses as "-6 hours and +3 minutes"
 *    "-P6H3M"    -> parses as "-6 hours and -3 minutes"
 *    "-P-6H+3M"  -> parses as "+6 hours and -3 minutes"
 * </pre>
 * 
 * @param measure the {@link String} representation of a duration
 * @return
 * 
 * @see org.threeten.bp.Duration#parse(String)
 * @see org.joda.time.format.ISOPeriodFormat#standard()
 * @see DecimalMeasure
 */
protected static final Measure<BigDecimal, Duration> parsePeriodOrMeasure(final String measure) {
    if (measure == null)
        return null;//throw new NullPointerException();
    DecimalMeasure<Duration> result;
    try {
        result = DecimalMeasure.valueOf(measure + " ");
        // LOG.trace("Parsed '{}' as JSR-275 measure/unit: {}", measure,
        // result);
        return result;
    } catch (final Exception a) {
        // LOG.trace("JSR-275 failed, try JSR-310", e);
        try {
            // final long millis = Period.parse(measure).getMillis();
            // return DecimalMeasure.valueOf(BigDecimal.valueOf(millis),
            // SI.MILLI(SI.SECOND));
            final java.time.Duration temp = java.time.Duration.parse(measure);
            result = temp.getNano() == 0
                    ? DecimalMeasure.valueOf(BigDecimal.valueOf(temp.getSeconds()), SI.SECOND)
                    : DecimalMeasure.valueOf(BigDecimal.valueOf(temp.getSeconds())
                            .multiply(BigDecimal.TEN.pow(9)).add(BigDecimal.valueOf(temp.getNano())),
                            Units.NANOS);
            // LOG.trace(
            // "Parsed '{}' using JSR-310 to JSR-275 measure/unit: {}",
            // measure, result);
            return result;
        } catch (final Exception e) {
            // LOG.trace("JSR-275 and JSR-310 failed, try Joda", e);
            try {
                final Period joda = Period.parse(measure);
                result = DecimalMeasure.valueOf(BigDecimal.valueOf(joda.toStandardDuration().getMillis()),
                        Units.MILLIS);
                // LOG.trace(
                // "Parsed '{}' using Joda to JSR-275 measure/unit: {}",
                // measure, result);
                return result;
            } catch (final Exception j) {
                return Thrower.throwNew(IllegalArgumentException.class,
                        "Could not parse duration or period from: {}"
                                + ", JSR-275: {}, JSR-310: {}, Joda-time: {}",
                        measure, a.getMessage(), e.getMessage(), j.getMessage());
            }
        }
    }
}

From source file:fragment.web.AdminControllerTest.java

@Test
public void testEditCreditExposurePost() throws Exception {
    AccountType expected = accountTypeService.locateAccountTypeName("Retail");
    expected.getAccountTypeCreditExposureList().get(0).setCreditExposureLimit(BigDecimal.TEN);
    AccountTypeForm form = new AccountTypeForm(expected);
    BindingResult result = validate(form);
    String view = controller.editcreditexposure(form, result, map);
    Assert.assertEquals("success", view);
    AccountType found = accountTypeService.locateAccountTypeName("Retail");
    BigDecimal bd = BigDecimal.TEN;
    bd = bd.setScale(4);/*w  w w. j av a  2 s  .c  om*/
    Assert.assertEquals(found.getAccountTypeCreditExposureList().get(0).getCreditExposureLimit(), bd);
}

From source file:de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImplTest.java

/**
 * Test method for {@link de.iteratec.iteraplan.businesslogic.service.legacyExcel.ExcelAttributesImportServiceImpl#importAttributes(java.io.InputStream, java.io.PrintWriter)}.
 * @throws IOException if the test Excel file will be not found
 *//* w ww. j a  v a  2s. c o  m*/
@SuppressWarnings("boxing")
@Test
public void testImportAttributesNumber() throws IOException {
    PrintWriter logWriter = new PrintWriter(new NullOutputStream());
    Resource excel = new ClassPathResource(EXCEL_TEST_FILES + "numberAttributesTest.xls");

    excelAttributesImportService.importAttributes(excel.getInputStream(), logWriter);
    commit();
    beginTransaction();

    NumberAT numberAt1 = (NumberAT) attributeTypeService.getAttributeTypeByName("NumberAt1");
    assertNotNull(numberAt1);
    assertEquals("NumberAt1 description", numberAt1.getDescription());
    assertFalse(numberAt1.isMandatory());
    assertEquals(BigDecimal.TEN, numberAt1.getMinValue());
    assertEquals(new BigDecimal(20), numberAt1.getMaxValue());
    assertEquals("Euro", numberAt1.getUnit());
    assertEquals(true, numberAt1.isRangeUniformyDistributed());

    NumberAT numberAt2 = (NumberAT) attributeTypeService.getAttributeTypeByName("NumberAt2");
    assertNotNull(numberAt2);
    assertEquals("NumberAt2 description", numberAt2.getDescription());
    assertTrue(numberAt2.isMandatory());
    assertNull(numberAt2.getMinValue());
    assertNull(numberAt2.getMaxValue());
    assertEquals("a", numberAt2.getUnit());
    assertEquals(false, numberAt2.isRangeUniformyDistributed());

    NumberAT numberAt3 = (NumberAT) attributeTypeService.getAttributeTypeByName("NumberAt3");
    assertNotNull(numberAt3);
    assertEquals(BigDecimal.TEN, numberAt3.getMinValue());
    assertEquals(BigDecimal.TEN, numberAt3.getMaxValue());

    NumberAT numberAt4 = (NumberAT) attributeTypeService.getAttributeTypeByName("NumberAt4");
    assertNotNull(numberAt4);
    assertNull(numberAt4.getMinValue());
    assertNull(numberAt4.getMaxValue());
}

From source file:org.apache.olingo.fit.proxy.v4.EntityCreateTestITCase.java

@Test
public void createWithBackNavigation() {
    final Integer id = 102;

    // -------------------------------
    // Create a new order
    // -------------------------------
    Order order = getContainer().newEntityInstance(Order.class);
    order.setOrderID(id);//from   www.  j  av a  2s.  c  o  m

    final Calendar orderDate = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    orderDate.clear();
    orderDate.set(2011, 3, 4, 16, 3, 57);
    order.setOrderDate(new Timestamp(orderDate.getTimeInMillis()));

    order.setShelfLife(BigDecimal.TEN);

    PrimitiveCollection<BigDecimal> osl = getContainer().newPrimitiveCollection(BigDecimal.class);
    osl.add(BigDecimal.TEN.negate());
    osl.add(BigDecimal.TEN);
    order.setOrderShelfLifes(osl);
    // -------------------------------

    // -------------------------------
    // Create a new customer
    // -------------------------------
    final Customer customer = getContainer().newEntityInstance(Customer.class);
    customer.setPersonID(id);
    customer.setPersonID(id);
    customer.setFirstName("Fabio");
    customer.setLastName("Martelli");
    customer.setCity("Pescara");

    PrimitiveCollection<String> value = getContainer().newPrimitiveCollection(String.class);
    value.add("fabio.martelli@tirasa.net");
    customer.setEmails(value);

    final Address homeAddress = getContainer().newComplexInstance(HomeAddress.class);
    homeAddress.setCity("Pescara");
    homeAddress.setPostalCode("65100");
    homeAddress.setStreet("viale Gabriele D'Annunzio 256");
    customer.setHomeAddress(homeAddress);

    value = getContainer().newPrimitiveCollection(String.class);
    value.add("3204725072");
    value.add("08569930");
    customer.setNumbers(value);

    final OrderCollection orders = getContainer().newEntityCollection(OrderCollection.class);
    orders.add(order);
    customer.setOrders(orders);
    // -------------------------------

    // -------------------------------
    // Link customer to order
    // -------------------------------
    order.setCustomerForOrder(customer);
    // -------------------------------

    getContainer().getOrders().add(order);
    getContainer().flush();

    assertEquals(id, order.getOrderID());
    assertEquals(id, customer.getPersonID());

    Customer actual = readCustomer(getContainer(), id);
    assertEquals(homeAddress.getCity(), actual.getHomeAddress().getCity());
    assertEquals(1, actual.getOrders().execute().size());
    assertEquals(id, actual.getOrders().iterator().next().getOrderID());

    order = getContainer().getOrders().getByKey(id);
    assertNotNull(order);
    assertEquals(id, order.getCustomerForOrder().load().getPersonID());

    getContainer().getOrders().delete(actual.getOrders());
    getContainer().flush();

    try {
        getContainer().getOrders().getByKey(id).load();
        fail();
    } catch (IllegalArgumentException e) {
    }

    actual = readCustomer(getContainer(), id);
    assertTrue(actual.getOrders().isEmpty());

    getContainer().getCustomers().delete(actual.getPersonID());
    getContainer().flush();

    try {
        getContainer().getCustomers().getByKey(id).load();
        fail();
    } catch (IllegalArgumentException e) {
    }
}