Example usage for java.util List toString

List of usage examples for java.util List toString

Introduction

In this page you can find the example usage for java.util List toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:kr.co.bitnine.octopus.sql.OctopusSqlTest.java

private static <E> Matcher<List<E>> listEqualTo(final List<E> expected) {
    return new TypeSafeMatcher<List<E>>() {
        @Override//from  ww  w . j a  v a 2s  .  c o  m
        protected boolean matchesSafely(List<E> actual) {
            if (expected == actual)
                return true;
            if (expected == null)
                return false;

            if (expected.size() != actual.size())
                return false;
            if (!expected.containsAll(actual))
                return false;

            return true;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText(expected.toString());
        }
    };
}

From source file:com.liferay.blade.samples.integration.test.utils.BladeCLIUtil.java

public static String execute(File workingDir, String... bladeArgs) throws Exception {

    String bladeCLIJarPath = getLatestBladeCLIJar();

    List<String> command = new ArrayList<>();

    command.add("java");
    command.add("-jar");
    command.add(bladeCLIJarPath);//from  ww  w  . j a  va2  s.c  om

    for (String arg : bladeArgs) {
        command.add(arg);
    }

    Process process = new ProcessBuilder(command.toArray(new String[0])).directory(workingDir).start();

    process.waitFor();

    InputStream stream = process.getInputStream();

    String output = new String(IO.read(stream));

    InputStream errorStream = process.getErrorStream();

    List<String> errorList = new ArrayList<>();

    String stringStream = null;

    if (errorStream != null) {
        stringStream = new String(IO.read(errorStream));

        errorList.add(stringStream);
    }

    List<String> filteredErrorList = new ArrayList<>();

    for (String string : errorList) {
        String exclusion = "(.*setlocale.*)";

        Pattern p = Pattern.compile(exclusion, Pattern.DOTALL);

        Matcher m = p.matcher(string);

        while (m.find()) {
            filteredErrorList.add(string);
        }

        if (string.contains("Picked up JAVA_TOOL_OPTIONS:")) {
            filteredErrorList.add(string);
        }
    }

    errorList.removeAll(filteredErrorList);

    Assert.assertTrue(errorList.toString(), errorList.size() <= 1);

    if (errorList.size() == 1) {
        Assert.assertTrue(errorList.get(0), errorList.get(0).isEmpty());
    }

    return output;
}

From source file:org.openbaton.utils.rabbit.RabbitManager.java

public static List<String> getQueues(String brokerIp, String username, String password, int managementPort)
        throws IOException {
    List<String> result = new ArrayList<>();
    String encoding = Base64.encodeBase64String((username + ":" + password).getBytes());
    HttpGet httpGet = new HttpGet("http://" + brokerIp + ":" + managementPort + "/api/queues/");
    httpGet.setHeader("Authorization", "Basic " + encoding);

    log.trace("executing request " + httpGet.getRequestLine());
    HttpClient httpclient = HttpClients.createDefault();
    HttpResponse response = httpclient.execute(httpGet);
    HttpEntity entity = response.getEntity();

    InputStreamReader inputStreamReader = new InputStreamReader(entity.getContent());

    JsonArray array = gson.fromJson(inputStreamReader, JsonArray.class);
    if (array != null)
        for (JsonElement queueJson : array) {
            String name = queueJson.getAsJsonObject().get("name").getAsString();
            result.add(name);/*from w w  w . ja va  2  s.c  o m*/
            log.trace("found queue: " + name);
        }
    //TODO check for errors
    log.trace("found queues: " + result.toString());
    return result;
}

From source file:HttpServerDemo.java

public void handle(HttpExchange exchange) throws IOException {
    String requestMethod = exchange.getRequestMethod();
    if (requestMethod.equalsIgnoreCase("GET")) {
        Headers responseHeaders = exchange.getResponseHeaders();
        responseHeaders.set("Content-Type", "text/plain");
        exchange.sendResponseHeaders(200, 0);

        OutputStream responseBody = exchange.getResponseBody();
        Headers requestHeaders = exchange.getRequestHeaders();
        Set<String> keySet = requestHeaders.keySet();
        Iterator<String> iter = keySet.iterator();
        while (iter.hasNext()) {
            String key = iter.next();
            List values = requestHeaders.get(key);
            String s = key + " = " + values.toString() + "\n";
            responseBody.write(s.getBytes());
        }//  w  ww  . j  a  v a  2  s .c o  m
        responseBody.close();
    }
}

From source file:com.odoo.core.rpc.helper.OArguments.java

public OArguments add(List<Object> datas) {
    try {//from  w w  w . ja  va2s .c o  m
        add(new JSONArray(datas.toString()));
    } catch (JSONException e) {
    }
    return this;
}

From source file:delfos.rs.trustbased.WeightedGraph.java

private static void validateWeightMatrix(double[][] weightMatrix) {

    List<Double> wrongValues = IntStream.range(0, weightMatrix.length).boxed().map(row -> weightMatrix[row])
            .flatMap(row -> IntStream.range(0, row.length).boxed().map(collumn -> row[collumn]))
            .filter(value -> (value > 1.0) || (value < 0.0)).collect(Collectors.toList());

    if (!wrongValues.isEmpty()) {
        throw new IllegalStateException(
                "Value must be given in [0,1] interval and it was: " + wrongValues.toString());
    }//w  w w  . j a  v a2  s  .  c  om
}

From source file:com.tapas.evidence.service.CodeListService.java

public List<StateDTO> getStates() {
    final List<State> states = repository.findAll();
    log.debug("Loaded states:", states.toString());
    return DTOConverter.convertList(states, StateDTO.class);
}

From source file:org.cloudfoundry.identity.uaa.scim.job.GenericSqlTasklet.java

@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    if (sql == null) {
        return RepeatStatus.FINISHED;
    }//www  .  ja  v  a  2s  .  c  om
    if (sql.toLowerCase().startsWith("select")) {
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        String result = list.toString();
        chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().put("result",
                result.substring(0, Math.min(result.length(), 4096)));
    } else {
        int updated = jdbcTemplate.update(sql);
        contribution.incrementWriteCount(updated);
    }
    return RepeatStatus.FINISHED;
}

From source file:com.aquest.emailmarketing.web.service.CampaignsService.java

/**
 * Gets the campaigns.//from   www.  j  a  v a  2 s .  c o m
 *
 * @return the campaigns
 */
public List<Campaigns> getCampaigns() {
    logger.debug("Ovo se pokrenulo");
    ;
    List<Campaigns> campaigns = campaignsDao.getCampaigns();
    logger.debug(campaigns.toString());
    return campaigns;
}

From source file:de.langmi.spring.batch.examples.complex.skip.simple.SkipJobListener.java

@Override
public void afterWrite(List<? extends String> items) {
    LOG.debug("after write:" + items.toString());
}