@Test
  public void testEntrySet() {
    Map<Integer, String> map = redisson.getMap("simple12");
    map.put(1, "12");
    map.put(2, "33");
    map.put(3, "43");

    Assert.assertEquals(3, map.entrySet().size());
    MatcherAssert.assertThat(map, Matchers.hasEntry(Matchers.equalTo(1), Matchers.equalTo("12")));
    MatcherAssert.assertThat(map, Matchers.hasEntry(Matchers.equalTo(2), Matchers.equalTo("33")));
    MatcherAssert.assertThat(map, Matchers.hasEntry(Matchers.equalTo(3), Matchers.equalTo("43")));
  }
  @Test
  public void testEvaluateCastFromObject() throws Exception {
    ToGeoFunction fn = getFunction(FUNCTION_NAME, DataTypes.OBJECT);

    Object val = fn.evaluate(Literal.newLiteral(DataTypes.OBJECT, VALID_OBJECT));
    assertThat(val, instanceOf(Map.class));
    Map<String, Object> valMap = (Map<String, Object>) val;
    assertThat(valMap.size(), is(2));
    assertThat(
        valMap,
        Matchers.allOf(
            Matchers.<String, Object>hasEntry("type", "Polygon"),
            Matchers.hasEntry("coordinates", VALID_OBJECT.get("coordinates"))));
  }
  @Test
  public void testStateFileCanBeRead() throws Exception {
    final MetricsLimiterStateManager out =
        new MetricsLimiterStateManager.Builder().setStateFile(STATE_FILE).build(_marks);
    out.writeState();

    final Map<String, Mark> inMarks = out.readState();

    Assert.assertEquals(2, inMarks.size());
    Assert.assertThat(
        inMarks,
        Matchers.allOf(
            Matchers.hasEntry(METRIC_A, new Mark(6, _time1)),
            Matchers.hasEntry(METRIC_B, new Mark(1, _time2))));
  }
 /**
  * ArrayMap can work as a map.
  *
  * @throws Exception If some problem inside
  */
 @Test
 public void worksAsANormalMap() throws Exception {
   final ConcurrentMap<Integer, String> map = new ConcurrentHashMap<Integer, String>(0);
   final String value = "first value";
   map.put(1, value);
   map.put(2, "second");
   MatcherAssert.assertThat(new ArrayMap<Integer, String>(map), Matchers.hasEntry(1, value));
 }
 /**
  * ArrayMap can make a map fluently.
  *
  * @throws Exception If some problem inside
  */
 @Test
 public void buildsMapFluently() throws Exception {
   MatcherAssert.assertThat(
       new ArrayMap<Integer, String>()
           .with(Tv.FIVE, "four")
           .with(Tv.FIVE, Integer.toString(Tv.FIVE))
           .with(Tv.FORTY, "fourty")
           .without(Tv.FORTY)
           .with(Tv.TEN, "ten"),
       Matchers.allOf(
           Matchers.not(Matchers.hasKey(Tv.FORTY)),
           Matchers.hasValue(Integer.toString(Tv.FIVE)),
           Matchers.hasKey(Tv.FIVE),
           Matchers.hasEntry(Tv.FIVE, Integer.toString(Tv.FIVE))));
 }
Beispiel #6
0
 /**
  * GithubProfile can fetch a YAML config.
  *
  * @throws Exception In case of error.
  */
 @Test
 public void fetchesYamlConfig() throws Exception {
   final Repo repo =
       GithubProfileTest.repo(
           Joiner.on('\n')
               .join(
                   "assets:",
                   "  test.xml: jeff/test1#test.xml",
                   "  beta: jeff/test1#test.xml",
                   "architect:",
                   " - jeff",
                   " - donald",
                   "merge:",
                   "  script: hello!"));
   final String yaml = "friends:\n  - jeff/test2";
   repo.github()
       .repos()
       .get(new Coordinates.Simple("jeff/test1"))
       .contents()
       .create(
           Json.createObjectBuilder()
               .add("path", ".rultor.yml")
               .add("message", "rultor config")
               .add("content", Base64.encodeBase64String(yaml.getBytes()))
               .build());
   final Profile profile = new GithubProfile(repo);
   MatcherAssert.assertThat(
       profile.read(),
       XhtmlMatchers.hasXPaths(
           "/p/entry[@key='merge']/entry[@key='script']",
           "/p/entry[@key='assets']/entry[@key='test.xml']",
           "/p/entry[@key='assets']/entry[@key='beta']"));
   MatcherAssert.assertThat(
       profile.read().xpath("/p/entry[@key='architect']/item/text()"),
       Matchers.contains("jeff", "donald"));
   MatcherAssert.assertThat(
       profile.assets(), Matchers.hasEntry(Matchers.equalTo("test.xml"), Matchers.notNullValue()));
 }
Beispiel #7
0
 // To fix generics bounding
 static Matcher<Map<? extends String, ?>> hasEntry(String key, Object value) {
   return Matchers.hasEntry(key, value);
 }