Пример #1
0
 @Test
 public void testEmptyRemove() {
   RMap<Integer, Integer> map = redisson.getMap("simple");
   Assert.assertFalse(map.remove(1, 3));
   map.put(4, 5);
   Assert.assertTrue(map.remove(4, 5));
 }
Пример #2
0
 @Test
 public void testFastPut() throws Exception {
   RMap<Integer, Integer> map = redisson.getMap("simple");
   Assert.assertTrue(map.fastPut(1, 2));
   Assert.assertFalse(map.fastPut(1, 3));
   Assert.assertEquals(1, map.size());
 }
Пример #3
0
 @Test
 public void testFastRemoveEmpty() throws Exception {
   RMap<Integer, Integer> map = redisson.getMap("simple");
   map.put(1, 3);
   Assert.assertEquals(0, map.fastRemove());
   Assert.assertEquals(1, map.size());
 }
Пример #4
0
  @Test
  public void testFastRemoveAsync() throws InterruptedException, ExecutionException {
    RMap<Integer, Integer> map = redisson.getMap("simple");
    map.put(1, 3);
    map.put(3, 5);
    map.put(4, 6);
    map.put(7, 8);

    Assert.assertEquals((Long) 3L, map.fastRemoveAsync(1, 3, 7).get());
    Thread.sleep(1);
    Assert.assertEquals(1, map.size());
  }
Пример #5
0
  @Test
  public void testPutAsync() throws InterruptedException, ExecutionException {
    RMap<Integer, Integer> map = redisson.getMap("simple");
    Future<Integer> future = map.putAsync(2, 3);
    Assert.assertNull(future.get());

    Assert.assertEquals((Integer) 3, map.get(2));

    Future<Integer> future1 = map.putAsync(2, 4);
    Assert.assertEquals((Integer) 3, future1.get());

    Assert.assertEquals((Integer) 4, map.get(2));
  }
Пример #6
0
  @Test
  public void testGetAll() {
    RMap<Integer, Integer> map = redisson.getMap("getAll");
    map.put(1, 100);
    map.put(2, 200);
    map.put(3, 300);
    map.put(4, 400);

    Map<Integer, Integer> filtered = map.getAll(new HashSet<Integer>(Arrays.asList(2, 3, 5)));

    Map<Integer, Integer> expectedMap = new HashMap<Integer, Integer>();
    expectedMap.put(2, 200);
    expectedMap.put(3, 300);
    Assert.assertEquals(expectedMap, filtered);
  }
Пример #7
0
  @Test
  public void testGetAllWithStringKeys() {
    RMap<String, Integer> map = redisson.getMap("getAllStrings");
    map.put("A", 100);
    map.put("B", 200);
    map.put("C", 300);
    map.put("D", 400);

    Map<String, Integer> filtered = map.getAll(new HashSet<String>(Arrays.asList("B", "C", "E")));

    Map<String, Integer> expectedMap = new HashMap<String, Integer>();
    expectedMap.put("B", 200);
    expectedMap.put("C", 300);
    Assert.assertEquals(expectedMap, filtered);
  }
Пример #8
0
 @Override
 public Set<Location> findAll() {
   Set<Location> set = new HashSet<>();
   for (Map.Entry<String, Location> entry : lists.entrySet()) {
     set.add(entry.getValue());
   }
   return set;
 }
Пример #9
0
  @Test(timeout = 5000)
  public void testDeserializationErrorReturnsErrorImmediately() throws Exception {
    redisson.getConfig().setCodec(new JsonJacksonCodec());

    RMap<String, SimpleObjectWithoutDefaultConstructor> map =
        redisson.getMap("deserializationFailure");
    SimpleObjectWithoutDefaultConstructor object =
        new SimpleObjectWithoutDefaultConstructor("test-val");

    Assert.assertEquals("test-val", object.getTestField());
    map.put("test-key", object);

    try {
      map.get("test-key");
      Assert.fail("Expected exception from map.get() call");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #10
0
  @Test
  public void testFilterKeys() {
    RMap<Integer, Integer> map = redisson.getMap("filterKeys");
    map.put(1, 100);
    map.put(2, 200);
    map.put(3, 300);
    map.put(4, 400);

    Map<Integer, Integer> filtered =
        map.filterKeys(
            new Predicate<Integer>() {
              @Override
              public boolean apply(Integer input) {
                return input >= 2 && input <= 3;
              }
            });

    Map<Integer, Integer> expectedMap = new HashMap<Integer, Integer>();
    expectedMap.put(2, 200);
    expectedMap.put(3, 300);
    Assert.assertEquals(expectedMap, filtered);
  }
Пример #11
0
  @Test
  public void testAddAndGet() throws InterruptedException {
    RMap<Integer, Integer> map = redisson.getMap("getAll");
    map.put(1, 100);

    Integer res = map.addAndGet(1, 12);
    Assert.assertEquals(112, (int) res);
    res = map.get(1);
    Assert.assertEquals(112, (int) res);

    RMap<Integer, Double> map2 = redisson.getMap("getAll2");
    map2.put(1, new Double(100.2));

    Double res2 = map2.addAndGet(1, new Double(12.1));
    Assert.assertTrue(new Double(112.3).compareTo(res2) == 0);
    res2 = map2.get(1);
    Assert.assertTrue(new Double(112.3).compareTo(res2) == 0);
  }
Пример #12
0
  @Test
  public void testRemoveAsync() throws InterruptedException, ExecutionException {
    RMap<Integer, Integer> map = redisson.getMap("simple");
    map.put(1, 3);
    map.put(3, 5);
    map.put(7, 8);

    Assert.assertEquals((Integer) 3, map.removeAsync(1).get());
    Assert.assertEquals((Integer) 5, map.removeAsync(3).get());
    Assert.assertNull(map.removeAsync(10).get());
    Assert.assertEquals((Integer) 8, map.removeAsync(7).get());
  }
 @Override
 public LeaveTypeList findById(String s) {
   return lists.get(s);
 }
 @Override
 public void delete(LeaveTypeList entity) {
   lists.remove(entity.getId());
 }
Пример #15
0
 @Override
 public Location findById(String s) {
   return lists.get(s);
 }
Пример #16
0
 @Override
 public Location update(Location entity) {
   return lists.put(entity.getId(), entity);
 }
Пример #17
0
 @Override
 public void delete(Location entity) {
   lists.remove(entity.getId());
 }
 @Override
 public LeaveTypeList update(LeaveTypeList entity) {
   return lists.put(entity.getId(), entity);
 }