List of usage examples for java.util List toString
public String toString()
From source file:org.alfresco.bm.BMCmisTest.java
/** * A listener method that allows the test to check results <b>before</b> the in-memory MongoDB instance * is discarded./*from ww w. j a va2s .c om*/ * <p/> * Check that the exact number of results are available, as expected * * @see BMTestRunnerListener */ @Override public void testRunFinished(ApplicationContext testCtx, String test, String run) { TestRunServicesCache services = testCtx.getBean(TestRunServicesCache.class); MongoTestDAO testDAO = services.getTestDAO(); LogService logService = testCtx.getBean(LogService.class); SessionService sessionService = services.getSessionService(test, run); TestService testService = services.getTestService(); ResultService resultService = services.getResultService(test, run); assertNotNull(resultService); TestRestAPI testAPI = new TestRestAPI(testDAO, testService, logService, services); ResultsRestAPI resultsAPI = testAPI.getTestRunResultsAPI(test, run); // Let's check the results before the DB gets thrown away (we didn't make it ourselves) // Get the summary CSV results for the time period and check some of the values String summary = BMTestRunner.getResultsCSV(resultsAPI); logger.info(summary); // Dump one of each type of event for information Set<String> eventNames = new TreeSet<String>(resultService.getEventNames()); logger.info("Showing 1 of each type of event:"); for (String eventName : eventNames) { List<EventRecord> eventRecord = resultService.getResults(eventName, 0, 1); logger.info(" " + eventRecord); assertFalse( "An event was created that has no available processor or producer: " + eventRecord + ". Use the TerminateEventProducer to absorb events.", eventRecord.toString().contains("processedBy=unknown")); } // One successful START event assertEquals("Incorrect number of start events.", 1, resultService.countResultsByEventName(Event.EVENT_NAME_START)); List<EventRecord> results = resultService.getResults(0L, Long.MAX_VALUE, false, 0, 1); if (results.size() != 1 || !results.get(0).getEvent().getName().equals(Event.EVENT_NAME_START)) { fail(Event.EVENT_NAME_START + " failed: \n" + results.toString()); } /* * 'start' = 1 result * 'cmis.createSessions' = 2 results * 'cmis.scenario.01.startSession' = 200 results * Successful processing generates a No-op for each */ /* * TODO Set<String> expectedEventNames = new TreeSet<String>(); expectedEventNames.add("start"); expectedEventNames.add("cmis.createSessions"); expectedEventNames.add("cmis.startSession"); expectedEventNames.add("cmis.scenario.01.findFolder"); expectedEventNames.add("cmis.scenario.01.listFolderContents"); expectedEventNames.add("cmis.scenario.02.retrieveTestFolder"); expectedEventNames.add("cmis.scenario.02.createTestFolder"); expectedEventNames.add("cmis.scenario.02.uploadFile"); expectedEventNames.add("cmis.scenario.02.downloadFile"); expectedEventNames.add("cmis.scenario.02.deleteTestFolder"); expectedEventNames.add("cmis.scenario.03.retrieveTestFolder"); expectedEventNames.add("cmis.scenario.03.createTestFolder"); expectedEventNames.add("cmis.scenario.03.searchInFolder"); expectedEventNames.add("cmis.scenario.03.deleteTestFolder"); expectedEventNames.add("cmis.scenario.04.queryFolder"); expectedEventNames.add("cmis.scenario.04.folderQueryCompleted"); expectedEventNames.add("cmis.scenario.04.documentQueryCompleted"); expectedEventNames.add("cmis.scenario.04.iteratePropertiesCompleted"); // Use the toString() as the TreeSet is ordered and the difference reporting is better assertEquals("Unexpected event names. ", expectedEventNames.toString(), eventNames.toString()); assertEquals( "Incorrect number of events: " + "cmis.startSession", 20, resultService.countResultsByEventName("cmis.startSession")); // Check for failures long failures = resultService.countResultsByFailure(); if (failures > 0L) { // Get the failures for information List<EventRecord> allResults = resultService.getResults(null, 0, Integer.MAX_VALUE); StringBuilder sb = new StringBuilder(2048); sb.append("Failures are:"); for (EventRecord result : allResults) { if (result.isSuccess()) { continue; } sb.append("\n").append(" ").append(result.toString()); } logger.error(sb.toString()); } assertEquals("Did not expect failures (at present). ", 0L, failures); */ // Check totals long countScenario01 = resultService.countResultsByEventName("cmis.scenario.01.findFolder"); long countScenario02 = resultService.countResultsByEventName("cmis.scenario.02.retrieveTestFolder"); long countScenario03 = resultService.countResultsByEventName("cmis.scenario.03.retrieveTestFolder"); long countExpected = 2 + (countScenario01 * 3) + (countScenario02 * 6) + (countScenario03 * 5); long successes = resultService.countResultsBySuccess(); //TODO assertEquals("Incorrect number of successful events. ", countExpected, successes); // Make sure that events received a traceable session ID assertEquals("Incorrect number of sessions: ", 20, sessionService.getAllSessionsCount()); results = resultService.getResults("cmis.scenario.02.retrieveTestFolder", 0, 20); for (EventRecord result : results) { assertNotNull("All scenario events must have a session ID: " + result, result.getEvent().getSessionId()); } }
From source file:de.dailab.plistacontest.client.ClientAndContestHandler0MQ.java
/** * Method to handle incoming messages from the server. * /*from ww w .j av a 2 s.c om*/ * @param messageType * the messageType of the incoming contest server message * @param _jsonString * the incoming contest server message * @return the response to the contest server */ @SuppressWarnings("unused") private String handleTraditionalMessage(final String messageType, final String _jsonMessageBody) { // write all data from the server to a file logger.info(messageType + "\t" + _jsonMessageBody); // create an jSON object from the String final JSONObject jObj = (JSONObject) JSONValue.parse(_jsonMessageBody); // define a response object String response = null; // TODO handle "item_create" // in a complex if/switch statement we handle the differentTypes of // messages if ("item_update".equalsIgnoreCase(messageType)) { // we extract itemID, domainID, text and the timeTime, create/update final RecommenderItem recommenderItem = RecommenderItem.parseItemUpdate(_jsonMessageBody); // we mark this information in the article table if (recommenderItem.getItemID() != null) { recommenderItemTable.handleItemUpdate(recommenderItem); } response = ";item_update successfull"; } else if ("recommendation_request".equalsIgnoreCase(messageType)) { final RecommenderItem recommenderItem = RecommenderItem.parseItemUpdate(_jsonMessageBody); // we handle a recommendation request try { // parse the new recommender request RecommenderItem currentRequest = RecommenderItem.parseRecommendationRequest(_jsonMessageBody); // gather the items to be recommended List<Long> resultList = recommenderItemTable.getLastItems(currentRequest); if (resultList == null) { response = "[]"; System.out.println("invalid resultList"); } else { response = resultList.toString(); } response = getRecommendationResultJSON(response); // TODO? might handle the the request as impressions } catch (Throwable t) { t.printStackTrace(); } } else if ("event_notification".equalsIgnoreCase(messageType)) { // parse the type of the event final RecommenderItem item = RecommenderItem.parseEventNotification(_jsonMessageBody); final String eventNotificationType = item.getNotificationType(); // impression refers to articles read by the user if ("impression".equalsIgnoreCase(eventNotificationType) || "impression_empty".equalsIgnoreCase(eventNotificationType)) { // we mark this information in the article table if (item.getItemID() != null) { // new items shall be added to the list of items recommenderItemTable.handleItemUpdate(item); response = "handle impression eventNotification successful"; } // click refers to recommendations clicked by the user } else if ("click".equalsIgnoreCase(eventNotificationType)) { response = "handle click eventNotification successful"; } else { System.out.println("unknown event-type: " + eventNotificationType + " (message ignored)"); } } else if ("error_notification".equalsIgnoreCase(messageType)) { System.out.println("error-notification: " + _jsonMessageBody); } else { System.out.println("unknown MessageType: " + messageType); // Error handling logger.info(jObj.toString()); // this.contestRecommender.error(jObj.toString()); } return response; }
From source file:com.oneops.antenna.ws.AntennaWsController.java
/** * Get the cache entry for specific nsPath. If the API returns an entry * doesn't mean that entry was existing in the Cache because the cache loader * would fetch and load a non existing entry on demand upon expiry. * * @param nsPath message nspath/*www .j a v a 2 s . c o m*/ * @return cache entry map. */ @RequestMapping(value = "/cache/entry", method = RequestMethod.GET) @ResponseBody public ResponseEntity<Map<String, Object>> getCacheEntry( @RequestParam(value = "nsPath", required = true) String nsPath) { Map<String, Object> stat = new LinkedHashMap<String, Object>(2); List<BasicSubscriber> entry; try { entry = cache.instance().get(new SinkKey(nsPath)); } catch (ExecutionException e) { stat.put("status", e.getMessage()); return new ResponseEntity<Map<String, Object>>(stat, HttpStatus.NOT_FOUND); } stat.put("status", "ok"); stat.put("entry", entry.toString()); return new ResponseEntity<Map<String, Object>>(stat, HttpStatus.OK); }
From source file:com.act.biointerpretation.l2expansion.L2ExpansionDriver.java
/** * Wraps L2 expansion so that it can be used in a workflow. The inputs are a list of RO IDs to expand on, * a file containing the substrates to apply the ROs to, and a file to which to write the output prediction corpus. * * @param roIds//from w w w . j av a 2 s . co m * @param substrateListFile * @param outputFile * @return */ public static JavaRunnable getRunnableOneSubstrateRoExpander(List<Integer> roIds, File substrateListFile, File outputFile) { return new JavaRunnable() { @Override public void run() throws IOException { // Verify files FileChecker.verifyInputFile(substrateListFile); FileChecker.verifyAndCreateOutputFile(outputFile); // Handle input ros ErosCorpus roCorpus = new ErosCorpus(); roCorpus.loadValidationCorpus(); roCorpus.filterCorpusById(roIds); // Handle input substrates L2InchiCorpus inchis = new L2InchiCorpus(); inchis.loadCorpus(substrateListFile); List<Molecule> moleculeList = inchis.getMolecules(); // Build expander PredictionGenerator generator = new AllPredictionsGenerator(new ReactionProjector()); L2Expander expander = new SingleSubstrateRoExpander(roCorpus, moleculeList, generator); // Run expander L2PredictionCorpus predictions = expander.getPredictions(); // Write output predictions.writePredictionsToJsonFile(outputFile); } @Override public String toString() { return "oneSubstrateRoExpander:" + roIds.toString(); } }; }
From source file:com.odoo.core.service.OSyncAdapter.java
/** * Removes non exist record from local database * * @param model//from w ww. ja va2 s .c om */ private void removeNonExistRecordFromLocal(OModel model) { List<Integer> ids = model.getServerIds(); try { ODomain domain = new ODomain(); domain.add("id", "in", new JSONArray(ids.toString())); JSONObject result = mOdoo.search_read(model.getModelName(), new JSONObject(), domain.get()); JSONArray records = result.getJSONArray("records"); if (records.length() > 0) { for (int i = 0; i < records.length(); i++) { JSONObject record = records.getJSONObject(i); ids.remove(ids.indexOf(record.getInt("id"))); } } int removedCounter = 0; if (ids.size() > 0) { removedCounter = model.deleteRecords(ids, true); } Log.i(TAG, removedCounter + " Records removed from local database."); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.lepin.activity.CarpoolWithCalendarActivity.java
protected void pay() { List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("carpoolProgramPassengerId", carpoolProgramPassengerId)); params.add(new BasicNameValuePair("payType", Constant.PAY_OFFLINE)); Util.printLog("?:" + params.toString()); util.doPostRequest(CarpoolWithCalendarActivity.this, new OnHttpRequestDataCallback() { public void onSuccess(String result) { Util.printLog(":" + result); JsonResult<String> jsonResult = Util.getInstance().getObjFromJsonResult(result, new TypeToken<JsonResult<String>>() { });/*w w w.jav a 2 s . com*/ if (jsonResult.isSuccess()) { Util.showToast(CarpoolWithCalendarActivity.this, jsonResult.getData()); getPlanInfo(); } else { Util.showToast(CarpoolWithCalendarActivity.this, getString(R.string.pay_error)); } } }, params, Constant.URL_CARPOOL_PAY, getString(R.string.complete_order_ing), false); // Util.getInstance().doPostRequest(this, new OnDataLoadingCallBack() { // // @Override // public void onLoadingBack(String result) { // Util.printLog(":" + result); // if (!TextUtils.isEmpty(result)) { // JsonResult<String> jsonResult = // Util.getInstance().getObjFromJsonResult(result, // new TypeToken<JsonResult<String>>() { // }); // if (jsonResult.isSuccess()) { // Util.showToast(CarpoolWithCalendarActivity.this, // jsonResult.getData()); // getPlanInfo(); // } else { // Util.showToast(CarpoolWithCalendarActivity.this, // getString(R.string.pay_error)); // } // } // } // }, params, Constant.URL_CARPOOL_PAY, // getString(R.string.complete_order_ing)); }
From source file:com.wso2telco.dep.reportingservice.dao.TaxDAO.java
/** * Gets the taxes for tax list.//from w w w.ja va 2 s.c o m * * @param taxList the tax list * @return the taxes for tax list * @throws Exception the exception */ public List<Tax> getTaxesForTaxList(List<String> taxList) throws Exception { Connection connection = null; Statement st = null; ResultSet results = null; List<Tax> taxes = new ArrayList<Tax>(); if (taxList == null || taxList.isEmpty()) { return taxes; } // CSV format surrounded by single quote String taxListStr = taxList.toString().replace("[", "'").replace("]", "'").replace(", ", "','"); String sql = "SELECT type,effective_from,effective_to,value FROM " + ReportingTable.TAX + " WHERE type IN (" + taxListStr + ")"; try { connection = DbUtils.getDbConnection(DataSourceNames.WSO2AM_STATS_DB); st = connection.createStatement(); log.debug("In getTaxesForTaxList"); log.debug("SQL (PS) ---> " + st.toString()); results = st.executeQuery(sql); while (results.next()) { Tax tax = new Tax(); tax.setType(results.getString("type")); tax.setEffective_from(results.getDate("effective_from")); tax.setEffective_to(results.getDate("effective_to")); tax.setValue(results.getBigDecimal("value")); taxes.add(tax); } st.close(); } catch (SQLException e) { log.error("SQL Error in getTaxesForTaxList"); log.error(e.getStackTrace()); handleException("Error occurred while getting Taxes for Tax List", e); } finally { DbUtils.closeAllConnections(null, connection, results); } return taxes; }
From source file:com.pureinfo.tgirls.servlet.ContinueServlet.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String type = request.getParameter("pictype"); String id = request.getParameter("picId"); if (StringUtils.isEmpty(id)) { id = "-1"; }//from ww w . j ava2 s . c o m int picId = -1; try { picId = Integer.parseInt(id); } catch (Exception e) { logger.error("error parse int", e); picId = -1; } logger.debug("to get pic with type[" + type + "] id[" + picId + "]"); response.setContentType("text/json; charset=utf-8"); JsonBase json = new JsonBase(); try { User loginUser = CookieUtils.getLoginUser(request, response); if (loginUser == null) { // response.sendError(HttpServletResponse.SC_BAD_REQUEST); // return; } Photo p = null; if (picId > 0) { p = GetPic.get(type, picId); } else { try { List<String> viewdPicIds = new ArrayList<String>();// (List<Integer>) String ids = (String) CookieUtils.getRequestCookieValue(request, VIEWD_PIC_IDS + loginUser.getTaobaoID()); logger.debug("the ids:" + ids); if (StringUtils.isNotEmpty(ids)) { viewdPicIds = new ArrayList<String>(Arrays.asList(ids.split(","))); } logger.debug("before:" + viewdPicIds.toString()); p = GetPic.getPic(type, viewdPicIds); ids = GetPic.idListToString(viewdPicIds); logger.debug("after:" + ids); request.getSession().setAttribute(VIEWD_PIC_IDS + loginUser.getTaobaoID(), ids); //Cookie c = new Cookie(VIEWD_PIC_IDS + loginUser.getTaobaoID(), ids); //response.addCookie(c); } catch (Exception e) { logger.error("error when record view ids.", e); p = GetPic.getRandomPic(type); } } json.put("pic", new JSONObject(p)); String[] moneyKey = MakeMoneyUtil.getMoney(request, response); if (moneyKey != null) { json.put("money", moneyKey[0]); json.put("moneyValidateKey", moneyKey[1]); request.getSession().setAttribute(MakeMoneyUtil.VALIDATE_KEY, moneyKey[1]); } if (loginUser != null) { List<JSONObject> infolist = GetInformationsServlet.getInformations(loginUser.getTaobaoID()); if (infolist != null) { json.put("informations", infolist); } } } catch (JSONException e) { e.printStackTrace(System.err); } //logger.debug("result:" + json.toString()); response.getWriter().write(json.toString()); return; }
From source file:de.tudarmstadt.ukp.dkpro.lexsemresource.core.ResourceFactory.java
public static synchronized ResourceFactory getInstance() throws ResourceLoaderException { if (loader == null) { List<String> locs = new ArrayList<String>(); URL resourceXmlUrl = null; // Check in workspace try {/*from ww w . j av a 2 s.com*/ File f = new File(getWorkspace(), CONFIG_FILE); if (f.isFile()) { try { resourceXmlUrl = f.toURI().toURL(); } catch (MalformedURLException e) { throw new ResourceLoaderException(e); } } locs.add(f.getAbsolutePath()); } catch (IOException e) { locs.add("DKPro workspace not available"); } // Check in classpath if (resourceXmlUrl == null) { resourceXmlUrl = ResourceFactory.class.getResource(CONFIG_FILE); locs.add("Classpath: " + CONFIG_FILE); } // Check in default file system location if (resourceXmlUrl == null && new File(CONFIG_FILE).isFile()) { try { resourceXmlUrl = new File(CONFIG_FILE).toURI().toURL(); } catch (MalformedURLException e) { throw new ResourceLoaderException(e); } locs.add(new File(CONFIG_FILE).getAbsolutePath()); } // Bail out if still not found if (resourceXmlUrl == null) { throw new ResourceLoaderException( "Unable to locate configuration file [" + CONFIG_FILE + "] in " + locs.toString()); } loader = new ResourceFactory(resourceXmlUrl.toString()); } return loader; }
From source file:com.dtolabs.rundeck.plugin.resources.ec2.InstanceToNodeMapper.java
public Set<Instance> addingImageName(Set<Instance> originalInstances) { Set<Instance> instances = new HashSet<>(); Map<String, Image> ec2Images = new HashMap<>(); List<String> imagesList = originalInstances.stream().map(Instance::getImageId).collect(Collectors.toList()); logger.debug("Image list: " + imagesList.toString()); try {//from w w w . j a va 2 s . c o m DescribeImagesRequest describeImagesRequest = new DescribeImagesRequest(); describeImagesRequest.setImageIds(imagesList); DescribeImagesResult result = ec2.describeImages(describeImagesRequest); for (Image image : result.getImages()) { ec2Images.put(image.getImageId(), image); } } catch (Exception e) { logger.error("error getting image info" + e.getMessage()); } for (final Instance inst : originalInstances) { if (ec2Images.containsKey(inst.getImageId())) { Ec2Instance customInstance = Ec2Instance.builder(inst); Image image = ec2Images.get(inst.getImageId()); customInstance.setImageName(image.getName()); instances.add(customInstance); } else { Ec2Instance customInstance = Ec2Instance.builder(inst); customInstance.setImageName("Not found"); logger.debug("Image not found" + inst.getImageId()); instances.add(customInstance); } } return instances; }