Example usage for java.math BigDecimal ONE

List of usage examples for java.math BigDecimal ONE

Introduction

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

Prototype

BigDecimal ONE

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

Click Source Link

Document

The value 1, with a scale of 0.

Usage

From source file:com.iisigroup.cap.report.AbstractReportExcelService.java

@SuppressWarnings("unchecked")
@Override/*from  w  w  w .ja v a  2  s .c  o m*/
public ByteArrayOutputStream generateReport(Request request) throws CapException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Workbook t = null;
    try {
        t = readTemplate();
        // Define the cell format
        // ??
        NumberFormat nf = new NumberFormat("#,##0_");
        // ??
        NumberFormat nf2 = new NumberFormat("#,##0.00");
        // ?
        WritableFont titleWf = new WritableFont(WritableFont.createFont(""), 12);
        // WritableFont titleWf = new WritableFont(WritableFont.createFont("DFKai-sb"),12);
        WritableCellFormat timesString = new WritableCellFormat(defaultFont);
        WritableCellFormat timesNumber = new WritableCellFormat(nf);
        WritableCellFormat timesDouble = new WritableCellFormat(nf2);
        timesNumber.setFont(titleWf);
        timesDouble.setFont(titleWf);
        // 
        timesNumber.setAlignment(Alignment.RIGHT);
        timesDouble.setAlignment(Alignment.CENTRE);
        timesString.setAlignment(Alignment.CENTRE);
        // 
        timesNumber.setVerticalAlignment(VerticalAlignment.CENTRE);
        timesDouble.setVerticalAlignment(VerticalAlignment.CENTRE);
        timesString.setVerticalAlignment(VerticalAlignment.CENTRE);
        // 
        timesNumber.setBorder(Border.ALL, BorderLineStyle.THIN, Colour.BLACK);
        timesDouble.setBorder(Border.BOTTOM, BorderLineStyle.THIN, Colour.BLACK);
        // Lets automatically wrap the cells
        timesNumber.setWrap(true);
        timesDouble.setWrap(true);
        timesString.setWrap(true);
        Map<String, Object> reportData = execute(request);
        WorkbookSettings wbSettings = new WorkbookSettings();
        wbSettings.setRationalization(false);
        wbSettings.setLocale(new Locale("zh", "TW"));
        WritableWorkbook workbook = Workbook.createWorkbook(out, t, wbSettings);
        WritableSheet sheet = workbook.getSheet(0);
        // ?
        for (Entry<String, Object> entry : reportData.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            if (!key.endsWith(OFFSET_SUFFIX) && !key.endsWith(POSITION_SUFFIX)) {
                // it's data
                int[] pos = (int[]) reportData.get(key + POSITION_SUFFIX);
                if (pos != null) {
                    int x = pos[0];
                    int y = pos[1];
                    if (value instanceof List) {
                        // grid data
                        JsonObject offset = (JsonObject) reportData.get(key + OFFSET_SUFFIX);
                        List<Map<String, Object>> l = (List<Map<String, Object>>) value;
                        for (Map<String, Object> m : l) {
                            for (Entry<String, Object> e : m.entrySet()) {
                                if (offset.get(e.getKey()) != null) {
                                    String cellVal = "";
                                    if (e.getValue() != null) {
                                        if (e.getValue() instanceof Timestamp) {
                                            cellVal = CapDate.convertDateTimeFromF1ToF2(
                                                    CapDate.getDateTimeFormat((Timestamp) e.getValue()),
                                                    "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd");
                                        } else {
                                            cellVal = e.getValue().toString();
                                        }
                                    }
                                    Label label = new Label(x + offset.get(e.getKey()).getAsInt(), y, cellVal,
                                            timesString);
                                    sheet.addCell(label);
                                }
                            }
                            y++;
                        }
                    } else {
                        if (value instanceof BigDecimal) {

                            jxl.write.Number number = new jxl.write.Number(x, y,
                                    ((BigDecimal) value).doubleValue(), timesNumber);

                            // ??
                            if (!((BigDecimal) value).divideAndRemainder(new BigDecimal(2))[1]
                                    .equals(BigDecimal.ZERO)
                                    && !((BigDecimal) value).divideAndRemainder(new BigDecimal(2))[1]
                                            .equals(BigDecimal.ONE)) {
                                number = new jxl.write.Number(x, y, ((BigDecimal) value).doubleValue(),
                                        timesDouble);
                            }

                            sheet.addCell(number);
                        } else if (value instanceof Integer) {
                            jxl.write.Number number = new jxl.write.Number(x, y, (Integer) value, timesNumber);
                            sheet.addCell(number);
                        } else {
                            Label label = new Label(x, y, (String) value, timesString);
                            sheet.addCell(label);
                        }
                    }
                }
            }
        }
        workbook.write();
        workbook.close();
        IOUtils.closeQuietly(out);
    } catch (Exception e) {
        e.printStackTrace();
        if (e.getCause() != null) {
            throw new CapException(e.getCause(), e.getClass());
        } else {
            throw new CapException(e, e.getClass());
        }
    } finally {
        if (t != null) {
            t.close();
        }
    }
    return out;
}

From source file:org.openvpms.web.workspace.workflow.checkin.CheckInWorkflowTestCase.java

/**
 * Verifies that a new patient can be created if the appointment doesn't have one.
 *///from  ww w.  j a  va2  s .  c  o m
@Test
public void testCreatePatient() {
    Act appointment = createAppointment(customer, null, clinician);
    CheckInWorkflowRunner workflow = new CheckInWorkflowRunner(appointment, getPractice(), context);
    workflow.setWorkList(workList); // need to pre-set work list so it can be selected in popup
    workflow.start();

    // create the new patient
    BrowserDialog<Party> dialog = workflow.getSelectionDialog();
    fireDialogButton(dialog, BrowserDialog.NEW_ID);
    EditDialog editDialog = workflow.editPatient("Fluffy");
    Party newPatient = (Party) editDialog.getEditor().getObject();
    fireDialogButton(editDialog, PopupDialog.OK_ID);

    // verify the patient has been created and is owned by the customer
    workflow.checkPatient(newPatient, customer);

    workflow.selectWorkList(workList, customer, newPatient);

    workflow.addWeight(newPatient, BigDecimal.ONE, clinician);

    workflow.printPatientDocuments(PopupDialog.SKIP_ID);

    PopupDialog eventDialog = workflow.editVisit();
    fireDialogButton(eventDialog, PopupDialog.OK_ID);
    workflow.checkEvent(newPatient, clinician, ActStatus.IN_PROGRESS);

    workflow.checkComplete(true, customer, newPatient, context);
}

From source file:org.openvpms.archetype.rules.supplier.OrderGeneratorTestCase.java

/**
 * Verifies that inactive products, or products with inactive product-supplier or product-stock location
 * relationships are ignored.//from  w w  w  .ja va  2s  . c o  m
 */
@Test
public void testGetOrderableStockIgnoresInactiveProducts() {
    OrderGenerator generator = new OrderGenerator(taxRules, getArchetypeService());
    Party stockLocation = SupplierTestHelper.createStockLocation();
    Party supplier1 = TestHelper.createSupplier();
    Product product1 = TestHelper.createProduct();
    Product product2 = TestHelper.createProduct();
    Product product3 = TestHelper.createProduct();

    addRelationships(product1, stockLocation, supplier1, true, 1, 10, 6);
    ProductSupplier ps = addRelationships(product2, stockLocation, supplier1, true, 2, 10, 5);
    addProductSupplierRelationship(product3, supplier1, true, BigDecimal.ONE, 1);
    EntityRelationship er = addProductStockLocationRelationship(product3, stockLocation, null, 1, 10, 5);

    supplier1 = get(supplier1);
    List<Stock> stock = generator.getOrderableStock(supplier1, stockLocation, false);
    assertEquals(3, stock.size());
    checkStock(stock, product1, supplier1, stockLocation, 1, 0, 9);
    checkStock(stock, product2, supplier1, stockLocation, 2, 0, 8);
    checkStock(stock, product3, supplier1, stockLocation, 1, 0, 9);

    // disable product1, and verify product2 and product3 are returned
    product1.setActive(false);
    save(product1);
    stock = generator.getOrderableStock(supplier1, stockLocation, false);
    assertEquals(2, stock.size());
    checkStock(stock, product2, supplier1, stockLocation, 2, 0, 8);
    checkStock(stock, product3, supplier1, stockLocation, 1, 0, 9);

    // disable the product-supplier relationship for product2
    ps.setActiveEndTime(new Date(System.currentTimeMillis() - 1000));
    ps.save();
    stock = generator.getOrderableStock(supplier1, stockLocation, false);
    assertEquals(1, stock.size());
    checkStock(stock, product3, supplier1, stockLocation, 1, 0, 9);

    // disable the product-stock location relationship for product3
    er.setActiveEndTime(new Date(System.currentTimeMillis() - 1000));
    save(er);
    stock = generator.getOrderableStock(supplier1, stockLocation, false);
    assertEquals(0, stock.size());
}

From source file:org.openinfobutton.responder.controller.OpenInfobuttonResponderControllerTest.java

private List<Asset> getValidMockAssets() {

    List<Asset> assets = new ArrayList<Asset>();

    Asset asset = new Asset();
    asset.setAssetId(BigDecimal.ZERO);
    asset.setDisplayName("Test asset");
    asset.setNamespaceCd("TEST");
    asset.setAssetUrl("http://test.org/TEST");

    List<AssetProperty> assetProperties = new ArrayList<AssetProperty>();
    AssetProperty ap1 = new AssetProperty();
    ap1.setAssetPropertyId(BigDecimal.ZERO);
    ap1.setAsset(asset);/* w  w w  .jav  a2 s .c o  m*/
    ap1.setPropertyType("CODE");
    ap1.setPropertyName("mainSearchCriteria.v");
    ap1.setCode("47505003");
    ap1.setCodeSystem("2.16.840.1.113883.6.96");

    AssetProperty ap2 = new AssetProperty();
    ap2.setAssetPropertyId(BigDecimal.ONE);
    ap2.setAsset(asset);
    ap2.setPropertyType("CODE");
    ap2.setPropertyName("taskContext.c");
    ap2.setCode("PROBLISTREV");
    ap2.setCodeSystem("2.16.840.1.113883.5.4");

    assetProperties.add(ap1);
    assetProperties.add(ap2);
    asset.setAssetProperties(assetProperties);

    assets.add(asset);

    return assets;

}

From source file:pe.gob.mef.gescon.hibernate.impl.VinculoHistDaoImpl.java

@Override
public List<HashMap> getConcimientosVinculadosByHistorial(HashMap filters) throws Exception {
    String nhistorialid = (String) filters.get("nhistorialid");
    String nconocimientoid = (String) filters.get("nconocimientoid");
    String ntipoconocimientoid = (String) filters.get("ntipoconocimientoid");
    Boolean flag = (Boolean) filters.get("flag");
    Object object = null;/* w  w w  . jav a 2 s.com*/
    final StringBuilder sql = new StringBuilder();
    if (StringUtils.isNotBlank(ntipoconocimientoid)
            && (ntipoconocimientoid.equals("3") || ntipoconocimientoid.equals("4")
                    || ntipoconocimientoid.equals("5") || ntipoconocimientoid.equals("6"))) {
        sql.append("SELECT ");
        sql.append(
                "    a.nvinculohid as ID, a.nconocimientovinc as IDCONOCIMIENTO, '' AS NUMERO, b.vtitulo AS NOMBRE, b.vdescripcion AS SUMILLA, ");
        sql.append("    b.ncategoriaid AS IDCATEGORIA, c.vnombre AS CATEGORIA, b.dfechapublicacion AS FECHA, ");
        sql.append("    b.ntpoconocimientoid AS IDTIPOCONOCIMIENTO, e.vnombre AS TIPOCONOCIMIENTO, ");
        sql.append("    b.nsituacionid AS IDESTADO, d.vnombre AS ESTADO ");
        sql.append("FROM TVINCULO_HIST a ");
        sql.append("INNER JOIN TCONOCIMIENTO b ");
        sql.append("    INNER JOIN MTCATEGORIA c ON b.ncategoriaid = c.ncategoriaid ");
        sql.append("    INNER JOIN MTSITUACION d ON b.nsituacionid = d.nsituacionid ");
        sql.append("    INNER JOIN MTTIPO_CONOCIMIENTO e ON b.ntpoconocimientoid = e.ntpoconocimientoid ");
        sql.append("ON a.nconocimientovinc = b.nconocimientoid ");
        sql.append("AND a.ntipoconocimientovinc = b.ntpoconocimientoid ");
        sql.append("AND b.nactivo = :ACTIVO ");
        sql.append("WHERE a.nconocimientoid = ").append(nconocimientoid).append(" ");
        sql.append("AND a.nhistorialid = ").append(nhistorialid).append(" ");
        if (flag) {
            sql.append("AND a.ntipoconocimientovinc = ").append(ntipoconocimientoid).append(" ");
        }
        sql.append("ORDER BY 7 DESC ");
    }
    if (StringUtils.isNotBlank(ntipoconocimientoid) && ntipoconocimientoid.equals("2")) {
        sql.append("SELECT ");
        sql.append(
                "    a.nvinculohid as ID, a.nconocimientovinc as IDCONOCIMIENTO, '' AS NUMERO, b.vasunto AS NOMBRE , b.vdetalle AS SUMILLA, ");
        sql.append("    b.ncategoriaid AS IDCATEGORIA, c.vnombre AS CATEGORIA, b.dfechapublicacion AS FECHA, ");
        sql.append("    2 AS IDTIPOCONOCIMIENTO, 'Preguntas y Respuestas' AS TIPOCONOCIMIENTO, ");
        sql.append("    b.nsituacionid AS IDESTADO, d.vnombre AS ESTADO ");
        sql.append("FROM TVINCULO_HIST a ");
        sql.append("INNER JOIN TPREGUNTA b ");
        sql.append("    INNER JOIN MTCATEGORIA c ON b.ncategoriaid = c.ncategoriaid ");
        sql.append("    INNER JOIN MTSITUACION d ON b.nsituacionid = d.nsituacionid ");
        sql.append("ON a.nconocimientovinc = b.npreguntaid ");
        sql.append("AND a.ntipoconocimientovinc = 2 ");
        sql.append("AND b.nactivo = :ACTIVO ");
        sql.append("WHERE a.nconocimientoid = ").append(nconocimientoid).append(" ");
        sql.append("AND a.nhistorialid = ").append(nhistorialid).append(" ");
        sql.append("ORDER BY 7 DESC ");
    }
    if (StringUtils.isNotBlank(ntipoconocimientoid) && ntipoconocimientoid.equals("1")) {
        sql.append("SELECT ");
        sql.append(
                "    a.nvinculohid as ID, a.nconocimientovinc as IDCONOCIMIENTO, b.vnumero AS NUMERO, b.vnombre AS NOMBRE , b.vsumilla AS SUMILLA, ");
        sql.append("    b.ncategoriaid AS IDCATEGORIA, c.vnombre AS CATEGORIA, b.dfechapublicacion AS FECHA, ");
        sql.append("    1 AS IDTIPOCONOCIMIENTO, 'Base Legal' AS TIPOCONOCIMIENTO, ");
        sql.append("    b.nestadoid AS IDESTADO, d.vnombre AS ESTADO ");
        sql.append("FROM TVINCULO_HIST a ");
        sql.append("INNER JOIN TBASELEGAL b ");
        sql.append("    INNER JOIN MTCATEGORIA c ON b.ncategoriaid = c.ncategoriaid ");
        sql.append("    INNER JOIN MTESTADO_BASELEGAL d ON b.nestadoid = d.nestadoid ");
        sql.append("ON a.nconocimientovinc = b.nbaselegalid ");
        sql.append("AND a.ntipoconocimientovinc = 1 ");
        sql.append("AND b.nactivo = :ACTIVO ");
        sql.append("WHERE a.nconocimientoid = ").append(nconocimientoid).append(" ");
        sql.append("AND a.nhistorialid = ").append(nhistorialid).append(" ");
        sql.append("ORDER BY 7 DESC ");
    }
    try {
        object = getHibernateTemplate().execute(new HibernateCallback() {
            @Override
            public Object doInHibernate(Session session) throws HibernateException {
                Query query = session.createSQLQuery(sql.toString());
                query.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
                if (StringUtils.isNotBlank(sql.toString())) {
                    query.setParameter("ACTIVO", BigDecimal.ONE);
                }
                return query.list();
            }
        });
    } catch (Exception e) {
        e.getMessage();
        e.printStackTrace();
    }
    return (List<HashMap>) object;
}

From source file:pe.gob.mef.gescon.web.ui.EntidadMB.java

public void cleanAttributes() {
    this.setId(BigDecimal.ZERO);
    this.setDescripcion(StringUtils.EMPTY);
    this.setNombre(StringUtils.EMPTY);
    this.setCodigo(null);
    this.setActivo(BigDecimal.ONE);
    this.setSelectedEntidad(null);
    this.setListaProvincia(new ArrayList());
    this.setListaDistrito(new ArrayList());
    this.setListaTipoEntidad(new ArrayList());
    this.setDepartamento(StringUtils.EMPTY);
    this.setProvincia(StringUtils.EMPTY);
    this.setDistrito(StringUtils.EMPTY);
    this.setTipoentidad(StringUtils.EMPTY);
    Iterator<FacesMessage> iter = FacesContext.getCurrentInstance().getMessages();
    if (iter.hasNext() == true) {
        iter.remove();// w  ww .  ja v a 2  s.  co m
        FacesContext.getCurrentInstance().renderResponse();
    }
}

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  w w  .j a v a 2s  . c  o  m
        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:com.qcadoo.mes.technologies.TechnologyService.java

public void loadProductsForReferencedTechnology(final ViewDefinitionState viewDefinitionState,
        final ComponentState state, final String[] args) {
    if (!(state instanceof TreeComponent)) {
        return;/*from  w w  w  .j ava  2  s  . co m*/
    }

    TreeComponent tree = (TreeComponent) state;

    if (tree.getSelectedEntityId() == null) {
        return;
    }

    Entity technologyOperationComponent = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER,
            TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).get(tree.getSelectedEntityId());

    GridComponent outProductsGrid = (GridComponent) viewDefinitionState.getComponentByReference("outProducts");
    GridComponent inProductsGrid = (GridComponent) viewDefinitionState.getComponentByReference("inProducts");

    if (!TechnologyOperationComponentType.REFERENCE_TECHNOLOGY.getStringValue().equals(
            technologyOperationComponent.getStringField(TechnologyOperationComponentFields.ENTITY_TYPE))) {
        inProductsGrid.setEditable(true);
        outProductsGrid.setEditable(true);

        return;
    }

    Entity technology = technologyOperationComponent
            .getBelongsToField(TechnologyOperationComponentFields.REFERENCE_TECHNOLOGY);

    EntityTree operations = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
    Entity rootOperation = operations.getRoot();

    if (rootOperation != null) {
        outProductsGrid.setEntities(rootOperation
                .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS));
    }

    List<Entity> operationProductInComponents = Lists.newArrayList();

    Map<Long, BigDecimal> productQuantities = productQuantitiesService.getNeededProductQuantities(technology,
            BigDecimal.ONE, MrpAlgorithm.ALL_PRODUCTS_IN);

    for (Entry<Long, BigDecimal> productQuantity : productQuantities.entrySet()) {
        Entity product = productQuantitiesService.getProduct(productQuantity.getKey());

        Entity operationProductInComponent = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER,
                TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT).create();

        operationProductInComponent.setField(OperationProductInComponentFields.OPERATION_COMPONENT,
                rootOperation);
        operationProductInComponent.setField(OperationProductInComponentFields.PRODUCT, product);
        operationProductInComponent.setField(OperationProductInComponentFields.QUANTITY,
                productQuantity.getValue());

        operationProductInComponents.add(operationProductInComponent);
    }

    inProductsGrid.setEntities(operationProductInComponents);

    inProductsGrid.setEnabled(false);
    inProductsGrid.setEditable(false);
    outProductsGrid.setEnabled(false);
    outProductsGrid.setEditable(false);
}

From source file:org.cirdles.ambapo.UTMToLatLong.java

/**
 * /*w  w w .j  av a  2  s.com*/
 * @param eccentricity
 * @param currentTau
 * @param currentSigma
 * @return change in tau
 */
private static BigDecimal changeInTau(BigDecimal eccentricity, BigDecimal currentTau, BigDecimal currentSigma) {

    BigDecimal changeInTau = ((new BigDecimal(
            Math.sqrt((1 + currentSigma.pow(2).doubleValue()) * (1 + currentTau.pow(2).doubleValue()))))
                    .subtract(currentSigma.multiply(currentTau)))
                            .multiply(new BigDecimal(1 - eccentricity.pow(2).doubleValue()))
                            .multiply(new BigDecimal(Math.sqrt(1 + currentTau.pow(2).doubleValue())))
                            .divide(BigDecimal.ONE.add(BigDecimal.ONE.subtract(eccentricity.pow(2)))
                                    .multiply(currentTau.pow(2)), PRECISION, RoundingMode.HALF_UP);

    return changeInTau;

}

From source file:com.opengamma.web.analytics.blotter.OtcTradeBuilderTest.java

@Test
public void newSecurityWithOtcUnderlying() {
    UniqueId tradeId = _builder.addTrade(createTradeData(), BlotterTestUtils.SWAPTION_DATA_SOURCE,
            BlotterTestUtils.SWAP_DATA_SOURCE, _nodeId);
    ManageableTrade trade = _positionMaster.getTrade(tradeId);
    UniqueId positionId = trade.getParentPositionId();
    ManageablePosition position = _positionMaster.get(positionId).getPosition();
    assertEquals(BigDecimal.ONE, trade.getQuantity());
    assertEquals(BigDecimal.ONE, position.getQuantity());
    SwaptionSecurity security = (SwaptionSecurity) _securityMaster
            .get(trade.getSecurityLink().getObjectId(), VersionCorrection.LATEST).getSecurity();
    assertNotNull(security);/* www  .j  a va  2s.  c om*/
    // check this later
    ExternalId underlyingId = security.getUnderlyingId();
    security.setUniqueId(null); // so it can be tested for equality against the unsaved version
    security.setUnderlyingId(BlotterTestUtils.SWAPTION.getUnderlyingId()); // will need this later
    assertEquals(BlotterTestUtils.SWAPTION, security);
    assertEquals(COUNTERPARTY_ID, trade.getCounterpartyExternalId());
    assertEquals(PREMIUM, trade.getPremium());
    assertEquals(Currency.GBP, trade.getPremiumCurrency());
    assertEquals(PREMIUM_DATE, trade.getPremiumDate());
    assertEquals(TRADE_DATE, trade.getTradeDate());
    assertEquals(PREMIUM_TIME, trade.getPremiumTime());
    assertEquals(TRADE_TIME, trade.getTradeTime());
    assertEquals(ATTRIBUTES, trade.getAttributes());

    // can't check the node ID as nodes are completely replaced
    ManageablePortfolioNode loadedRoot = _portfolioMaster.get(_savedPortfolio.getUniqueId()).getPortfolio()
            .getRootNode();
    ManageablePortfolioNode loadedNode = loadedRoot.getChildNodes().get(0);
    assertEquals(1, loadedNode.getPositionIds().size());
    assertEquals(positionId.getObjectId(), loadedNode.getPositionIds().get(0));

    SecuritySearchRequest searchRequest = new SecuritySearchRequest();
    searchRequest.setExternalIdSearch(new ExternalIdSearch(underlyingId));
    SecuritySearchResult searchResult = _securityMaster.search(searchRequest);
    ManageableSecurity underlying = searchResult.getSingleSecurity();
    ExternalIdBundle underlyingBundle = underlying.getExternalIdBundle();
    // this isn't part of the equality check below because the test swaption can't know what the ID will be
    assertTrue(underlyingBundle.contains(underlyingId));
    // clear these values so we can do an equality check with the test swaption
    underlying.setUniqueId(null);
    underlying.setExternalIdBundle(ExternalIdBundle.EMPTY);
    assertEquals(BlotterTestUtils.SWAP, underlying);
}