List of usage examples for java.util List toString
public String toString()
From source file:com.google.code.joliratools.bind.apt.JAXROProcessorJSONTest.java
/** * Test the process with the -Ajaxroproc= parameters. * //from w w w . j ava2 s.c om * @throws Exception * something failed */ @Test(expected = RuntimeException.class) public void testProcessProcAdaptersOnly() throws Exception { final Compilation compilation = createCompilation(); compilation.doCompile(new PrintWriter(System.out), "-Ajaxroproc=adaptersonly"); final List<Diagnostic<? extends JavaFileObject>> diagnostics = compilation.getDiagnostics(); assertEquals(diagnostics.toString(), 2, diagnostics.size()); compilation.getGeneratedResource("com/google/code/joliratools/bind/demo/jaxro.xsd"); }
From source file:io.seldon.spark.actions.GroupActionsJob.java
public static void run(CmdLineArgs cmdLineArgs) { long unixDays = 0; try {// w ww . java 2 s.c o m unixDays = JobUtils.dateToUnixDays(cmdLineArgs.input_date_string); } catch (ParseException e) { unixDays = 0; } System.out.println(String.format("--- started GroupActionsJob date[%s] unixDays[%s] ---", cmdLineArgs.input_date_string, unixDays)); System.out.println("Env: " + System.getenv()); System.out.println("Properties: " + System.getProperties()); SparkConf sparkConf = new SparkConf().setAppName("GroupActionsJob"); if (cmdLineArgs.debug_use_local_master) { System.out.println("Using 'local' master"); sparkConf.setMaster("local"); } Tuple2<String, String>[] sparkConfPairs = sparkConf.getAll(); System.out.println("--- sparkConf ---"); for (int i = 0; i < sparkConfPairs.length; i++) { Tuple2<String, String> kvPair = sparkConfPairs[i]; System.out.println(String.format("%s:%s", kvPair._1, kvPair._2)); } System.out.println("-----------------"); JavaSparkContext jsc = new JavaSparkContext(sparkConf); { // setup aws access Configuration hadoopConf = jsc.hadoopConfiguration(); hadoopConf.set("fs.s3.impl", "org.apache.hadoop.fs.s3native.NativeS3FileSystem"); if (cmdLineArgs.aws_access_key_id != null && !"".equals(cmdLineArgs.aws_access_key_id)) { hadoopConf.set("fs.s3n.awsAccessKeyId", cmdLineArgs.aws_access_key_id); hadoopConf.set("fs.s3n.awsSecretAccessKey", cmdLineArgs.aws_secret_access_key); } } // String output_path_dir = "./out/" + input_date_string + "-" + UUID.randomUUID(); JavaRDD<String> dataSet = jsc.textFile( JobUtils.getSourceDirFromDate(cmdLineArgs.input_path_pattern, cmdLineArgs.input_date_string)) .repartition(4); final ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); final String single_client = cmdLineArgs.single_client; if (single_client != null) { Function<String, Boolean> clientFilter = new Function<String, Boolean>() { @Override public Boolean call(String t) throws Exception { ActionData actionData = JobUtils.getActionDataFromActionLogLine(objectMapper, t); return ((actionData.client != null) && (actionData.client.equals(single_client))); } }; dataSet = dataSet.filter(clientFilter); } JavaPairRDD<String, ActionData> pairs = dataSet.mapToPair(new PairFunction<String, String, ActionData>() { @Override public Tuple2<String, ActionData> call(String t) throws Exception { ActionData actionData = JobUtils.getActionDataFromActionLogLine(objectMapper, t); // String key = (actionData.userid == 0) ? "__no_userid__" : actionData.client; String key = actionData.client; return new Tuple2<String, ActionData>(key, actionData); } }).persist(StorageLevel.MEMORY_AND_DISK()); List<String> clientList = pairs.keys().distinct().collect(); Queue<ClientDetail> clientDetailQueue = new PriorityQueue<ClientDetail>(30, new Comparator<ClientDetail>() { @Override public int compare(ClientDetail o1, ClientDetail o2) { if (o1.itemCount > o2.itemCount) { return -1; } else if (o1.itemCount < o2.itemCount) { return 1; } return 0; } }); Queue<ClientDetail> clientDetailZeroQueue = new PriorityQueue<ClientDetail>(30, new Comparator<ClientDetail>() { @Override public int compare(ClientDetail o1, ClientDetail o2) { if (o1.itemCount > o2.itemCount) { return -1; } else if (o1.itemCount < o2.itemCount) { return 1; } return 0; } }); System.out.println("Client list " + clientList.toString()); for (String client : clientList) { if (client != null) { System.out.println("looking at client " + client); final String currentClient = client; JavaPairRDD<String, ActionData> filtered_by_client = pairs .filter(new Function<Tuple2<String, ActionData>, Boolean>() { @Override public Boolean call(Tuple2<String, ActionData> v1) throws Exception { if (currentClient.equalsIgnoreCase(v1._1)) { return Boolean.TRUE; } else { return Boolean.FALSE; } } }); JavaPairRDD<String, ActionData> nonZeroUserIds = filtered_by_client .filter(new Function<Tuple2<String, ActionData>, Boolean>() { @Override public Boolean call(Tuple2<String, ActionData> v1) throws Exception { if (v1._2.userid == 0) { return Boolean.FALSE; } else { return Boolean.TRUE; } } }); JavaPairRDD<String, Integer> userIdLookupRDD = nonZeroUserIds .mapToPair(new PairFunction<Tuple2<String, ActionData>, String, Integer>() { @Override public Tuple2<String, Integer> call(Tuple2<String, ActionData> t) throws Exception { String key = currentClient + "_" + t._2.client_userid; return new Tuple2<String, Integer>(key, t._2.userid); } }); Map<String, Integer> userIdLookupMap = userIdLookupRDD.collectAsMap(); Map<String, Integer> userIdLookupMap_wrapped = new HashMap<String, Integer>(userIdLookupMap); final Broadcast<Map<String, Integer>> broadcastVar = jsc.broadcast(userIdLookupMap_wrapped); JavaRDD<String> json_only_with_zeros = filtered_by_client .map(new Function<Tuple2<String, ActionData>, String>() { @Override public String call(Tuple2<String, ActionData> v1) throws Exception { Map<String, Integer> m = broadcastVar.getValue(); ActionData actionData = v1._2; if (actionData.userid == 0) { String key = currentClient + "_" + actionData.client_userid; if (m.containsKey(key)) { actionData.userid = m.get(key); } else { return ""; } } String json = JobUtils.getJsonFromActionData(actionData); return json; } }); JavaRDD<String> json_only = json_only_with_zeros.filter(new Function<String, Boolean>() { @Override public Boolean call(String v1) throws Exception { return (v1.length() == 0) ? Boolean.FALSE : Boolean.TRUE; } }); String outputPath = getOutputPath(cmdLineArgs.output_path_dir, unixDays, client); if (cmdLineArgs.gzip_output) { json_only.saveAsTextFile(outputPath, org.apache.hadoop.io.compress.GzipCodec.class); } else { json_only.saveAsTextFile(outputPath); } long json_only_count = json_only.count(); clientDetailZeroQueue .add(new ClientDetail(currentClient, json_only_with_zeros.count() - json_only_count)); clientDetailQueue.add(new ClientDetail(currentClient, json_only_count)); } else System.out.println("Found null client!"); } System.out.println("- Client Action (Zero Userid) Count -"); while (clientDetailZeroQueue.size() != 0) { GroupActionsJob.ClientDetail clientDetail = clientDetailZeroQueue.remove(); System.out.println(String.format("%s: %d", clientDetail.client, clientDetail.itemCount)); } System.out.println("- Client Action Count -"); while (clientDetailQueue.size() != 0) { GroupActionsJob.ClientDetail clientDetail = clientDetailQueue.remove(); System.out.println(String.format("%s: %d", clientDetail.client, clientDetail.itemCount)); } jsc.stop(); System.out.println(String.format("--- finished GroupActionsJob date[%s] unixDays[%s] ---", cmdLineArgs.input_date_string, unixDays)); }
From source file:org.opennms.netmgt.correlation.ncs.DependencyLoadingRulesTest.java
private void verifyFacts() { List<Object> memObjects = m_engine.getMemoryObjects(); String memContents = memObjects.toString(); for (Object anticipated : m_anticipatedWorkingMemory) { assertTrue("Expected " + anticipated + " in memory but memory was " + memContents, memObjects.contains(anticipated)); memObjects.remove(anticipated);/* ww w .ja v a 2 s . c o m*/ } assertEquals("Unexpected objects in working memory " + memObjects, 0, memObjects.size()); }
From source file:com.google.code.joliratools.bind.apt.JAXROProcessorJSONTest.java
/** * Test the process with the -Ajaxroproc= parameters. * /*from w ww . j a va 2 s . c o m*/ * @throws Exception * something failed */ @Test public void testProcessProcSchemaOnly() throws Exception { final Compilation compilation = createCompilation(); compilation.doCompile(new PrintWriter(System.out), "-Ajaxroproc=schemaonly"); final List<Diagnostic<? extends JavaFileObject>> diagnostics = compilation.getDiagnostics(); assertEquals(diagnostics.toString(), 2, diagnostics.size()); final String schemaDocument = compilation .getGeneratedResource("com/google/code/joliratools/bind/demo/jaxro.xsd"); if (schemaDocument == null || schemaDocument.length() < 100) { fail("no schema document"); } }
From source file:schemacrawler.integration.test.SpringIntegrationTest.java
@Test public void testExecutableForXMLSerialization() throws Exception { final List<String> failures = new ArrayList<>(); final String beanDefinitionName = "executableForXMLSerialization"; final Object bean = appContext.getBean(beanDefinitionName); if (bean instanceof Executable) { final Executable executable = (Executable) bean; executeAndCheckForOutputFile(beanDefinitionName, executable, failures, true); }//from ww w . ja v a 2 s.co m if (failures.size() > 0) { fail(failures.toString()); } }
From source file:test.com.google.resting.RestingTest.java
public void testTrans() { System.out.println("\ntestTrans\n-----------------------------"); String text = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><standards> <standard> <id>1</id> <title>Safety</title> <parentId></parentId> <parentTitle></parentTitle> <level>0</level> </standard></standards>"; XMLAlias alias = new XMLAlias().add("standard", Standard.class).add("standards", Standards.class); //alias.addConverter(new MyStringConverter()); XMLTransformer trans = new XMLTransformer(); List<Standards> list = trans.getEntityList(text, Standards.class, alias); System.out.println(list.toString()); }
From source file:dao.LogtabDaoJdbc.java
/** * This method returns logtab bean for a given hotdiary login * @param login//w ww . j a v a 2s . c o m * @return Logtab * @throws BaseDaoException */ public Logtab getLogtab(String login) throws BaseDaoException { logger.info("LogtabDaoJdbc, getLogtab() login!" + login); LogtabQuery query = new LogtabQuery(ds); Object[] params = new Object[1]; params[0] = login; List result = query.execute(params); // for guestbook entries multiple rows are returned. if (result.size() == 1) { return (Logtab) result.get(0); } else { // TODO: add a method to get toString() for List. logger.error("Multiple logtab beans returned. Only one bean is expected to be returned!" + login + "Logtab beans returned = " + result.toString()); return null; } }
From source file:aldenjava.opticalmapping.miscellaneous.ExtendOptionParser.java
@Override public void printHelpOn(OutputStream sink) { try {//from ww w . ja v a 2 s. co m NullHelpFormatter nhf = new NullHelpFormatter(); super.formatHelpWith(nhf); super.printHelpOn(new NullOutputStream()); if (recentparser != null) subParser.add(recentparser); recentparser = null; if (title != null) { sink.write((" " + title + "\n").getBytes()); sink.write((StringUtils.repeat("=", 60) + "\n").getBytes()); } for (int i = 0; i < header.size(); i++) { String separateLine = ""; String leftAdjust = StringUtils.repeat(" ", (level.get(i) - 1) * 2); if (level.get(i) == 1) separateLine = StringUtils.repeat("=", 10); else separateLine = StringUtils.repeat("-", 10); sink.write(("\n" + leftAdjust + separateLine + header.get(i) + separateLine + "\n").getBytes()); int elements = optionList.get(i).size(); leftAdjust = " " + leftAdjust; for (int j = 0; j < elements; j++) { String option = "--" + optionList.get(i).get(j); String description = optionDescriptionList.get(i).get(j); List<?> defaultValues = nhf.options.get(optionList.get(i).get(j)).defaultValues(); description += String.format(" [Default: %s]", defaultValues.size() == 1 ? defaultValues.get(0).toString() : defaultValues.size() == 0 ? "" : defaultValues.toString()); List<String> descriptionList = this.paragraphSeparate(description, 50); sink.write( (leftAdjust + String.format("%-25s%s\n", option, descriptionList.get(0))).getBytes()); for (int k = 1; k < descriptionList.size(); k++) sink.write( (leftAdjust + String.format("%-25s %s\n", "", descriptionList.get(k))).getBytes()); } // subParser.get(i).printHelpOn(sink); } } catch (IOException e) { System.err.println("IO Error. Help menu is not displayed successfully."); e.printStackTrace(); } }
From source file:com.sm.store.client.ClientConnections.java
public void connectAll() { logger.info("create all connections"); Collection<List<Connection>> collection = clusterConnections.values(); for (List<Connection> each : collection) { for (int i = 0; i < each.size(); i++) { if (each.get(i).connect(timeout)) logger.info("connect to " + each.toString()); }//from www . j a va 2s. co m } }
From source file:edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.IndividualsForClassesDataGetter.java
public Map<String, Object> getData(ServletContext context, VitroRequest vreq, String pageUri, Map<String, Object> page) { this.setTemplateName(); HashMap<String, Object> data = new HashMap<String, Object>(); //This is the old technique of getting class intersections PageDao pageDao = vreq.getWebappDaoFactory().getPageDao(); Map<String, Object> classIntersectionsMap = getClassIntersectionsMap(pageDao, pageUri); try {// w ww .j a v a 2 s .c o m List<String> classes = retrieveClasses(context, classIntersectionsMap); List<String> restrictClasses = retrieveRestrictClasses(context, classIntersectionsMap); log.debug("Retrieving classes for " + classes.toString() + " and restricting by " + restrictClasses.toString()); processClassesAndRestrictions(vreq, context, data, classes, restrictClasses); //Also add data service url //Hardcoding for now, need a more dynamic way of doing this data.put("dataServiceUrlIndividualsByVClass", this.getDataServiceUrl()); //this is the class group associated with the data getter utilized for display on menu editing, not the custom one created data.put("classGroupUri", pageDao.getClassGroupPage(pageUri)); } catch (Exception ex) { log.error("An error occurred retrieving Vclass Intersection individuals", ex); } return data; }