use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testNoTransformation.
@Test
public void testNoTransformation() {
RLiveObjectService service = redisson.getLiveObjectService();
TestClassNoTransformation ts = new TestClassNoTransformation();
ts = service.persist(ts);
HashMap<String, String> m = new HashMap<>();
ts.setContent(m);
assertTrue(HashMap.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RMap.class.isAssignableFrom(ts.getContent().getClass()));
HashSet<String> s = new HashSet<>();
ts.setContent(s);
assertTrue(HashSet.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RSet.class.isAssignableFrom(ts.getContent().getClass()));
TreeSet<String> ss = new TreeSet<>();
ts.setContent(ss);
assertTrue(TreeSet.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RSortedSet.class.isAssignableFrom(ts.getContent().getClass()));
ArrayList<String> al = new ArrayList<>();
ts.setContent(al);
assertTrue(ArrayList.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RList.class.isAssignableFrom(ts.getContent().getClass()));
ConcurrentHashMap<String, String> chm = new ConcurrentHashMap<>();
ts.setContent(chm);
assertTrue(ConcurrentHashMap.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RMap.class.isAssignableFrom(ts.getContent().getClass()));
ArrayBlockingQueue<String> abq = new ArrayBlockingQueue<>(10);
abq.add("111");
ts.setContent(abq);
assertTrue(ArrayBlockingQueue.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RBlockingQueue.class.isAssignableFrom(ts.getContent().getClass()));
ConcurrentLinkedQueue<String> clq = new ConcurrentLinkedQueue<>();
ts.setContent(clq);
assertTrue(ConcurrentLinkedQueue.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RQueue.class.isAssignableFrom(ts.getContent().getClass()));
LinkedBlockingDeque<String> lbdq = new LinkedBlockingDeque<>();
ts.setContent(lbdq);
assertTrue(LinkedBlockingDeque.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RBlockingDeque.class.isAssignableFrom(ts.getContent().getClass()));
LinkedList<String> ll = new LinkedList<>();
ts.setContent(ll);
assertTrue(LinkedList.class.isAssignableFrom(ts.getContent().getClass()));
assertFalse(RDeque.class.isAssignableFrom(ts.getContent().getClass()));
}
use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testFieldWithoutIdSetter.
@Test
public void testFieldWithoutIdSetter() {
RLiveObjectService service = redisson.getLiveObjectService();
SimpleObject so = new SimpleObject();
so = service.persist(so);
so.setValue(10L);
so = redisson.getLiveObjectService().detach(so);
assertThat(so.getId()).isNotNull();
assertThat(so.getValue()).isEqualTo(10L);
so = redisson.getLiveObjectService().get(SimpleObject.class, so.getId());
assertThat(so.getId()).isNotNull();
assertThat(so.getValue()).isEqualTo(10L);
}
use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method test.
@Test
public void test() {
RLiveObjectService service = redisson.getLiveObjectService();
MyObject object = new MyObject(20L);
try {
service.attach(object);
} catch (Exception e) {
assertEquals("Non-null value is required for the field with RId annotation.", e.getMessage());
}
}
use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testClassRegistration.
@Test
public void testClassRegistration() {
RLiveObjectService service = redisson.getLiveObjectService();
service.registerClass(TestClass.class);
assertTrue(service.isClassRegistered(TestClass.class));
RLiveObjectService newService = redisson.getLiveObjectService();
assertTrue(newService.isClassRegistered(TestClass.class));
RedissonClient newRedisson = Redisson.create(redisson.getConfig());
assertFalse(newRedisson.getLiveObjectService().isClassRegistered(TestClass.class));
newRedisson.shutdown(1, 5, TimeUnit.SECONDS);
}
use of org.redisson.api.RLiveObjectService in project redisson by redisson.
the class RedissonLiveObjectServiceTest method testCreateObjectsInRuntime.
@Test
public void testCreateObjectsInRuntime() {
RLiveObjectService service = redisson.getLiveObjectService();
TestREntityWithMap so = new TestREntityWithMap();
so = service.persist(so);
so.getValue().put("1", "2");
so = redisson.getLiveObjectService().detach(so);
assertThat(so.getName()).isNotNull();
assertThat(so.getValue()).containsKey("1");
assertThat(so.getValue()).containsValue("2");
so = redisson.getLiveObjectService().get(TestREntityWithMap.class, so.getName());
assertThat(so.getName()).isNotNull();
assertThat(so.getValue()).containsKey("1");
assertThat(so.getValue()).containsValue("2");
}
Aggregations