List of usage examples for java.util Collection toString
public String toString()
From source file:com.comcast.dawg.house.EditDeviceUIIT.java
/** * * @param val The value to give for the new property * @author Kevin Pearson//from ww w . j av a 2 s. co m * @throws IOException */ @Test(dataProvider = "testAddPropertySetData") public void testAddPropertySet(String val, String[] contained) throws IOException { RemoteWebDriver driver = BrowserServiceManager.getDriver(Browser.chrome); MetaStb stb = MetaStbBuilder.build().uid(DEVICE_PREF).stb(); addStb(stb); String token = MetaStbBuilder.getUID("testtoken"); EditDeviceOverlay edOverlay = loadPageAndLaunchEditOverlay(driver, token, stb.getId()); String myKey = "myKeySet"; edOverlay.addProp(myKey, true, false); EditDeviceRow row = edOverlay.getRow(myKey); Assert.assertNotNull(row); Assert.assertEquals(row.getPropDisp(), "My Key Set"); Assert.assertTrue(row.isModified()); row.changeValue(val); edOverlay.save(); waitForNewPageToLoad(driver, edOverlay.getOverlayUI()); MetaStb updated = client.getById(stb.getId()); Object newVal = updated.getData().get(myKey); Assert.assertNotNull(newVal); Assert.assertTrue(newVal instanceof Collection); Collection<?> coll = (Collection<?>) newVal; Assert.assertEquals(coll.size(), contained.length); for (String contain : contained) { Assert.assertTrue(coll.contains(contain), "Backend did not contain '" + contain + "', had values: " + coll.toString()); } }
From source file:it.cnr.icar.eric.client.ui.common.UIUtility.java
public String formatCollectionString(Collection<?> collection) { String value = collection.toString(); StringBuffer sb3 = new StringBuffer(value); // remove leading straight bracket '[' sb3.deleteCharAt(0);/* ww w . j a va2s . c o m*/ // remove ending straight bracket ']' sb3.deleteCharAt(sb3.length() - 1); value = sb3.toString(); StringBuffer sb = new StringBuffer(); String[] tokens = value.split(", "); for (int i = 0; i < tokens.length; i++) { String token = tokens[i]; if (i > 0) { sb.append(", "); } // construct hyperlink if (token.indexOf("://") != -1) { StringBuffer sb2 = new StringBuffer(); sb2.append("<a href=\""); sb2.append(token); sb2.append("\" target=\"_new\">"); sb2.append(token); sb2.append("</a>"); token = sb2.toString(); } sb.append(token); } value = sb.toString(); return value; }
From source file:org.apache.nifi.processors.standard.TestEncryptContent.java
@Test public void testValidation() { final TestRunner runner = TestRunners.newTestRunner(EncryptContent.class); Collection<ValidationResult> results; MockProcessContext pc;// w w w . j av a 2s . c o m runner.enqueue(new byte[0]); pc = (MockProcessContext) runner.getProcessContext(); results = pc.validate(); Assert.assertEquals(results.toString(), 1, results.size()); for (final ValidationResult vr : results) { Assert.assertTrue(vr.toString() .contains(EncryptContent.PASSWORD.getDisplayName() + " is required when using algorithm")); } runner.enqueue(new byte[0]); final EncryptionMethod encryptionMethod = EncryptionMethod.MD5_128AES; runner.setProperty(EncryptContent.ENCRYPTION_ALGORITHM, encryptionMethod.name()); runner.setProperty(EncryptContent.KEY_DERIVATION_FUNCTION, KeyDerivationFunction.NIFI_LEGACY.name()); runner.setProperty(EncryptContent.PASSWORD, "ThisIsAPasswordThatIsLongerThanSixteenCharacters"); pc = (MockProcessContext) runner.getProcessContext(); results = pc.validate(); if (!PasswordBasedEncryptor.supportsUnlimitedStrength()) { logger.info(results.toString()); Assert.assertEquals(1, results.size()); for (final ValidationResult vr : results) { Assert.assertTrue( "Did not successfully catch validation error of a long password in a non-JCE Unlimited Strength environment", vr.toString().contains("Password length greater than " + CipherUtility.getMaximumPasswordLengthForAlgorithmOnLimitedStrengthCrypto( encryptionMethod) + " characters is not supported by this JVM due to lacking JCE Unlimited Strength Jurisdiction Policy files.")); } } else { Assert.assertEquals(results.toString(), 0, results.size()); } runner.removeProperty(EncryptContent.PASSWORD); runner.setProperty(EncryptContent.ENCRYPTION_ALGORITHM, EncryptionMethod.PGP.name()); runner.setProperty(EncryptContent.PUBLIC_KEYRING, "src/test/resources/TestEncryptContent/text.txt"); runner.enqueue(new byte[0]); pc = (MockProcessContext) runner.getProcessContext(); results = pc.validate(); Assert.assertEquals(1, results.size()); for (final ValidationResult vr : results) { Assert.assertTrue(vr.toString() .contains(" encryption without a " + EncryptContent.PASSWORD.getDisplayName() + " requires both " + EncryptContent.PUBLIC_KEYRING.getDisplayName() + " and " + EncryptContent.PUBLIC_KEY_USERID.getDisplayName())); } // Legacy tests moved to individual tests to comply with new library // TODO: Move secring tests out to individual as well runner.removeProperty(EncryptContent.PUBLIC_KEYRING); runner.removeProperty(EncryptContent.PUBLIC_KEY_USERID); runner.setProperty(EncryptContent.MODE, EncryptContent.DECRYPT_MODE); runner.setProperty(EncryptContent.PRIVATE_KEYRING, "src/test/resources/TestEncryptContent/secring.gpg"); runner.enqueue(new byte[0]); pc = (MockProcessContext) runner.getProcessContext(); results = pc.validate(); Assert.assertEquals(1, results.size()); for (final ValidationResult vr : results) { Assert.assertTrue(vr.toString() .contains(" decryption without a " + EncryptContent.PASSWORD.getDisplayName() + " requires both " + EncryptContent.PRIVATE_KEYRING.getDisplayName() + " and " + EncryptContent.PRIVATE_KEYRING_PASSPHRASE.getDisplayName())); } runner.setProperty(EncryptContent.PRIVATE_KEYRING_PASSPHRASE, "PASSWORD"); runner.enqueue(new byte[0]); pc = (MockProcessContext) runner.getProcessContext(); results = pc.validate(); Assert.assertEquals(1, results.size()); for (final ValidationResult vr : results) { Assert.assertTrue(vr.toString().contains(" could not be opened with the provided " + EncryptContent.PRIVATE_KEYRING_PASSPHRASE.getDisplayName())); } }
From source file:org.opentestsystem.authoring.testauth.validation.AbstractDomainValidator.java
protected void rejectIfNotInCollection(final Errors e, final String fieldName, final Collection<String> collection, final Object... errorArgs) { final Object value = e.getFieldValue(fieldName); if (!org.springframework.util.StringUtils.isEmpty(value) && collection != null && !collection.isEmpty()) { if (!collection.contains(value.toString())) { rejectValue(e, fieldName, getErrorMessageRoot() + fieldName + MSG_REQUIRED_CONTAINS, flattenArgs(errorArgs, collection.toString())); }/*from w w w .j a v a2 s.c om*/ } }
From source file:com.hadoopvietnam.cache.memcached.MemcachedCache.java
/** * {@inheritDoc}/* ww w . j ava 2 s . com*/ */ public Map<String, Object> multiGet(final Collection<String> inKeys) { if (log.isTraceEnabled()) { log.trace("Getting bulk: " + inKeys.toString()); } return client.getBulk(inKeys); }
From source file:org.apache.hadoop.hdfs.server.datanode.BPServiceActor.java
private String formatThreadName() { Collection<StorageLocation> dataDirs = DataNode.getStorageLocations(dn.getConf()); return "DataNode: [" + dataDirs.toString() + "] " + " heartbeating to " + nnAddr; }
From source file:com.pinterest.teletraan.worker.ClusterReplacer.java
/** * Step 1. INIT state will launch hosts outside of the auto scaling group * The number of hosts to be launched should be max_parallel_rp * If launching failed, retry INIT state until timeout meets */// w ww. ja va 2 s .c o m private void processInitState(ClusterUpgradeEventBean eventBean) throws Exception { String clusterName = eventBean.getCluster_name(); EnvironBean environBean = environDAO.getById(eventBean.getEnv_id()); int totToLaunch = environBean.getMax_parallel_rp() <= 0 ? 1 : environBean.getMax_parallel_rp(); if (!StringUtils.isEmpty(eventBean.getHost_ids())) { Collection<String> oldHostIds = Arrays.asList(eventBean.getHost_ids().split(",")); totToLaunch -= oldHostIds.size(); } LOG.info(String.format("Start to launch hosts (number to launch: %d)", totToLaunch)); boolean succeeded = true; while (totToLaunch > 0) { int numToLaunch = Math.min(totToLaunch, MAX_HOST_LAUNCH_SIZE); Collection<HostBean> newHosts = clusterManager.launchHosts(clusterName, numToLaunch, false); if (newHosts.isEmpty()) { LOG.error(String.format("Failed to launch %s hosts in INIT state", numToLaunch)); succeeded = false; break; } LOG.info(String.format("Successfully launched %d hosts: %s", newHosts.size(), newHosts.toString())); Collection<String> updateHostIds = new ArrayList<>(); for (HostBean host : newHosts) { updateHostIds.add(host.getHost_id()); hostDAO.insert(host); } if (!StringUtils.isEmpty(eventBean.getHost_ids())) { Collection<String> oldHostIds = Arrays.asList(eventBean.getHost_ids().split(",")); updateHostIds.addAll(oldHostIds); } updateHostsInClusterEvent(eventBean.getId(), updateHostIds); totToLaunch -= newHosts.size(); } if (succeeded) { LOG.info("Successfully completed INIT state, move to LAUNCHING state"); ClusterUpgradeEventBean updateBean = new ClusterUpgradeEventBean(); updateBean.setState(ClusterUpgradeEventState.LAUNCHING); updateBean.setStatus(ClusterUpgradeEventStatus.SUCCEEDED); transitionState(eventBean.getId(), updateBean); } }
From source file:com.pinterest.clusterservice.cm.AwsVmManager.java
@Override public void terminateHosts(String clusterName, Collection<String> hostIds, boolean replaceHost) throws Exception { if (replaceHost) { TerminateInstancesRequest termianteRequest = new TerminateInstancesRequest(); termianteRequest.setInstanceIds(hostIds); try {/* w w w . jav a 2 s . c o m*/ ec2Client.terminateInstances(termianteRequest); } catch (AmazonClientException e) { LOG.error(String.format("Failed to termiante hosts %s: %s", hostIds.toString(), e.getMessage())); throw new Exception( String.format("Failed to termiante hosts %s: %s", hostIds.toString(), e.getMessage())); } } else { // Do not replace host and decrease the cluster capacity AutoScalingGroup group = getAutoScalingGroup(clusterName); if (group == null) { LOG.error(String.format("Failed to terminate hosts: auto scaling group %s does not exist", clusterName)); throw new Exception(String.format("Failed to terminate hosts: auto scaling group %s does not exist", clusterName)); } UpdateAutoScalingGroupRequest updateRequest = new UpdateAutoScalingGroupRequest(); updateRequest.setAutoScalingGroupName(clusterName); updateRequest.setMinSize(Math.max(group.getMinSize() - hostIds.size(), 0)); for (String hostId : hostIds) { TerminateInstanceInAutoScalingGroupRequest terminateRequest = new TerminateInstanceInAutoScalingGroupRequest(); terminateRequest.setShouldDecrementDesiredCapacity(true); terminateRequest.setInstanceId(hostId); aasClient.terminateInstanceInAutoScalingGroup(terminateRequest); } } }
From source file:de.smartics.maven.plugin.jboss.modules.JBossModulesArchiveMojo.java
private void logDependencies(final Collection<Dependency> rootDependencies, final Collection<Dependency> dependencies) throws MojoExecutionException { if (verbose) { try {/*from ww w . ja v a 2 s .c o m*/ FileUtils.writeStringToFile(new File(project.getBasedir(), "target/root-dependencies.txt"), rootDependencies.toString()); FileUtils.writeStringToFile(new File(project.getBasedir(), "target/resolved-dependencies.txt"), dependencies.toString()); } catch (final IOException e) { throw new MojoExecutionException("dependencies", e); } } }
From source file:org.intermine.dwr.AjaxServices.java
/** * This method gets a map of ids of elements that were in the past (during session) toggled and * returns them in JSON//from w w w. j a v a 2 s . co m * @return JSON serialized to a String * @throws JSONException */ public static String getToggledElements() { HttpSession session = WebContextFactory.get().getSession(); WebState webState = SessionMethods.getWebState(session); Collection<JSONObject> lists = new HashSet<JSONObject>(); try { for (Map.Entry<String, Boolean> entry : webState.getToggledElements().entrySet()) { JSONObject list = new JSONObject(); list.put("id", entry.getKey()); list.put("opened", entry.getValue().toString()); lists.add(list); } } catch (JSONException jse) { LOG.error("Errors generating json objects", jse); } return lists.toString(); }