public JsonRpcServer(@NotNull ClientManager clientManager) { this.clientManager = clientManager; gson = new GsonBuilder().registerTypeAdapter(CharSequenceBackedByArray.class, new JsonSerializer<CharSequenceBackedByArray>() { @Override public JsonElement serialize(CharSequenceBackedByArray src, Type typeOfSrc, JsonSerializationContext context) { return new JsonPrimitive(src.toString()); } }).registerTypeAdapterFactory(INT_LIST_TYPE_ADAPTER_FACTORY).disableHtmlEscaping().create(); }
@Config(text = "01234567", deferred = true) @Test public void subSequenceWithDeferredChangeBeforeIt() { replace(0, 2, "abc"); CharSequenceBackedByArray subsSequence = (CharSequenceBackedByArray)myArray.subSequence(5, 6); assertArrayEquals("4".toCharArray(), subsSequence.getChars()); }
@Config(text = "01234567", deferred = true) @Test public void subSequenceWithDeferredChangeIntersectingFromLeft() { replace(0, 2, "abc"); CharSequenceBackedByArray subsSequence = (CharSequenceBackedByArray)myArray.subSequence(2, 4); assertArrayEquals("c2".toCharArray(), subsSequence.getChars()); }
@Config(text = "01234567", deferred = true) @Test public void subSequenceWithDeferredChangeIntersectingFromRight() { replace(4, 6, "abc"); CharSequenceBackedByArray subsSequence = (CharSequenceBackedByArray)myArray.subSequence(3, 5); assertArrayEquals("3a".toCharArray(), subsSequence.getChars()); }
@Config(text = "01234567", deferred = true) @Test public void subSequenceWithDeferredChangeAfterIt() { replace(6, 8, "abc"); CharSequenceBackedByArray subsSequence = (CharSequenceBackedByArray)myArray.subSequence(1, 2); assertArrayEquals("1".toCharArray(), subsSequence.getChars()); }