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:com.avanza.ymer.MongoDocumentCollectionTest.java

@Test
public void canLoadDocumentsRouted() throws Exception {
    DocumentPatch[] patches = {};/*from  w  w w. j  a  va2 s  .  c om*/
    MirroredObject<FakeSpaceObject> mirroredObject = MirroredObjectDefinition.create(FakeSpaceObject.class)
            .loadDocumentsRouted(true).documentPatches(patches).buildMirroredDocument();

    // Objects WITH routed field
    BasicDBObject doc1 = new BasicDBObject();
    doc1.put("_id", 1);
    doc1.put("value", "a");
    mirroredObject.setDocumentAttributes(doc1, new FakeSpaceObject(1, "a"));

    final BasicDBObject doc2 = new BasicDBObject();
    doc2.put("_id", 2);
    doc2.put("value", "b");
    mirroredObject.setDocumentAttributes(doc2, new FakeSpaceObject(2, "b"));

    // Objects WITHOUT routed field
    final BasicDBObject doc3 = new BasicDBObject();
    doc3.put("_id", 3);
    doc3.put("value", "c");

    final BasicDBObject doc4 = new BasicDBObject();
    doc4.put("_id", 4);
    doc4.put("value", "d");

    MongoDocumentCollectionTest testCollection = new MongoDocumentCollectionTest();
    DocumentCollection documentCollection = testCollection.createEmptyCollection();
    documentCollection.insertAll(doc1, doc2, doc3, doc4);

    MirroredObjectLoader<FakeSpaceObject> documentLoader = new MirroredObjectLoader<>(documentCollection,
            FakeMirroredDocumentConverter.create(), mirroredObject,
            SpaceObjectFilter.partitionFilter(mirroredObject, 2, 2), new MirrorContextProperties(2, 2),
            noOpPostReadProcessor());

    List<FakeSpaceObject> loadedSpaceObjects = documentLoader.loadAllObjects().stream()
            .map(LoadedDocument::getDocument).collect(Collectors.toList());

    assertTrue(loadedSpaceObjects.toString(), loadedSpaceObjects.contains(new FakeSpaceObject(1, "a")));
    assertTrue(loadedSpaceObjects.toString(), loadedSpaceObjects.contains(new FakeSpaceObject(3, "c")));
    assertEquals(2, loadedSpaceObjects.size());
}

From source file:com.avanza.ymer.MongoDocumentCollectionTest.java

@Test
public void canLoadDocumentsRoutedWithoutWriteBack() throws Exception {
    DocumentPatch[] patches = {};/* w ww. j a v  a2  s.co m*/
    MirroredObject<FakeSpaceObject> mirroredObject = MirroredObjectDefinition.create(FakeSpaceObject.class)
            .loadDocumentsRouted(true).writeBackPatchedDocuments(false).documentPatches(patches)
            .buildMirroredDocument();

    // Objects WITH routed field
    BasicDBObject doc1 = new BasicDBObject();
    doc1.put("_id", 1);
    doc1.put("value", "a");
    mirroredObject.setDocumentAttributes(doc1, new FakeSpaceObject(1, "a"));

    final BasicDBObject doc2 = new BasicDBObject();
    doc2.put("_id", 2);
    doc2.put("value", "b");
    mirroredObject.setDocumentAttributes(doc2, new FakeSpaceObject(2, "b"));

    // Objects WITHOUT routed field
    final BasicDBObject doc3 = new BasicDBObject();
    doc3.put("_id", 3);
    doc3.put("value", "c");

    final BasicDBObject doc4 = new BasicDBObject();
    doc4.put("_id", 4);
    doc4.put("value", "d");

    MongoDocumentCollectionTest testCollection = new MongoDocumentCollectionTest();
    DocumentCollection documentCollection = testCollection.createEmptyCollection();
    documentCollection.insertAll(doc1, doc2, doc3, doc4);

    MirroredObjectLoader<FakeSpaceObject> documentLoader = new MirroredObjectLoader<>(documentCollection,
            FakeMirroredDocumentConverter.create(), mirroredObject,
            SpaceObjectFilter.partitionFilter(mirroredObject, 1, 2), new MirrorContextProperties(2, 1),
            noOpPostReadProcessor());

    List<FakeSpaceObject> loadedSpaceObjects = documentLoader.loadAllObjects().stream()
            .map(LoadedDocument::getDocument).collect(Collectors.toList());

    assertTrue(loadedSpaceObjects.toString(), loadedSpaceObjects.contains(new FakeSpaceObject(2, "b")));
    assertTrue(loadedSpaceObjects.toString(), loadedSpaceObjects.contains(new FakeSpaceObject(4, "d")));
    assertEquals(2, loadedSpaceObjects.size());
}

From source file:org.alfresco.test.util.ContentAspectsTests.java

@Test
public void addAudioAspect() {
    contentAspect.addAspect(userName, password, siteName, plainDoc, DocumentAspect.AUDIO);
    List<Property<?>> properties = contentAspect.getProperties(userName, password, siteName, plainDoc);
    Assert.assertTrue(properties.toString().contains(DocumentAspect.AUDIO.getProperty()));
}

From source file:org.alfresco.test.util.ContentAspectsTests.java

@Test
public void addExifAspect() {
    contentAspect.addAspect(userName, password, siteName, plainDoc, DocumentAspect.EXIF);
    List<Property<?>> properties = contentAspect.getProperties(userName, password, siteName, plainDoc);
    Assert.assertTrue(properties.toString().contains(DocumentAspect.EXIF.getProperty()));
}

From source file:org.alfresco.test.util.ContentAspectsTests.java

@Test
public void addDocAspect() {
    Assert.assertTrue(site.exists(siteName, userName, password));
    Assert.assertFalse(doc.getId().isEmpty());
    contentAspect.addAspect(userName, password, siteName, plainDoc, DocumentAspect.DUBLIN_CORE);
    List<Property<?>> properties = contentAspect.getProperties(userName, password, siteName, plainDoc);
    Assert.assertTrue(properties.toString().contains(DocumentAspect.DUBLIN_CORE.getProperty()));
}

From source file:org.alfresco.test.util.ContentAspectsTests.java

@Test
public void addTagDocument() {
    String tag1 = "tag1" + System.currentTimeMillis();
    Assert.assertTrue(contentAction.addSingleTag(userName, password, siteName, plainDoc, tag1));
    List<Property<?>> properties = contentAspect.getProperties(userName, password, siteName, plainDoc);
    Assert.assertTrue(properties.toString().contains(DocumentAspect.TAGGABLE.getProperty()));
    String tagNodeRef = contentAction.getTagNodeRef(userName, password, siteName, plainDoc, tag1);
    List<?> values = contentAspect.getValues(properties, "cm:taggable");
    Assert.assertTrue(values.contains(tagNodeRef));
}

From source file:hudson.model.ItemGroupMixInTest.java

/**
 * This test unit makes sure that if part of the config.xml file is
 * deleted it will still load everything else inside the folder.
 * The test unit expects an IOException is thrown, and the one failed
 * job fails to load.//from  ww w.ja v  a  2s . c om
 */
@Issue("JENKINS-22811")
@Test
public void xmlFileFailsToLoad() throws Exception {
    MockFolder folder = r.createFolder("folder");
    assertNotNull(folder);

    AbstractProject project = folder.createProject(FreeStyleProject.class, "job1");
    AbstractProject project2 = folder.createProject(FreeStyleProject.class, "job2");
    AbstractProject project3 = folder.createProject(FreeStyleProject.class, "job3");

    File configFile = project.getConfigFile().getFile();

    List<String> lines = FileUtils.readLines(configFile).subList(0, 5);
    configFile.delete();

    // Remove half of the config.xml file to make "invalid" or fail to load
    FileUtils.writeByteArrayToFile(configFile, lines.toString().getBytes());
    for (int i = lines.size() / 2; i < lines.size(); i++) {
        FileUtils.writeStringToFile(configFile, lines.get(i), true);
    }

    // Reload Jenkins.
    r.jenkins.reload();

    // Folder
    assertNotNull("Folder failed to load.", r.jenkins.getItemByFullName("folder"));
    assertNull("Job should have failed to load.", r.jenkins.getItemByFullName("folder/job1"));
    assertNotNull("Other job in folder should have loaded.", r.jenkins.getItemByFullName("folder/job2"));
    assertNotNull("Other job in folder should have loaded.", r.jenkins.getItemByFullName("folder/job3"));
}

From source file:com.wso2telco.gsma.handlers.MIFEStepBasedSequenceHandler.java

private void writeLogHistory(HttpServletRequest request, AuthenticationContext context) {
    String authenticatedUser;/*from  ww w  .j ava2 s.  c  om*/
    String authenticators = "";
    Object amrValue;
    if (context.isRequestAuthenticated() && context.getSequenceConfig().getAuthenticatedUser() != null) {
        amrValue = context.getProperty("amr");
        authenticatedUser = context.getSequenceConfig().getAuthenticatedUser().getUserName();
    } else {
        amrValue = context.getProperty("failedamr");
        authenticatedUser = (String) context.getProperty("faileduser");
    }

    // authenticators
    if (null != amrValue && amrValue instanceof ArrayList<?>) {
        @SuppressWarnings("unchecked")
        List<String> amr = (ArrayList<String>) amrValue;
        authenticators = amr.toString();
    }

    try {
        String ipAddress = retrieveIPAddress(request);
        DbTracelog.LogHistory(context.getRequestType(), context.isRequestAuthenticated(),
                context.getSequenceConfig().getApplicationId(), authenticatedUser, authenticators, ipAddress);
    } catch (LogHistoryException ex) {
        log.error("Error occured while Login SP LogHistory", ex);
    }
}

From source file:org.tomitribe.tribestream.registryng.resources.RegistryResourceTest.java

@Test
@Retry/*from  ww w. j av  a 2s.  c  om*/
public void searchQuery() {
    final List<Endpoint> endpoints = em.createQuery("select e from Endpoint e", Endpoint.class).getResultList();

    // no query param
    final SearchPage root = registry.target().path("api/registry").request(MediaType.APPLICATION_JSON_TYPE)
            .get(SearchPage.class);
    assertEquals(endpoints.toString() + "\n\n" + root.getResults(), endpoints.size(), root.getTotal());

    // wildcard = no filter
    final SearchPage wildcard = registry.target().path("api/registry").queryParam("query", "*")
            .request(MediaType.APPLICATION_JSON_TYPE).get(SearchPage.class);
    assertEquals(endpoints.toString() + "\n\n" + root.getResults(), endpoints.size(), wildcard.getTotal());

    // custom query_string
    final SearchPage query = registry.target().path("api/registry").queryParam("query", "Estimates")
            .request(MediaType.APPLICATION_JSON_TYPE).get(SearchPage.class);
    assertEquals(query.toString(), 2, query.getTotal());
}

From source file:com.qubole.rubix.hadoop2.hadoop2CM.Hadoop2ClusterManager.java

@Override
public void initialize(Configuration conf) {
    super.initialize(conf);
    yconf = new YarnConfiguration();
    this.address = yconf.get(addressConf, address);
    this.serverAddress = address.substring(0, address.indexOf(":"));
    this.serverPort = Integer.parseInt(address.substring(address.indexOf(":") + 1));

    ExecutorService executor = Executors.newSingleThreadExecutor();
    nodesCache = CacheBuilder.newBuilder().refreshAfterWrite(getNodeRefreshTime(), TimeUnit.SECONDS)
            .build(CacheLoader.asyncReloading(new CacheLoader<String, List<String>>() {
                @Override// w  w w.  j a va  2  s  . c o m
                public List<String> load(String s) throws Exception {
                    if (!isMaster) {
                        // First time all nodes start assuming themselves as master and down the line figure out their role
                        // Next time onwards, only master will be fetching the list of nodes
                        return ImmutableList.of();
                    }
                    try {
                        StringBuffer response = new StringBuffer();
                        URL obj = getNodeURL();
                        HttpURLConnection httpcon = (HttpURLConnection) obj.openConnection();
                        httpcon.setRequestMethod("GET");
                        log.debug("Sending 'GET' request to URL: " + obj.toString());
                        int responseCode = httpcon.getResponseCode();
                        if (responseCode == HttpURLConnection.HTTP_OK) {
                            BufferedReader in = new BufferedReader(
                                    new InputStreamReader(httpcon.getInputStream()));
                            String inputLine;
                            while ((inputLine = in.readLine()) != null) {
                                response.append(inputLine);
                            }
                            in.close();
                            httpcon.disconnect();
                        } else {
                            log.info("/ws/v1/cluster/nodes failed due to " + responseCode
                                    + ". Setting this node as worker.");
                            isMaster = false;
                            httpcon.disconnect();
                            return ImmutableList.of();
                        }
                        Gson gson = new Gson();
                        Type type = new TypeToken<Nodes>() {
                        }.getType();
                        Nodes nodes = gson.fromJson(response.toString(), type);
                        List<Elements> allNodes = nodes.getNodes().getNode();
                        Set<String> hosts = new HashSet<>();

                        for (Elements node : allNodes) {
                            String state = node.getState();
                            log.debug("Hostname: " + node.getNodeHostName() + "State: " + state);
                            //keep only healthy data nodes
                            if (state.equalsIgnoreCase("Running") || state.equalsIgnoreCase("New")
                                    || state.equalsIgnoreCase("Rebooted")) {
                                hosts.add(node.getNodeHostName());
                            }
                        }

                        if (hosts.isEmpty()) {
                            throw new Exception("No healthy data nodes found.");
                        }

                        List<String> hostList = Lists.newArrayList(hosts.toArray(new String[0]));
                        Collections.sort(hostList);
                        log.debug("Hostlist: " + hostList.toString());
                        return hostList;
                    } catch (Exception e) {
                        throw Throwables.propagate(e);
                    }
                }
            }, executor));
}