/** * Gets the total size of the map by counting all the values. * * @return the total size of the map counting all values */ public int totalSize() { int total = 0; for (final Object v : decorated().values()) { total += CollectionUtils.size(v); } return total; }
public InternalTransaction addInternalTransaction(byte[] parentHash, int deep, byte[] nonce, DataWord gasPrice, DataWord gasLimit, byte[] senderAddress, byte[] receiveAddress, byte[] value, byte[] data, String note) { InternalTransaction transaction = new InternalTransaction(parentHash, deep, size(internalTransactions), nonce, gasPrice, gasLimit, senderAddress, receiveAddress, value, data, note); getInternalTransactions().add(transaction); return transaction; }
private static void assertLogInfoEquals(LogInfo expected, LogInfo actual) { assertNotNull(expected); assertNotNull(actual); assertArrayEquals(expected.getAddress(), actual.getAddress()); assertEquals(size(expected.getTopics()), size(actual.getTopics())); for (int i = 0; i < size(expected.getTopics()); i++) { assertArrayEquals(expected.getTopics().get(i).getData(), actual.getTopics().get(i).getData()); } assertArrayEquals(expected.getData(), actual.getData()); }
assertArrayEquals(tx.getHash(), summary.getTransactionHash()); assertEquals(size(deleteAccounts), size(summary.getDeletedAccounts())); for (DataWord account : summary.getDeletedAccounts()) { assertTrue(deleteAccounts.contains(account)); assertEquals(size(logs), size(summary.getLogs())); for (int i = 0; i < logs.size(); i++) { assertLogInfoEquals(logs.get(i), summary.getLogs().get(i)); assertEquals(gasUsed, summary.getGasUsed()); assertEquals(nestedLevelCount * countByLevel, size(internalTransactions));
/** * Flushes all expired profiles. * * <p>If a profile has not received a message for an extended period of time then it is * marked as expired. Periodically we need to flush these expired profiles to ensure * that their state is not lost. */ protected void flushExpired() { List<ProfileMeasurement> measurements = null; try { // flush the expired profiles synchronized (messageDistributor) { measurements = messageDistributor.flushExpired(); emitMeasurements(measurements); } } catch(Throwable t) { // need to catch the exception, otherwise subsequent executions would be suppressed. // see java.util.concurrent.ScheduledExecutorService#scheduleAtFixedRate LOG.error("Failed to flush expired profiles", t); } LOG.debug("Flushed expired profiles and found {} measurement(s).", CollectionUtils.size(measurements)); }
/** * Render a view of the {@link RecordMetadata} that resulted from writing * messages to Kafka. * * @param records The record metadata. * @param properties The properties. * @return */ private Object render(List<RecordMetadata> records, Properties properties) { Object view; if(MESSAGE_VIEW_RICH.equals(getMessageView(properties))) { // build a 'rich' view of the messages that were written List<Object> responses = new ArrayList<>(); for(RecordMetadata record: records) { // render the 'rich' view of the record Map<String, Object> richView = new HashMap<>(); richView.put("topic", record.topic()); richView.put("partition", record.partition()); richView.put("offset", record.offset()); richView.put("timestamp", record.timestamp()); responses.add(richView); } // the rich view is a list of maps containing metadata about how each message was written view = responses; } else { // otherwise, the view is simply a count of the number of messages written view = CollectionUtils.size(records); } return view; }
@Override @SuppressWarnings("rawtypes") public int collectionSize(Collection collection) { return CollectionUtils.size(collection); }
@Override public String toString() { return "Pom{" + role + " " + coord + ", parent=" + (parent == null ? "" : parent.coord) + ", " + "name=" + name + /* ", desc=" + description + */ ", " + "dependencies=" + CollectionUtils.size(dependencies) + ", " + "localDependencies=" + CollectionUtils.size(localDependencies) + ", " + "submodules=" + CollectionUtils.size(submodules) + '}'; }
@Override public String toString() { return "Pom{" + role + " " + coord + ", parent=" + (parent == null ? "" : parent.coord) + ", " + "name=" + name + /* ", desc=" + description + */ ", " + "dependencies=" + CollectionUtils.size(dependencies) + ", " + "localDependencies=" + CollectionUtils.size(localDependencies) + ", " + "submodules=" + CollectionUtils.size(submodules) + '}'; }
@Override @Transactional public int deleteAllExpected(final Collection<K> identifiers) { final int deleted = deleteAll(identifiers); if (deleted != org.apache.commons.collections4.CollectionUtils.size(identifiers)) { // At least one row has not been deleted throw new EntityNotFoundException(identifiers.toString()); } return deleted; }
public SpiPeriodicPaymentInitiationResponse mapToSpiPeriodicPaymentResponse(@NotNull AspspPeriodicPayment payment) { SpiPeriodicPaymentInitiationResponse spi = new SpiPeriodicPaymentInitiationResponse(); spi.setAspspAccountId(Optional.ofNullable(payment.getDebtorAccount()) .map(AspspAccountReference::getAccountId) .orElse(null)); spi.setPaymentId(payment.getPaymentId()); spi.setMultilevelScaRequired(CollectionUtils.size(payment.getPsuDataList()) > 1); if (payment.getPaymentId() == null) { spi.setTransactionStatus(SpiTransactionStatus.RJCT); } else { spi.setTransactionStatus(SpiTransactionStatus.RCVD); } return spi; }
public SpiSinglePaymentInitiationResponse mapToSpiSinglePaymentResponse(@NotNull AspspSinglePayment payment) { SpiSinglePaymentInitiationResponse spi = new SpiSinglePaymentInitiationResponse(); spi.setAspspAccountId(Optional.ofNullable(payment.getDebtorAccount()) .map(AspspAccountReference::getAccountId) .orElse(null)); spi.setPaymentId(payment.getPaymentId()); spi.setMultilevelScaRequired(CollectionUtils.size(payment.getPsuDataList()) > 1); if (payment.getPaymentId() == null) { spi.setTransactionStatus(SpiTransactionStatus.RJCT); } else { spi.setTransactionStatus(SpiTransactionStatus.RCVD); } return spi; } }
public SpiBulkPaymentInitiationResponse mapToSpiBulkPaymentResponse(@NotNull AspspBulkPayment payment, String paymentProduct) { SpiBulkPaymentInitiationResponse spi = new SpiBulkPaymentInitiationResponse(); spi.setAspspAccountId(Optional.ofNullable(payment.getDebtorAccount()) .map(AspspAccountReference::getAccountId) .orElse(null)); spi.setPayments(mapToListSpiSinglePayments(payment.getPayments(), paymentProduct)); spi.setPaymentId(payment.getPaymentId()); spi.setMultilevelScaRequired(CollectionUtils.size(payment.getPsuDataList()) > 1); if (payment.getPaymentId() == null) { spi.setTransactionStatus(SpiTransactionStatus.RJCT); } else { spi.setTransactionStatus(SpiTransactionStatus.RCVD); } return spi; }
@Test public void testAddObjectPropertyToContextOnAbstractNotificationMessageBuilder() { // Create an empty context map Map<String, Object> context = new LinkedHashMap<>(); // Create test property values. Object propertyValue = new Object(); Object jsonEscapedPropertyValue = new Object(); Object xmlEscapedPropertyValue = new Object(); // Call the method under test. businessObjectDataStatusChangeMessageBuilder .addObjectPropertyToContext(context, ATTRIBUTE_NAME + SUFFIX_UNESCAPED, propertyValue, jsonEscapedPropertyValue, xmlEscapedPropertyValue); // Validate the results. assertEquals(3, CollectionUtils.size(context)); assertEquals(propertyValue, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED)); assertEquals(jsonEscapedPropertyValue, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED + "WithJson")); assertEquals(xmlEscapedPropertyValue, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED + "WithXml")); }
@Test public void testAddStringPropertyToContextOnAbstractNotificationMessageBuilder() { // Create an empty context map. Map<String, Object> context = new LinkedHashMap<>(); // Call the method under test. businessObjectDataStatusChangeMessageBuilder.addStringPropertyToContext(context, ATTRIBUTE_NAME + SUFFIX_UNESCAPED, ATTRIBUTE_VALUE + SUFFIX_UNESCAPED); // Validate the results. assertEquals(3, CollectionUtils.size(context)); assertEquals(ATTRIBUTE_VALUE + SUFFIX_UNESCAPED, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED)); assertEquals(ATTRIBUTE_VALUE + SUFFIX_ESCAPED_JSON, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED + "WithJson")); assertEquals(ATTRIBUTE_VALUE + SUFFIX_ESCAPED_XML, context.get(ATTRIBUTE_NAME + SUFFIX_UNESCAPED + "WithXml")); }
@Test public void testGetBaseVelocityContextMap() { // Call the method under test. Map<String, Object> result = businessObjectDataStatusChangeMessageBuilder.getBaseVelocityContextMap(); // Validate the results. assertEquals(14, CollectionUtils.size(result)); }
@SuppressWarnings("unchecked") private <F extends FocusType> Collection<EvaluatedAssignmentImpl<F>> assertAssignmentTripleSetSize(LensContext<F> context, int zero, int plus, int minus) { assertEquals("Wrong size of assignment triple zero set", zero, CollectionUtils.size(context.getEvaluatedAssignmentTriple().getZeroSet())); assertEquals("Wrong size of assignment triple plus set", plus, CollectionUtils.size(context.getEvaluatedAssignmentTriple().getPlusSet())); assertEquals("Wrong size of assignment triple minus set", minus, CollectionUtils.size(context.getEvaluatedAssignmentTriple().getMinusSet())); return (Collection) context.getEvaluatedAssignmentTriple().getAllValues(); }
@Test public void testGetMap() { // Create objects required for testing. final String name = STRING_VALUE; final String value = STRING_VALUE_2; final Parameter parameter = new Parameter(name, value); // Call the method under test. Map<String, String> result = emrDaoImpl.getMap(Arrays.asList(parameter)); // Verify the external calls. verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(1, CollectionUtils.size(result)); assertTrue(result.containsKey(name)); assertEquals(value, result.get(name)); }
@Test public void testSearchBusinessObjectDataPageNum1() throws Exception { retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setUseSsl(false); BusinessObjectDataSearchResult result = retentionExpirationExporterWebClient.searchBusinessObjectData(new BusinessObjectDataSearchRequest(), 1); assertNotNull(result); assertEquals(2, CollectionUtils.size(result.getBusinessObjectDataElements())); }
@Test public void testSearchBusinessObjectDataPageNum2() throws Exception { retentionExpirationExporterWebClient.getRegServerAccessParamsDto().setUseSsl(false); BusinessObjectDataSearchResult result = retentionExpirationExporterWebClient.searchBusinessObjectData(new BusinessObjectDataSearchRequest(), 2); assertNotNull(result); assertEquals(0, CollectionUtils.size(result.getBusinessObjectDataElements())); }