Example usage for java.util Set toString

List of usage examples for java.util Set toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.mapr.synth.samplers.ZipSamplerTest.java

@Test
public void testZips() throws IOException {
    SchemaSampler s = new SchemaSampler(
            Resources.asCharSource(Resources.getResource("schema016.json"), Charsets.UTF_8).read());

    JsonNode v = s.sample();//from  ww  w  . j  a  v  a 2s .  c om
    // regression test given that we specify the seed
    assertEquals("65529", v.get("z").get("zip").asText());

    Multiset<String> laCounts = HashMultiset.create();

    double latitude = 0;
    double longitude = 0;
    double latitudeFuzzy = 0;
    double longitudeFuzzy = 0;
    boolean allInside1 = true;
    boolean allInside2 = true;
    for (int i = 0; i < N; i++) {
        v = s.sample();
        double x = v.get("z").get("longitude").asDouble();
        double y = v.get("z").get("latitude").asDouble();

        Set<String> ss = Sets.newTreeSet();
        Iterator<String> it = v.get("zLimited").fieldNames();
        while (it.hasNext()) {
            String field = it.next();
            ss.add(field);
        }
        assertEquals("[latitude, longitude, state, zip]", ss.toString());

        longitude += x;
        latitude += y;
        allInside1 &= isContinental(x, y);

        x = v.get("zContinental").get("longitude").asDouble();
        y = v.get("zContinental").get("latitude").asDouble();
        allInside2 &= isContinental(x, y);

        x = v.get("zFuzzy").get("longitude").asDouble();
        y = v.get("zFuzzy").get("latitude").asDouble();
        longitudeFuzzy += x;
        latitudeFuzzy += y;

        laCounts.add(v.get("zLosAngeles").get("zip").asText());
        assertTrue("Unexpected zip code in LA",
                v.get("zLosAngeles").get("zip").asText().matches("(9[0123]...)|(89...)"));

        assertTrue(v.get("zFlat").asText().matches("\\d\\d\\d\\d\\d"));
    }

    assertFalse("Expected non-continental samples", allInside1);
    assertTrue("Should not have had non-continental samples", allInside2);

    longitude = longitude / N;
    latitude = latitude / N;

    longitudeFuzzy = longitudeFuzzy / N;
    latitudeFuzzy = latitudeFuzzy / N;

    // these expected values are the true means of all zip code locations
    assertEquals(-90.88465, longitude, 2);
    assertEquals(38.47346, latitude, 2);

    assertEquals(-90.88465, longitudeFuzzy, 7);
    assertEquals(38.47346, latitudeFuzzy, 5);

    assertEquals(1365, laCounts.elementSet().size(), 50);
}

From source file:ubic.BAMSandAllen.TopTenInfo.java

private Map<String, String> getColInfo(String colname) throws Exception {
    Map<String, String> colStats = new HashMap<String, String>();

    colStats.put("Name", colname);
    double[] conValues = connectivity.getColumnByName(colname);
    String connections = "";
    for (String conRow : connectivity.getRowNames()) {
        if (connectivity.getByKeys(conRow, colname) == 1d) {
            connections += "|" + conRow;
        }//from  w  w  w.  ja  va2  s  . c  o m
    }
    colStats.put("connections", connections);

    double[] expValues = expression.getColumnByName(colname);
    colStats.put("connectionCount", "" + Util.sum(conValues));

    // assume one allen name
    StructureCatalogLoader allenCatalog = new StructureCatalogLoader();

    colStats.put("MotorRegion", "" + motorRegions.contains(colname));
    colStats.put("x", "" + forCoords.getX(colname));
    colStats.put("y", "" + forCoords.getY(colname));
    colStats.put("z", "" + forCoords.getZ(colname));

    if (pair.isVirtualRegion(colname)) {
        colStats.put("allen names", colname);
        colStats.put("virtual", "true");
    } else {
        colStats.put("virtual", "false");
        Set<String> allennames = allenCatalog.getAllenMappedRegions(colname);
        String allenName;
        colStats.put("allen names", allennames.toString());
        if (!allennames.isEmpty()) {
            allenName = allennames.iterator().next();
            AllenAtlasAnnotationLoader spaceLoader = new AllenAtlasAnnotationLoader();
            DoubleMatrix<String, String> volumeMatrix = spaceLoader.getVolumeMatrix();
            colStats.put("volume", "" + volumeMatrix.getByKeys("volume", allenName));
        }
    }

    boolean removeNaNs = true;
    colStats.put("expSum", "" + Util.sum(expValues, removeNaNs));
    colStats.put("expNaNs", "" + Util.countNaNs(expValues));
    return colStats;
}

From source file:org.sonatype.nexus.index.FullIndexNexusIndexerTest.java

public void testBrokenJar() throws Exception {
    Query q = nexusIndexer.constructQuery(ArtifactInfo.ARTIFACT_ID, "brokenjar");

    FlatSearchRequest searchRequest = new FlatSearchRequest(q);

    FlatSearchResponse response = nexusIndexer.searchFlat(searchRequest);

    Set<ArtifactInfo> r = response.getResults();

    assertEquals(r.toString(), 1, r.size());

    ArtifactInfo ai = r.iterator().next();

    assertEquals("brokenjar", ai.groupId);
    assertEquals("brokenjar", ai.artifactId);
    assertEquals("1.0", ai.version);
    assertEquals(null, ai.classNames);//from www .  java 2 s  .  c o  m
}

From source file:se.frostyelk.cordova.parse.plugin.ParsePlugin.java

private PluginResult getSubscriptions(final CallbackContext callbackContext) {
    cordova.getThreadPool().execute(new Runnable() {
        public void run() {
            Set<String> subscriptions = PushService.getSubscriptions(cordova.getActivity());
            callbackContext.success(subscriptions.toString());
        }/*www  .ja v  a 2  s.  co  m*/
    });

    return null;
}

From source file:org.sonatype.nexus.index.FullIndexNexusIndexerTest.java

public void testMissingPom() throws Exception {
    Query q = nexusIndexer.constructQuery(ArtifactInfo.ARTIFACT_ID, "missingpom");

    FlatSearchRequest searchRequest = new FlatSearchRequest(q);

    FlatSearchResponse response = nexusIndexer.searchFlat(searchRequest);

    Set<ArtifactInfo> r = response.getResults();

    assertEquals(r.toString(), 1, r.size());

    ArtifactInfo ai = r.iterator().next();

    assertEquals("missingpom", ai.groupId);
    assertEquals("missingpom", ai.artifactId);
    assertEquals("1.0", ai.version);
    // See Nexus 2318. It should be null for a jar without classes
    assertNull(ai.classNames);/*  ww w .  j  a v  a2 s  .  co m*/
}

From source file:org.springframework.data.repository.cdi.CdiRepositoryBean.java

@SuppressWarnings("rawtypes")
public Set<Type> getTypes() {

    Set<Class> interfaces = new HashSet<Class>();
    interfaces.add(repositoryType);/*from w w  w  .  j  a  v a 2 s .co m*/
    interfaces.addAll(Arrays.asList(repositoryType.getInterfaces()));

    if (LOG.isDebugEnabled()) {
        LOG.debug(String.format("Declaring types '%s' for repository '%s'.", interfaces.toString(),
                repositoryType.getName()));
    }

    return new HashSet<Type>(interfaces);
}

From source file:org.openmhealth.data.generator.Application.java

/**
 * @return true if the requests are valid, false otherwise
 *//*from w  w  w.  jav  a2s .  c  o m*/
private boolean areMeasureGenerationRequestsValid() {

    List<MeasureGenerationRequest> requests = dataGenerationSettings.getMeasureGenerationRequests();
    Joiner joiner = Joiner.on(", ");

    for (int i = 0; i < requests.size(); i++) {
        MeasureGenerationRequest request = requests.get(i);

        Set<ConstraintViolation<MeasureGenerationRequest>> constraintViolations = validator.validate(request);

        if (!constraintViolations.isEmpty()) {
            log.error("The measure generation request with index {} is not valid.", i);
            log.error(request.toString());
            log.error(constraintViolations.toString());
            return false;
        }

        if (!dataPointGeneratorMap.containsKey(request.getGeneratorName())) {
            log.error("The data generator '{}' in request {} doesn't exist.", request.getGeneratorName(), i);
            log.error(request.toString());
            log.error("The allowed data generators are: {}", joiner.join(dataPointGeneratorMap.keySet()));
            return false;
        }

        DataPointGenerator<?> generator = dataPointGeneratorMap.get(request.getGeneratorName());

        Set<String> specifiedTrendKeys = request.getTrends().keySet();
        Set<String> requiredTrendKeys = generator.getRequiredValueGroupKeys();

        if (!specifiedTrendKeys.containsAll(requiredTrendKeys)) {
            log.error("Request {} for generator '{}' is missing required trend keys.", i, generator.getName());
            log.error("The generator requires the following missing keys: {}.",
                    joiner.join(Sets.difference(requiredTrendKeys, specifiedTrendKeys)));
            return false;
        }

        Set<String> supportedTrendKeys = generator.getSupportedValueGroupKeys();

        if (!supportedTrendKeys.containsAll(specifiedTrendKeys)) {
            log.warn("Request {} for generator '{}' specifies unsupported trend keys.", i, generator.getName());
            log.warn("The generator supports the following keys: {}.", joiner.join(supportedTrendKeys));
            log.warn("The following keys are being ignored: {}.",
                    joiner.join(Sets.difference(specifiedTrendKeys, supportedTrendKeys)));
        }
    }

    return true;
}

From source file:de.iteratec.iteraplan.general.PropertiesTest.java

private void logDifferences(Set<?> first, Set<?> second) {
    Set<Object> firstCopy = new HashSet<Object>(first);
    firstCopy.removeAll(second);/*from  w  ww.j a  va  2  s.c om*/
    LOGGER.info(firstCopy.toString());
}

From source file:com.abixen.platform.service.businessintelligence.multivisualization.service.impl.AbstractDatabaseService.java

private StringBuilder buildQueryForDataSourceData(DatabaseDataSource databaseDataSource,
        Set<String> chartColumnsSet, ResultSetMetaData resultSetMetaData) throws SQLException {
    StringBuilder stringBuilder = new StringBuilder("SELECT ");
    stringBuilder.append(chartColumnsSet.toString().substring(1, chartColumnsSet.toString().length() - 1));
    stringBuilder.append(" FROM ");
    stringBuilder.append(databaseDataSource.getTable());
    stringBuilder.append(" WHERE ");
    stringBuilder/* w  w w. j a va 2 s .c  o  m*/
            .append(jsonFilterService.convertJsonToJpql(databaseDataSource.getFilter(), resultSetMetaData));
    return stringBuilder;
}

From source file:org.hobbit.storage.queries.ExampleGraphValidityTest.java

@Test
public void test() throws IOException {
    Assert.assertNotNull(modelFile);/*from  w  w w  . ja  v a2 s  .  c  om*/
    Model model = loadModel(modelFile);

    StmtIterator iterator = model.listStatements();
    Statement s;
    Set<String> wrongUris = new HashSet<>();
    while (iterator.hasNext()) {
        s = iterator.next();
        check(s.getSubject(), wrongUris);
        check(s.getPredicate(), wrongUris);
        check(s.getObject(), wrongUris);
    }
    Assert.assertTrue("The model \"" + modelFile + "\" contains the unknown resources " + wrongUris.toString(),
            wrongUris.size() == 0);
}