author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
426,504
01.08.2020 15:53:55
-7,200
a1c2a80d4edf664ca0c12e53c9d74545ecafee6f
transform IBulkQuery
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/BulkQuery.kt", "new_path": "model-client/src/main/java/org/modelix/model/lazy/BulkQuery.kt", "diff": "@@ -16,9 +16,9 @@ import kotlin.collections.HashMap\n* Not thread safe\n*/\nclass BulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\n- private var queue: MutableList<Tuple3<String, Function<String, *>, Consumer<Any?>>> = ArrayList()\n+ private var queue: MutableList<Tuple3<String, Function<String?, *>, Consumer<Any?>>> = ArrayList()\nprivate var processing = false\n- protected fun executeBulkQuery(keys: Iterable<String>, deserializers: Map<String, Function<String, *>>): Map<String, Any> {\n+ protected fun executeBulkQuery(keys: Iterable<String>, deserializers: Map<String, Function<String?, *>>): Map<String, Any> {\nval values = store.getAll(keys, BiFunction<String?, String?, Any> { key: String?, serialized: String? -> deserializers[key]!!.apply(serialized!!) })\nval result: MutableMap<String, Any> = HashMap()\nrun {\n@@ -35,13 +35,13 @@ class BulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\nreturn result\n}\n- fun query(key: String, deserializer: Function<String, *>, callback: Consumer<Any?>) {\n- queue.add(Tuple.of<String, Function<String, *>, Consumer<Any?>>(key, deserializer, callback))\n+ fun query(key: String, deserializer: Function<String?, *>, callback: Consumer<Any?>) {\n+ queue.add(Tuple.of<String, Function<String?, *>, Consumer<Any?>>(key, deserializer, callback))\n}\n- override fun <T> get(hash: String, deserializer: Function<String, T>): IBulkQuery.Value<T> {\n+ override fun <T> get(hash: String?, deserializer: Function<String?, T>?): IBulkQuery.Value<T>? {\nval result = Value<T>()\n- query(hash, deserializer, Consumer { value: Any? -> result.success(value as T) })\n+ query(hash!!, deserializer as Function<String?, *>, Consumer { value: Any? -> result.success(value as T) })\nreturn result\n}\n@@ -56,18 +56,18 @@ class BulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\nprocessing = true\ntry {\nwhile (!queue.isEmpty()) {\n- val currentRequests: List<Tuple3<String, Function<String, *>, Consumer<Any?>>> = queue\n+ val currentRequests: List<Tuple3<String, Function<String?, *>, Consumer<Any?>>> = queue\nqueue = ArrayList()\n- val deserializers: MutableMap<String, Function<String, *>> = HashMap()\n+ val deserializers: MutableMap<String, Function<String?, *>> = HashMap()\nfor (request in currentRequests) {\ndeserializers[request._1()] = request._2()\n}\nval entries = executeBulkQuery(\ncurrentRequests.stream()\n- .map { obj: Tuple3<String, Function<String, *>, Consumer<Any?>> -> obj._1() }\n+ .map { obj: Tuple3<String, Function<String?, *>, Consumer<Any?>> -> obj._1() }\n.distinct()\n.collect(Collectors.toList()),\n- deserializers\n+ deserializers.toMap()\n)\nfor (request in currentRequests) {\nrequest._3().accept(entries[request._1()])\n@@ -78,17 +78,17 @@ class BulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\n}\n}\n- override fun <I, O> map(input_: Iterable<I>, f: Function<I, IBulkQuery.Value<O>>): IBulkQuery.Value<List<O>> {\n- val input = StreamSupport.stream(input_.spliterator(), false).collect(Collectors.toList())\n+ override fun <I, O> map(input_: Iterable<I>?, f: Function<I, IBulkQuery.Value<O>?>?): IBulkQuery.Value<List<O>?>? {\n+ val input = StreamSupport.stream(input_!!.spliterator(), false).collect(Collectors.toList())\nif (input.isEmpty()) {\nreturn constant(emptyList())\n}\nval output = arrayOfNulls<Any>(input.size)\nval done = BooleanArray(input.size)\nval remaining = MutableInt(input.size)\n- val result = Value<List<O>>()\n+ val result = Value<List<O>?>()\nfor (i_ in input.indices) {\n- f.apply(input[i_]).onSuccess(\n+ f!!.apply(input[i_])!!.onSuccess(\nConsumer { value ->\nif (done[i_]) {\nreturn@Consumer\n@@ -128,11 +128,11 @@ class BulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\n}\n@Synchronized\n- override fun onSuccess(handler: Consumer<T?>) {\n+ override fun onSuccess(handler: Consumer<T?>?) {\nif (done) {\n- handler.accept(value)\n+ handler!!.accept(value!!)\n} else {\n- handlers!!.add(handler)\n+ handlers!!.add(handler!!)\n}\n}\n@@ -144,15 +144,15 @@ class BulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\nreturn value!!\n}\n- override fun <R> map(handler: Function<T, R>): IBulkQuery.Value<R> {\n+ override fun <R> map(handler: Function<T, R>?): Value<R>? {\nval result = Value<R>()\n- onSuccess { v: T? -> result.success(handler.apply(v!!)) }\n+ onSuccess(Consumer { v: T? -> result.success(handler!!.apply(v!!)) })\nreturn result\n}\n- override fun <R> mapBulk(handler: Function<T, IBulkQuery.Value<R>>): IBulkQuery.Value<R> {\n+ override fun <R> mapBulk(handler: Function<T, IBulkQuery.Value<R>?>?): IBulkQuery.Value<R>? {\nval result = Value<R>()\n- onSuccess { v: T? -> handler.apply(v!!).onSuccess { value: R -> result.success(value) } }\n+ onSuccess(Consumer { v: T? -> handler!!.apply(v!!)!!.onSuccess(Consumer { value: R? -> result.success(value!!) }) })\nreturn result\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLHamtInternal.kt", "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLHamtInternal.kt", "diff": "@@ -6,6 +6,7 @@ import org.modelix.model.persistent.HashUtil\nimport org.modelix.model.util.pmap.COWArrays\nimport org.modelix.model.util.pmap.LongKeyPMap\nimport java.util.function.BiPredicate\n+import java.util.function.Function\nclass CLHamtInternal : CLHamtNode<CPHamtInternal?> {\nprivate val data: CPHamtInternal\n@@ -41,26 +42,28 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\n}\n}\n- override fun get(key: Long, shift: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<String> {\n+ override fun get(key: Long, shift: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<String?>? {\nval childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n- return getChild(childIndex, bulkQuery).mapBulk<String> { child: CLHamtNode<*>? ->\n+ // getChild(logicalIndex: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n+ return getChild(childIndex, bulkQuery).mapBulk<String?>(Function { child: CLHamtNode<*>? ->\nif (child == null) {\n- return@mapBulk bulkQuery.constant<String?>(null)\n- }\n+ bulkQuery.constant<String?>(null)\n+ } else {\nchild[key, shift + BITS_PER_LEVEL, bulkQuery]\n}\n+ })\n}\nprotected fun getChild(logicalIndex: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\nif (isBitNotSet(data.bitmap, logicalIndex)) {\n- return bulkQuery.constant(null)\n+ return bulkQuery.constant(null) as IBulkQuery.Value<CLHamtNode<*>?>\n}\nval physicalIndex = logicalToPhysicalIndex(data.bitmap, logicalIndex)\nreturn getChild(data.children[physicalIndex], bulkQuery)\n}\nprotected fun getChild(childHash: String?, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n- return bulkQuery.get(childHash, CPHamtNode.DESERIALIZER).map { childData: CPHamtNode? -> create(childData, store) }\n+ return bulkQuery.get(childHash, CPHamtNode.DESERIALIZER)!!.map(Function { childData: CPHamtNode? -> create(childData, store) })!!\n}\nprotected fun getChild(logicalIndex: Int): CLHamtNode<*>? {\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/IBulkQuery.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import java.util.List;\n-import java.util.function.Consumer;\n-import java.util.function.Function;\n-\n-public interface IBulkQuery {\n- <I, O> Value<List<O>> map(Iterable<I> input_, Function<I, Value<O>> f);\n- <T> Value<T> constant(T value);\n- <T> Value<T> get(String hash, Function<String, T> deserializer);\n-\n-\n- interface Value<T> {\n- T execute();\n- <R> Value<R> mapBulk(final Function<T, Value<R>> handler);\n- <R> Value<R> map(Function<T, R> handler);\n- void onSuccess(Consumer<T> handler);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/IBulkQuery.kt", "diff": "+package org.modelix.model.lazy\n+\n+import java.util.function.Consumer\n+import java.util.function.Function\n+\n+interface IBulkQuery {\n+ fun <I, O> map(input_: Iterable<I>?, f: Function<I, Value<O>?>?): Value<List<O>?>?\n+ fun <T> constant(value: T): Value<T>?\n+ operator fun <T> get(hash: String?, deserializer: Function<String?, T>?): Value<T>?\n+ interface Value<T> {\n+ fun execute(): T\n+ fun <R> mapBulk(handler: Function<T, Value<R>?>?): Value<R>?\n+ fun <R> map(handler: Function<T, R>?): Value<R>?\n+ fun onSuccess(handler: Consumer<T?>?)\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/NonBulkQuery.kt", "new_path": "model-client/src/main/java/org/modelix/model/lazy/NonBulkQuery.kt", "diff": "@@ -6,8 +6,8 @@ import java.util.function.Function\nimport java.util.stream.Collectors\nclass NonBulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery {\n- override fun <I, O> map(input: Iterable<I>, f: Function<I, IBulkQuery.Value<O>>): IBulkQuery.Value<List<O>> {\n- val list = toStream(input).map(f).map(Function<IBulkQuery.Value<O>, O> { it.execute() }).collect(Collectors.toList())\n+ override fun <I, O> map(input_: Iterable<I>?, f: Function<I, IBulkQuery.Value<O>?>?): IBulkQuery.Value<List<O>?>? {\n+ val list = toStream(input_!!).map(f).map(Function<IBulkQuery.Value<O>?, O> { it!!.execute() }).collect(Collectors.toList())\nreturn Value(list)\n}\n@@ -15,7 +15,7 @@ class NonBulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery\nreturn Value(value)\n}\n- override fun <T> get(hash: String, deserializer: Function<String?, T>): IBulkQuery.Value<T> {\n+ override fun <T> get(hash: String?, deserializer: Function<String?, T>?): IBulkQuery.Value<T>? {\nreturn constant(store.get(hash, deserializer)!!)\n}\n@@ -24,16 +24,16 @@ class NonBulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery\nreturn value\n}\n- override fun <R> mapBulk(handler: Function<T, IBulkQuery.Value<R>>): IBulkQuery.Value<R> {\n- return handler.apply(value)\n+ override fun <R> mapBulk(handler: Function<T, IBulkQuery.Value<R>?>?): IBulkQuery.Value<R>? {\n+ return handler!!.apply(value)\n}\n- override fun <R> map(handler: Function<T, R>): IBulkQuery.Value<R> {\n- return Value(handler.apply(value))\n+ override fun <R> map(handler: Function<T, R>?): IBulkQuery.Value<R>? {\n+ return Value(handler!!.apply(value))\n}\n- override fun onSuccess(handler: Consumer<T>) {\n- handler.accept(value)\n+ override fun onSuccess(handler: Consumer<T?>?) {\n+ handler!!.accept(value)\n}\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
transform IBulkQuery
426,504
01.08.2020 15:54:47
-7,200
0ef1bd5f06c1ff290e74476f2fb00b55d33f2ab9
translate LazyLoaded
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/LazyLoaded.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-public abstract class LazyLoaded<E> {\n-\n- protected String hash;\n- protected IDeserializingKeyValueStore store;\n-\n- public LazyLoaded(String hash, IDeserializingKeyValueStore store) {\n- this.hash = hash;\n- this.store = store;\n- }\n-\n- protected void init() {\n- if (hash == null) {\n- return;\n- }\n- try {\n- E deserialized = store.get(hash, this::deserialize);\n- init(deserialized);\n- } finally {\n- store = null;\n- hash = null;\n- }\n- }\n-\n- protected abstract void init(E data);\n- public abstract E deserialize(String serialized);\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/LazyLoaded.kt", "diff": "+package org.modelix.model.lazy\n+\n+import java.util.function.Function\n+\n+abstract class LazyLoaded<E>(protected var hash: String?, protected var store: IDeserializingKeyValueStore?) {\n+ protected fun init() {\n+ if (hash == null) {\n+ return\n+ }\n+ try {\n+ val deserialized = store!![hash, Function { serialized: String? -> deserialize(serialized) }]\n+ init(deserialized)\n+ } finally {\n+ store = null\n+ hash = null\n+ }\n+ }\n+\n+ protected abstract fun init(data: E?)\n+ abstract fun deserialize(serialized: String?): E\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate LazyLoaded
426,504
01.08.2020 15:55:29
-7,200
b00e6a8982e015740d51e25518c2df4eda54980d
translate LazyValue
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/LazyValue.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.modelix.model.IKeyValueStore;\n-\n-public abstract class LazyValue<E> {\n- private IKeyValueStore store;\n- private String hash;\n- private E value;\n-\n- public abstract E deserialize(String input);\n- public E getValue() {\n- if (hash != null) {\n- value = deserialize(store.get(hash));\n- hash = null;\n- store = null;\n- }\n- return value;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/LazyValue.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.modelix.model.IKeyValueStore\n+\n+abstract class LazyValue<E> {\n+ private var store: IKeyValueStore? = null\n+ private var hash: String? = null\n+ var value: E? = null\n+ get() {\n+ if (hash != null) {\n+ field = deserialize(store!![hash])\n+ hash = null\n+ store = null\n+ }\n+ return field\n+ }\n+ private set\n+\n+ abstract fun deserialize(input: String?): E\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate LazyValue
426,504
01.08.2020 16:00:30
-7,200
c8477ac421ca1e12b05141c08b1da3dfee4d21ab
convert CLHamtLeaf
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLHamtLeaf.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.apache.commons.lang3.mutable.MutableObject;\n-import org.modelix.model.persistent.CPHamtLeaf;\n-import org.modelix.model.persistent.CPHamtNode;\n-import org.modelix.model.persistent.HashUtil;\n-\n-import java.util.Objects;\n-import java.util.function.BiPredicate;\n-\n-public class CLHamtLeaf extends CLHamtNode<CPHamtLeaf> {\n-\n- public static CLHamtLeaf create(long key, String value, IDeserializingKeyValueStore store) {\n- return (value == null ? null : new CLHamtLeaf(key, value, store));\n- }\n-\n- private final CPHamtLeaf data;\n-\n- public CLHamtLeaf(CPHamtLeaf data, IDeserializingKeyValueStore store) {\n- super(store);\n- this.data = data;\n- }\n-\n- private CLHamtLeaf(long key, String value, IDeserializingKeyValueStore store) {\n- super(store);\n- this.data = new CPHamtLeaf(key, value);\n- String serialized = this.data.serialize();\n- store.put(HashUtil.sha256(serialized), data, serialized);\n- }\n-\n- @Override\n- public CPHamtNode getData() {\n- return data;\n- }\n-\n- public long getKey() {\n- return data.getKey();\n- }\n-\n- public String getValue() {\n- return data.getValue();\n- }\n-\n- @Override\n- public CLHamtNode put(long key, String value, int shift) {\n- if (Objects.equals(key, data.key)) {\n- if (Objects.equals(value, data.value)) {\n- return this;\n- } else {\n- return CLHamtLeaf.create(key, value, store);\n- }\n- } else {\n- if (shift > CLHamtNode.MAX_SHIFT) {\n- throw new RuntimeException(shift + \" > \" + CLHamtNode.MAX_SHIFT);\n- }\n- CLHamtNode result = createEmptyNode();\n- result = result.put(data.key, data.value, shift);\n- if (result == null) {\n- result = createEmptyNode();\n- }\n- result = result.put(key, value, shift);\n- return result;\n- }\n- }\n-\n- @Override\n- public CLHamtNode remove(long key, int shift) {\n- if (Objects.equals(key, data.key)) {\n- return null;\n- } else {\n- return this;\n- }\n- }\n-\n- @Override\n- public IBulkQuery.Value<String> get(long key, int shift, IBulkQuery bulkQuery) {\n- return bulkQuery.constant((Objects.equals(data.key, key) ? data.value : null));\n- }\n-\n- @Override\n- public boolean visitEntries(BiPredicate<Long, String> visitor) {\n- return visitor.test(data.key, data.value);\n- }\n-\n- @Override\n- public void visitChanges(CLHamtNode oldNode, final CLHamtNode.IChangeVisitor visitor) {\n- if (oldNode == this) {\n- return;\n- }\n-\n- final MutableObject<String> oldValue = new MutableObject<>();\n- oldNode.visitEntries(new BiPredicate<Long, String>() {\n- public boolean test(Long k, String v) {\n- if (Objects.equals(k, data.key)) {\n- oldValue.setValue(v);\n- } else {\n- visitor.entryRemoved(k, v);\n- }\n- return true;\n- }\n- });\n-\n- if (oldValue.getValue() == null) {\n- visitor.entryAdded(data.key, data.value);\n- } else if (oldValue.getValue() != data.value) {\n- visitor.entryChanged(data.key, oldValue.getValue(), data.value);\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLHamtLeaf.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.apache.commons.lang3.mutable.MutableObject\n+import org.modelix.model.persistent.CPHamtLeaf\n+import org.modelix.model.persistent.CPHamtNode\n+import org.modelix.model.persistent.HashUtil\n+import java.util.function.BiPredicate\n+\n+class CLHamtLeaf : CLHamtNode<CPHamtLeaf?> {\n+ private val data: CPHamtLeaf\n+\n+ constructor(data: CPHamtLeaf, store: IDeserializingKeyValueStore?) : super(store) {\n+ this.data = data\n+ }\n+\n+ private constructor(key: Long, value: String, store: IDeserializingKeyValueStore) : super(store) {\n+ data = CPHamtLeaf(key, value)\n+ val serialized = data.serialize()\n+ store.put(HashUtil.sha256(serialized), data, serialized)\n+ }\n+\n+ override fun getData(): CPHamtNode {\n+ return data\n+ }\n+\n+ val key: Long\n+ get() = data.getKey()\n+\n+ val value: String\n+ get() = data.getValue()\n+\n+ override fun put(key: Long, value: String, shift: Int): CLHamtNode<*>? {\n+ return if (key == data.key) {\n+ if (value == data.value) {\n+ this\n+ } else {\n+ create(key, value, store)\n+ }\n+ } else {\n+ if (shift > MAX_SHIFT) {\n+ throw RuntimeException(\"$shift > $MAX_SHIFT\")\n+ }\n+ var result = createEmptyNode()\n+ result = result!!.put(data.key, data.value, shift)\n+ if (result == null) {\n+ result = createEmptyNode()\n+ }\n+ result = result.put(key, value, shift)\n+ result\n+ }\n+ }\n+\n+ override fun remove(key: Long, shift: Int): CLHamtNode<*>? {\n+ return if (key == data.key) {\n+ null\n+ } else {\n+ this\n+ }\n+ }\n+\n+ override fun get(key: Long, shift: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<String?> {\n+ return bulkQuery.constant<String?>(if (data.key == key) data.value else null)!!\n+ }\n+\n+ override fun visitEntries(visitor: BiPredicate<Long, String>): Boolean {\n+ return visitor.test(data.key, data.value)\n+ }\n+\n+ override fun visitChanges(oldNode: CLHamtNode<*>, visitor: IChangeVisitor) {\n+ if (oldNode === this) {\n+ return\n+ }\n+ val oldValue = MutableObject<String?>()\n+ oldNode.visitEntries { k, v ->\n+ if (k == data.key) {\n+ oldValue.setValue(v)\n+ } else {\n+ visitor.entryRemoved(k!!, v)\n+ }\n+ true\n+ }\n+ if (oldValue.value == null) {\n+ visitor.entryAdded(data.key, data.value)\n+ } else if (oldValue.value !== data.value) {\n+ visitor.entryChanged(data.key, oldValue.value, data.value)\n+ }\n+ }\n+\n+ companion object {\n+ fun create(key: Long, value: String?, store: IDeserializingKeyValueStore): CLHamtLeaf? {\n+ return value?.let { CLHamtLeaf(key, it, store) }\n+ }\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert CLHamtLeaf
426,504
01.08.2020 16:05:36
-7,200
f718e4198deb2f593668c1c61c927f55e533d2ad
convert HashUtil
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/HashUtil.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-import java.util.regex.Pattern;\n-import java.nio.charset.Charset;\n-import java.nio.charset.StandardCharsets;\n-import java.security.MessageDigest;\n-import java.util.Base64;\n-import java.security.NoSuchAlgorithmException;\n-import java.util.Iterator;\n-import java.util.regex.Matcher;\n-\n-public class HashUtil {\n-\n- private static final Pattern HASH_PATTERN = Pattern.compile(\"[a-zA-Z0-9\\\\-_]{43}\");\n- private static final Charset UTF8 = StandardCharsets.UTF_8;\n-\n- public static String sha256(byte[] input) {\n- try {\n- MessageDigest digest = MessageDigest.getInstance(\"SHA-256\");\n- digest.update(input);\n- byte[] sha256Bytes = digest.digest();\n- return Base64.getUrlEncoder().withoutPadding().encodeToString(sha256Bytes);\n- } catch (NoSuchAlgorithmException ex) {\n- throw new RuntimeException(ex);\n- }\n- }\n-\n- public static String sha256(String input) {\n- return sha256(input.getBytes(UTF8));\n- }\n-\n- public static boolean isSha256(String value) {\n- if (value == null) {\n- return false;\n- }\n- if (value.length() != 43) {\n- return false;\n- }\n- return HASH_PATTERN.matcher(value).matches();\n- }\n-\n- public static Iterable<String> extractSha256(final String input) {\n- return new Iterable<String>() {\n- @Override\n- public Iterator<String> iterator() {\n- return new Iterator<String>() {\n- private Matcher matcher = HASH_PATTERN.matcher(input);\n- private boolean hasNext;\n- private boolean hasNextInitialized;\n- public void ensureInitialized() {\n- if (!(hasNextInitialized)) {\n- hasNext = matcher.find();\n- hasNextInitialized = true;\n- }\n- }\n- @Override\n- public boolean hasNext() {\n- ensureInitialized();\n- return hasNext;\n- }\n-\n- @Override\n- public String next() {\n- ensureInitialized();\n- hasNextInitialized = false;\n- return matcher.group();\n- }\n- };\n- }\n- };\n- }\n-\n- public static String base64encode(String input) {\n- return Base64.getUrlEncoder().withoutPadding().encodeToString(input.getBytes(UTF8));\n- }\n-\n- public static String base64decode(String input) {\n- return new String(Base64.getUrlDecoder().decode(input.getBytes(UTF8)), UTF8);\n- }\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/HashUtil.kt", "diff": "+package org.modelix.model.persistent\n+\n+import java.nio.charset.StandardCharsets\n+import java.security.MessageDigest\n+import java.security.NoSuchAlgorithmException\n+import java.util.*\n+import java.util.regex.Pattern\n+\n+object HashUtil {\n+ private val HASH_PATTERN = Pattern.compile(\"[a-zA-Z0-9\\\\-_]{43}\")\n+ private val UTF8 = StandardCharsets.UTF_8\n+ fun sha256(input: ByteArray?): String {\n+ return try {\n+ val digest = MessageDigest.getInstance(\"SHA-256\")\n+ digest.update(input)\n+ val sha256Bytes = digest.digest()\n+ Base64.getUrlEncoder().withoutPadding().encodeToString(sha256Bytes)\n+ } catch (ex: NoSuchAlgorithmException) {\n+ throw RuntimeException(ex)\n+ }\n+ }\n+\n+ @JvmStatic\n+ fun sha256(input: String): String {\n+ return sha256(input.toByteArray(UTF8))\n+ }\n+\n+ @JvmStatic\n+ fun isSha256(value: String?): Boolean {\n+ if (value == null) {\n+ return false\n+ }\n+ return if (value.length != 43) {\n+ false\n+ } else HASH_PATTERN.matcher(value).matches()\n+ }\n+\n+ fun extractSha256(input: String?): Iterable<String> {\n+ return object : Iterable<String> {\n+ override fun iterator(): Iterator<String> {\n+ return object : Iterator<String> {\n+ private val matcher = HASH_PATTERN.matcher(input)\n+ private var hasNext = false\n+ private var hasNextInitialized = false\n+ fun ensureInitialized() {\n+ if (!hasNextInitialized) {\n+ hasNext = matcher.find()\n+ hasNextInitialized = true\n+ }\n+ }\n+\n+ override fun hasNext(): Boolean {\n+ ensureInitialized()\n+ return hasNext\n+ }\n+\n+ override fun next(): String {\n+ ensureInitialized()\n+ hasNextInitialized = false\n+ return matcher.group()\n+ }\n+ }\n+ }\n+ }\n+ }\n+\n+ fun base64encode(input: String): String {\n+ return Base64.getUrlEncoder().withoutPadding().encodeToString(input.toByteArray(UTF8))\n+ }\n+\n+ fun base64decode(input: String): String {\n+ return String(Base64.getUrlDecoder().decode(input.toByteArray(UTF8)), UTF8)\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/lazy/IDeserializingKeyValueStore_extensions.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/IDeserializingKeyValueStore_extensions.kt", "diff": "@@ -5,7 +5,7 @@ import org.modelix.model.persistent.HashUtil\nobject IDeserializingKeyValueStore_extensions {\nfun put(_this: IDeserializingKeyValueStore, deserialized: Any?, serialized: String?) {\n- _this.put(HashUtil.sha256(serialized), deserialized, serialized)\n+ _this.put(HashUtil.sha256(serialized!!), deserialized, serialized)\n}\n@JvmStatic\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert HashUtil
426,504
01.08.2020 16:07:24
-7,200
6c0a73925b3ab0a4adbce7c376fa530c53ebea87
convert CPTree
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "diff": "@@ -82,11 +82,11 @@ public class CLTree implements ITree {\n}\npublic CLHamtNode getNodesMap() {\n- return CLHamtNode.create(store.get(data.idToHash, s -> CPHamtNode.deserialize(s)), store);\n+ return CLHamtNode.create(store.get(data.getIdToHash(), s -> CPHamtNode.deserialize(s)), store);\n}\npublic String getId() {\n- return data.id;\n+ return data.getId();\n}\nprotected CLHamtNode storeElement(CLElement element, CLHamtNode id2hash) {\n@@ -102,7 +102,7 @@ public class CLTree implements ITree {\n}\npublic CLNode getRoot() {\n- return (CLNode) resolveElement(data.rootId);\n+ return (CLNode) resolveElement(data.getRootId());\n}\n@Override\n@@ -115,7 +115,7 @@ public class CLTree implements ITree {\nnewIdToHash = newIdToHash.put(newNodeData);\nIDeserializingKeyValueStore_extensions.put(store, newNodeData);\n- CLTree newTree = new CLTree(data.id, data.rootId, newIdToHash, store);\n+ CLTree newTree = new CLTree(data.getId(), data.getRootId(), newIdToHash, store);\nreturn newTree;\n}\n@@ -148,7 +148,7 @@ public class CLTree implements ITree {\nnewIdToHash = newIdToHash.put(newChildData);\nIDeserializingKeyValueStore_extensions.put(store, newChildData);\n- CLTree newTree = new CLTree(data.id, data.rootId, newIdToHash, store);\n+ CLTree newTree = new CLTree(data.getId(), data.getRootId(), newIdToHash, store);\nreturn newTree;\n}\n@@ -204,7 +204,7 @@ public class CLTree implements ITree {\nnewIdToHash = newIdToHash.put(newParentData);\nIDeserializingKeyValueStore_extensions.put(store, newParentData);\n- CLTree newTree = new CLTree(data.id, data.rootId, newIdToHash, store);\n+ CLTree newTree = new CLTree(data.getId(), data.getRootId(), newIdToHash, store);\nreturn newTree;\n}\n@@ -232,7 +232,7 @@ public class CLTree implements ITree {\nnewIdToHash = newIdToHash.put(newNodeData);\nIDeserializingKeyValueStore_extensions.put(store, newNodeData);\n- CLTree newTree = new CLTree(data.id, data.rootId, newIdToHash, store);\n+ CLTree newTree = new CLTree(data.getId(), data.getRootId(), newIdToHash, store);\nreturn newTree;\n}\n@@ -259,7 +259,7 @@ public class CLTree implements ITree {\nnewIdToHash = deleteElements(node.getData(), newIdToHash);\n}\n- CLTree newTree = new CLTree(data.id, data.rootId, newIdToHash, store);\n+ CLTree newTree = new CLTree(data.getId(), data.getRootId(), newIdToHash, store);\nreturn newTree;\n}\n@@ -437,8 +437,8 @@ public class CLTree implements ITree {\nif (ref == null) {\nreturn null;\n}\n- if (ref.isGLobal() && !(ref.getTreeId().equals(this.data.id))) {\n- throw new RuntimeException(\"Cannot resolve \" + ref + \" in tree \" + this.data.id);\n+ if (ref.isGLobal() && !(ref.getTreeId().equals(this.data.getId()))) {\n+ throw new RuntimeException(\"Cannot resolve \" + ref + \" in tree \" + this.data.getId());\n}\nif (ref.isLocal()) {\nreturn resolveElement(ref.getElementId());\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPTree.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-public class CPTree {\n-\n- public static CPTree deserialize(String input) {\n- String[] parts = input.split(\"/\", -1);\n- return new CPTree(parts[0], Long.parseLong(parts[1]), parts[2]);\n- }\n-\n- public final String id;\n- public final long rootId;\n- /**\n- * SHA to CPHamtNode\n- */\n- public String idToHash;\n-\n- public CPTree(String id1, long rootId1, String idToHash1) {\n- id = id1;\n- rootId = rootId1;\n- idToHash = idToHash1;\n- }\n-\n- public String serialize() {\n- return id + \"/\" + rootId + \"/\" + idToHash;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/CPTree.kt", "diff": "+package org.modelix.model.persistent\n+\n+class CPTree(val id: String, val rootId: Long,\n+ /**\n+ * SHA to CPHamtNode\n+ */\n+ var idToHash: String) {\n+\n+ fun serialize(): String {\n+ return \"$id/$rootId/$idToHash\"\n+ }\n+\n+ companion object {\n+ @JvmStatic\n+ fun deserialize(input: String): CPTree {\n+ val parts = input.split(\"/\").dropLastWhile { it.isEmpty() }.toTypedArray()\n+ return CPTree(parts[0], parts[1].toLong(), parts[2])\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert CPTree
426,504
02.08.2020 08:25:19
-7,200
49893f0769a7a23874220db230c45aaefe00aade
convert CPVersion
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPVersion.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-import org.apache.commons.lang3.StringUtils;\n-import org.apache.log4j.Level;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-import org.modelix.model.operations.IOperation;\n-\n-import java.util.stream.Stream;\n-\n-public class CPVersion {\n- private static final Logger LOG = LogManager.getLogger(CPVersion.class);\n-\n- public final long id;\n- public final String time;\n- public final String author;\n-\n- /**\n- * SHA to CPTree\n- */\n- public final String treeHash;\n- public final String previousVersion;\n- public final IOperation[] operations;\n- public final String operationsHash;\n- public final int numberOfOperations;\n-\n- public CPVersion(long id, String time, String author, String treeHash, String previousVersion, IOperation[] operations, String operationsHash, int numberOfOperations) {\n- if ((treeHash == null || treeHash.length() == 0)) {\n- if (LOG.isEnabledFor(Level.WARN)) {\n- LOG.warn(\"No tree hash provided\", new Exception());\n- }\n- }\n- if ((operations == null) == (operationsHash == null)) {\n- throw new RuntimeException(\"Only one of 'operations' and 'operationsHash' can be provided\");\n- }\n- this.id = id;\n- this.author = author;\n- this.previousVersion = previousVersion;\n- this.time = time;\n- this.treeHash = treeHash;\n- this.operations = operations;\n- this.operationsHash = operationsHash;\n- this.numberOfOperations = (operations != null ? operations.length : numberOfOperations);\n- }\n-\n- public String serialize() {\n- String opsPart = operationsHash != null\n- ? operationsHash :\n- Stream.of(operations)\n- .map(OperationSerializer.INSTANCE::serialize)\n- .reduce((a, b) -> a + \",\" + b)\n- .orElse(\"\");\n- String serialized = SerializationUtil.longToHex(id) +\n- \"/\" + SerializationUtil.escape(time) +\n- \"/\" + SerializationUtil.escape(author) +\n- \"/\" + SerializationUtil.nullAsEmptyString(treeHash) +\n- \"/\" + SerializationUtil.nullAsEmptyString(previousVersion) +\n- \"/\" + opsPart;\n- if (numberOfOperations >= 0) {\n- serialized += \"/\" + numberOfOperations;\n- }\n- return serialized;\n- }\n-\n- public static CPVersion deserialize(String input) {\n- String[] parts = input.split(\"/\", -1);\n-\n- String opsHash = null;\n- IOperation[] ops = null;\n- if (HashUtil.isSha256(parts[5])) {\n- opsHash = parts[5];\n- } else {\n- ops = Stream.of(parts[5].split(\",\"))\n- .filter(StringUtils::isNotEmpty)\n- .map(OperationSerializer.INSTANCE::deserialize)\n- .toArray(IOperation[]::new);\n- }\n-\n- int numOps = (parts.length >= 7 ? Integer.parseInt(parts[6]) : -1);\n- return new CPVersion(\n- SerializationUtil.longFromHex(parts[0]),\n- SerializationUtil.unescape(parts[1]),\n- SerializationUtil.unescape(parts[2]),\n- SerializationUtil.emptyStringAsNull(parts[3]),\n- SerializationUtil.emptyStringAsNull(parts[4]),\n- ops,\n- opsHash,\n- numOps);\n- }\n-\n- public String getHash() {\n- return HashUtil.sha256(this.serialize());\n- }\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/CPVersion.kt", "diff": "+package org.modelix.model.persistent\n+\n+import org.apache.commons.lang3.StringUtils\n+import org.apache.log4j.Level\n+import org.apache.log4j.LogManager\n+import org.modelix.model.operations.IOperation\n+import org.modelix.model.persistent.HashUtil.isSha256\n+import org.modelix.model.persistent.HashUtil.sha256\n+import org.modelix.model.persistent.SerializationUtil.emptyStringAsNull\n+import org.modelix.model.persistent.SerializationUtil.escape\n+import org.modelix.model.persistent.SerializationUtil.longFromHex\n+import org.modelix.model.persistent.SerializationUtil.longToHex\n+import org.modelix.model.persistent.SerializationUtil.nullAsEmptyString\n+import org.modelix.model.persistent.SerializationUtil.unescape\n+import java.util.function.Function\n+import java.util.stream.Collectors\n+import java.util.stream.Stream\n+\n+class CPVersion(id: Long, time: String?, author: String?, treeHash: String?, previousVersion: String?, operations: Array<IOperation?>?, operationsHash: String?, numberOfOperations: Int) {\n+ val id: Long\n+ val time: String?\n+ val author: String?\n+\n+ /**\n+ * SHA to CPTree\n+ */\n+ val treeHash: String?\n+ val previousVersion: String?\n+ val operations: Array<IOperation?>?\n+ val operationsHash: String?\n+ val numberOfOperations: Int\n+ fun serialize(): String {\n+ val opsPart = operationsHash\n+ ?: operations!!.toList().stream()\n+ .map(Function<IOperation?, String> { op: IOperation? -> OperationSerializer.INSTANCE.serialize(op) })\n+ .reduce { a: String, b: String -> \"$a,$b\" }\n+ .orElse(\"\")\n+ var serialized = longToHex(id) +\n+ \"/\" + escape(time) +\n+ \"/\" + escape(author) +\n+ \"/\" + nullAsEmptyString(treeHash) +\n+ \"/\" + nullAsEmptyString(previousVersion) +\n+ \"/\" + opsPart\n+ if (numberOfOperations >= 0) {\n+ serialized += \"/$numberOfOperations\"\n+ }\n+ return serialized\n+ }\n+\n+ val hash: String\n+ get() = sha256(serialize())\n+\n+ companion object {\n+ private val LOG = LogManager.getLogger(CPVersion::class.java)\n+ fun deserialize(input: String): CPVersion {\n+ val parts = input.split(\"/\").dropLastWhile { it.isEmpty() }.toTypedArray()\n+ var opsHash: String? = null\n+ var ops: Array<IOperation?>? = null\n+ if (isSha256(parts[5])) {\n+ opsHash = parts[5]\n+ } else {\n+ ops = Stream.of(*parts[5].split(\",\").toTypedArray())\n+ .filter { cs: String? -> StringUtils.isNotEmpty(cs) }\n+ .map { serialized: String? -> OperationSerializer.INSTANCE.deserialize(serialized) }\n+ .collect(Collectors.toList()).toTypedArray()\n+ }\n+ val numOps = if (parts.size >= 7) parts[6].toInt() else -1\n+ return CPVersion(\n+ longFromHex(parts[0]),\n+ unescape(parts[1]),\n+ unescape(parts[2]),\n+ emptyStringAsNull(parts[3]),\n+ emptyStringAsNull(parts[4]),\n+ ops,\n+ opsHash,\n+ numOps)\n+ }\n+ }\n+\n+ init {\n+ if (treeHash == null || treeHash.length == 0) {\n+ if (LOG.isEnabledFor(Level.WARN)) {\n+ LOG.warn(\"No tree hash provided\", Exception())\n+ }\n+ }\n+ if (operations == null == (operationsHash == null)) {\n+ throw RuntimeException(\"Only one of 'operations' and 'operationsHash' can be provided\")\n+ }\n+ this.id = id\n+ this.author = author\n+ this.previousVersion = previousVersion\n+ this.time = time\n+ this.treeHash = treeHash\n+ this.operations = operations\n+ this.operationsHash = operationsHash\n+ this.numberOfOperations = operations?.size ?: numberOfOperations\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -81,7 +81,7 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n.map { obj: IAppliedOperation -> obj.originalOp }\n.collect(Collectors.toList())\nval operationsToApply = StreamUtils.toStream(versionToApply.operations)\n- .map { it: IOperation -> transformOperation(it, oppositeAppliedOps) }\n+ .map { it: IOperation? -> transformOperation(it!!, oppositeAppliedOps) }\n.collect(Collectors.toList())\nfor (op in operationsToApply) {\nval appliedOp = op.apply(t)\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLVersion.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLVersion.kt", "diff": "@@ -23,7 +23,7 @@ class CLVersion {\nIDeserializingKeyValueStore_extensions.put(store, data, data!!.serialize())\n}\n- constructor(hash: String?, store: IDeserializingKeyValueStore) : this(store.get<CPVersion>(hash, Function { input: String? -> CPVersion.deserialize(input) }), store) {}\n+ constructor(hash: String?, store: IDeserializingKeyValueStore) : this(store.get<CPVersion>(hash, Function { input: String? -> CPVersion.deserialize(input!!) }), store) {}\nconstructor(data: CPVersion?, store: IDeserializingKeyValueStore) {\nif (data == null) {\nthrow NullPointerException(\"data is null\")\n@@ -33,22 +33,22 @@ class CLVersion {\n}\nval author: String\n- get() = data!!.author\n+ get() = data!!.author!!\nval id: Long\nget() = data!!.id\nval time: String\n- get() = data!!.time\n+ get() = data!!.time!!\nval hash: String\nget() = data!!.hash\nval previousHash: String\n- get() = data!!.previousVersion\n+ get() = data!!.previousVersion!!\nval treeHash: String\n- get() = data!!.treeHash\n+ get() = data!!.treeHash!!\nval tree: CLTree\nget() = CLTree(treeHash, store)\n@@ -58,12 +58,12 @@ class CLVersion {\nif (data!!.previousVersion == null) {\nreturn null\n}\n- val previousVersion = store.get(data!!.previousVersion, Function { input: String? -> CPVersion.deserialize(input) })\n+ val previousVersion = store.get(data!!.previousVersion, Function { input: String? -> CPVersion.deserialize(input!!) })\n?: return null\nreturn CLVersion(previousVersion, store)\n}\n- val operations: Iterable<IOperation>\n+ val operations: Iterable<IOperation?>\nget() {\nval ops = if (data!!.operationsHash == null) data!!.operations else store.get(data!!.operationsHash, Function { input: String? -> CPOperationsList.deserialize(input) })!!.operations\nreturn Iterable { Arrays.stream(ops).iterator() }\n@@ -79,7 +79,7 @@ class CLVersion {\ncompanion object {\n@JvmStatic\nfun loadFromHash(hash: String?, store: IDeserializingKeyValueStore): CLVersion? {\n- val data = store.get(hash, Function { input: String? -> CPVersion.deserialize(input) })\n+ val data = store.get(hash, Function { input: String? -> CPVersion.deserialize(input!!) })\nreturn data?.let { CLVersion(it, store) }\n}\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert CPVersion
426,504
02.08.2020 08:27:18
-7,200
171f123eef0d7a5e633a9a17d6e01b6ade91dac5
translate CPOperationsList
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPOperationsList.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-import org.apache.commons.lang3.StringUtils;\n-import org.modelix.model.operations.IOperation;\n-\n-import java.util.stream.Stream;\n-\n-public class CPOperationsList {\n- public final IOperation[] operations;\n-\n- public CPOperationsList(IOperation[] operations) {\n- this.operations = operations;\n- }\n-\n- public String serialize() {\n- return Stream.of(operations)\n- .map(OperationSerializer.INSTANCE::serialize)\n- .reduce((a, b) -> a + \",\" + b)\n- .orElse(\"\");\n- }\n-\n- public static CPOperationsList deserialize(String input) {\n- return new CPOperationsList(\n- Stream.of(input.split(\",\"))\n- .filter(StringUtils::isNotEmpty)\n- .map(OperationSerializer.INSTANCE::deserialize)\n- .toArray(IOperation[]::new)\n- );\n- }\n-\n- public String getHash() {\n- return HashUtil.sha256(this.serialize());\n- }\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/CPOperationsList.kt", "diff": "+package org.modelix.model.persistent\n+\n+import org.apache.commons.lang3.StringUtils\n+import org.modelix.model.operations.IOperation\n+import org.modelix.model.persistent.HashUtil.sha256\n+import java.util.stream.Collectors\n+import java.util.stream.Stream\n+\n+class CPOperationsList(val operations: Array<IOperation?>) {\n+ fun serialize(): String {\n+ return Stream.of(*operations)\n+ .map { op: IOperation? -> OperationSerializer.INSTANCE.serialize(op) }\n+ .reduce { a: String, b: String -> \"$a,$b\" }\n+ .orElse(\"\")\n+ }\n+\n+ val hash: String\n+ get() = sha256(serialize())\n+\n+ companion object {\n+ fun deserialize(input: String): CPOperationsList {\n+ return CPOperationsList(\n+ Stream.of(*input.split(\",\").toTypedArray())\n+ .filter { cs: String? -> StringUtils.isNotEmpty(cs) }\n+ .map { serialized: String? -> OperationSerializer.INSTANCE.deserialize(serialized) }\n+ .collect(Collectors.toList()).toTypedArray()\n+ )\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLVersion.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLVersion.kt", "diff": "@@ -65,7 +65,7 @@ class CLVersion {\nval operations: Iterable<IOperation?>\nget() {\n- val ops = if (data!!.operationsHash == null) data!!.operations else store.get(data!!.operationsHash, Function { input: String? -> CPOperationsList.deserialize(input) })!!.operations\n+ val ops = if (data!!.operationsHash == null) data!!.operations else store.get(data!!.operationsHash, Function { input: String? -> CPOperationsList.deserialize(input!!) })!!.operations\nreturn Iterable { Arrays.stream(ops).iterator() }\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CPOperationsList
426,504
02.08.2020 08:35:25
-7,200
78f262ad82f36d169ebccd5f7596bfcd43c43736
translate CPElementRef
[ { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "diff": "@@ -437,7 +437,7 @@ public class CLTree implements ITree {\nif (ref == null) {\nreturn null;\n}\n- if (ref.isGLobal() && !(ref.getTreeId().equals(this.data.getId()))) {\n+ if (ref.isGlobal() && !(ref.getTreeId().equals(this.data.getId()))) {\nthrow new RuntimeException(\"Cannot resolve \" + ref + \" in tree \" + this.data.getId());\n}\nif (ref.isLocal()) {\n" }, { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPElementRef.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-public abstract class CPElementRef {\n-\n- /*package*/ CPElementRef() {\n- }\n-\n- public static CPElementRef local(long elementId) {\n- return new LocalRef(elementId);\n- }\n-\n- public static CPElementRef global(String treeId, long elementId) {\n- return new GlobalRef(treeId, elementId);\n- }\n-\n- public static CPElementRef mps(String pointer) {\n- return new MpsRef(pointer);\n- }\n-\n- public static CPElementRef fromString(String str) {\n- if (str.charAt(0) == 'G') {\n- int i = str.lastIndexOf(\"#\");\n- return global(str.substring(1, i), Long.valueOf(str.substring(i + 1)));\n- } else if (str.charAt(0) == 'M') {\n- return mps(str.substring(1));\n- } else {\n- return local(Long.valueOf(str));\n- }\n- }\n-\n- public abstract boolean isGLobal();\n- public abstract boolean isLocal();\n-\n- public abstract long getElementId();\n- public abstract String getTreeId();\n-\n- private static class LocalRef extends CPElementRef {\n- private final long id;\n-\n- private LocalRef(long id1) {\n- id = id1;\n- }\n-\n- @Override\n- public String toString() {\n- return \"\" + id;\n- }\n-\n- @Override\n- public boolean isGLobal() {\n- return false;\n- }\n-\n- @Override\n- public boolean isLocal() {\n- return true;\n- }\n-\n- @Override\n- public long getElementId() {\n- return id;\n- }\n-\n- @Override\n- public String getTreeId() {\n- throw new RuntimeException(\"Local reference\");\n- }\n-\n- @Override\n- public boolean equals(Object o) {\n- if (this == o) {\n- return true;\n- }\n- if (o == null || this.getClass() != o.getClass()) {\n- return false;\n- }\n-\n- LocalRef that = (LocalRef) o;\n- if (id != that.id) {\n- return false;\n- }\n-\n- return true;\n- }\n-\n- @Override\n- public int hashCode() {\n- int result = 0;\n- result = 31 * result + (int) (id ^ (id >> 32));\n- return result;\n- }\n- }\n-\n- private static class GlobalRef extends CPElementRef {\n- private final String treeId;\n- private final long elementId;\n-\n- private GlobalRef(String treeId1, long elementId1) {\n- treeId = treeId1;\n- elementId = elementId1;\n- }\n-\n- @Override\n- public String toString() {\n- return \"G\" + treeId + \"#\" + elementId;\n- }\n-\n- @Override\n- public boolean isGLobal() {\n- return true;\n- }\n-\n- @Override\n- public boolean isLocal() {\n- return false;\n- }\n-\n- @Override\n- public long getElementId() {\n- return elementId;\n- }\n-\n- @Override\n- public String getTreeId() {\n- return treeId;\n- }\n-\n- @Override\n- public boolean equals(Object o) {\n- if (this == o) {\n- return true;\n- }\n- if (o == null || this.getClass() != o.getClass()) {\n- return false;\n- }\n-\n- GlobalRef that = (GlobalRef) o;\n- if (elementId != that.elementId) {\n- return false;\n- }\n- if ((treeId != null ? !(((Object) treeId).equals(that.treeId)) : that.treeId != null)) {\n- return false;\n- }\n-\n- return true;\n- }\n-\n- @Override\n- public int hashCode() {\n- int result = 0;\n- result = 31 * result + (int) (elementId ^ (elementId >> 32));\n- result = 31 * result + ((treeId != null ? String.valueOf(treeId).hashCode() : 0));\n- return result;\n- }\n- }\n-\n- public static class MpsRef extends CPElementRef {\n- private final String ref;\n-\n- private MpsRef(String ref) {\n- this.ref = ref;\n- }\n-\n- public String getSerializedRef() {\n- return ref;\n- }\n-\n- @Override\n- public String toString() {\n- return \"M\" + ref;\n- }\n-\n- @Override\n- public boolean isGLobal() {\n- return false;\n- }\n-\n- @Override\n- public boolean isLocal() {\n- return false;\n- }\n-\n- @Override\n- public long getElementId() {\n- throw new RuntimeException(\"MPS reference\");\n- }\n-\n- @Override\n- public String getTreeId() {\n- throw new RuntimeException(\"MPS reference\");\n- }\n-\n- @Override\n- public boolean equals(Object o) {\n- if (this == o) {\n- return true;\n- }\n- if (o == null || this.getClass() != o.getClass()) {\n- return false;\n- }\n-\n- MpsRef that = (MpsRef) o;\n- if ((ref != null ? !(((Object) ref).equals(that.ref)) : that.ref != null)) {\n- return false;\n- }\n-\n- return true;\n- }\n-\n- @Override\n- public int hashCode() {\n- int result = 0;\n- result = 31 * result + ((ref != null ? String.valueOf(ref).hashCode() : 0));\n- return result;\n- }\n- }\n-\n-\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/CPElementRef.kt", "diff": "+package org.modelix.model.persistent\n+\n+abstract class CPElementRef /*package*/\n+internal constructor() {\n+ abstract val isGlobal: Boolean\n+ abstract val isLocal: Boolean\n+ abstract val elementId: Long\n+ abstract val treeId: String?\n+\n+ private class LocalRef(private val id: Long) : CPElementRef() {\n+ override fun toString(): String {\n+ return \"\" + id\n+ }\n+\n+ override val isGlobal: Boolean\n+ get() = false\n+\n+ override val isLocal: Boolean\n+ get() = true\n+\n+ override val elementId: Long\n+ get() = id\n+\n+ override val treeId: String?\n+ get() {\n+ throw RuntimeException(\"Local reference\")\n+ }\n+\n+ override fun equals(o: Any?): Boolean {\n+ if (this === o) {\n+ return true\n+ }\n+ if (o == null || this.javaClass != o.javaClass) {\n+ return false\n+ }\n+ val that = o as LocalRef\n+ return if (id != that.id) {\n+ false\n+ } else true\n+ }\n+\n+ override fun hashCode(): Int {\n+ var result = 0\n+ result = 31 * result + (id xor (id shr 32)).toInt()\n+ return result\n+ }\n+\n+ }\n+\n+ private class GlobalRef(treeId1: String, elementId1: Long) : CPElementRef() {\n+ override val treeId: String?\n+ override val elementId: Long\n+ override fun toString(): String {\n+ return \"G$treeId#$elementId\"\n+ }\n+\n+ override val isGlobal: Boolean\n+ get() = true\n+\n+ override val isLocal: Boolean\n+ get() = false\n+\n+ override fun equals(o: Any?): Boolean {\n+ if (this === o) {\n+ return true\n+ }\n+ if (o == null || this.javaClass != o.javaClass) {\n+ return false\n+ }\n+ val that = o as GlobalRef\n+ if (elementId != that.elementId) {\n+ return false\n+ }\n+ return if (if (treeId != null) treeId as Any != that.treeId else that.treeId != null) {\n+ false\n+ } else true\n+ }\n+\n+ override fun hashCode(): Int {\n+ var result = 0\n+ result = 31 * result + (elementId xor (elementId shr 32)).toInt()\n+ result = 31 * result + (treeId?.hashCode() ?: 0)\n+ return result\n+ }\n+\n+ init {\n+ treeId = treeId1\n+ elementId = elementId1\n+ }\n+ }\n+\n+ class MpsRef(ref: String) : CPElementRef() {\n+ val serializedRef: String?\n+\n+ override fun toString(): String {\n+ return \"M\" + serializedRef\n+ }\n+\n+ override val isGlobal: Boolean\n+ get() = false\n+\n+ override val isLocal: Boolean\n+ get() = false\n+\n+ override val elementId: Long\n+ get() {\n+ throw RuntimeException(\"MPS reference\")\n+ }\n+\n+ override val treeId: String?\n+ get() {\n+ throw RuntimeException(\"MPS reference\")\n+ }\n+\n+ override fun equals(o: Any?): Boolean {\n+ if (this === o) {\n+ return true\n+ }\n+ if (o == null || this.javaClass != o.javaClass) {\n+ return false\n+ }\n+ val that = o as MpsRef\n+ return if (if (serializedRef != null) serializedRef as Any != that.serializedRef else that.serializedRef != null) {\n+ false\n+ } else true\n+ }\n+\n+ override fun hashCode(): Int {\n+ var result = 0\n+ result = 31 * result + if (serializedRef != null) serializedRef.toString().hashCode() else 0\n+ return result\n+ }\n+\n+ init {\n+ serializedRef = ref\n+ }\n+ }\n+\n+ companion object {\n+ @JvmStatic\n+ fun local(elementId: Long): CPElementRef {\n+ return LocalRef(elementId)\n+ }\n+\n+ fun global(treeId: String, elementId: Long): CPElementRef {\n+ return GlobalRef(treeId, elementId)\n+ }\n+\n+ fun mps(pointer: String): CPElementRef {\n+ return MpsRef(pointer)\n+ }\n+\n+ @JvmStatic\n+ fun fromString(str: String): CPElementRef {\n+ return if (str[0] == 'G') {\n+ val i = str.lastIndexOf(\"#\")\n+ global(str.substring(1, i), java.lang.Long.valueOf(str.substring(i + 1)))\n+ } else if (str[0] == 'M') {\n+ mps(str.substring(1))\n+ } else {\n+ local(java.lang.Long.valueOf(str))\n+ }\n+ }\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CPElementRef
426,504
02.08.2020 08:38:17
-7,200
77d879d1e90ec93367e9fbad54ef2efe0bad920e
translate CPHamtInternal
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPHamtInternal.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-import java.util.Arrays;\n-\n-public class CPHamtInternal extends CPHamtNode {\n-\n- public int bitmap;\n-\n- /**\n- * SHA to CPHamtNode\n- */\n- public final String[] children;\n-\n- public CPHamtInternal(int bitmap, String[] childHashes) {\n- this.bitmap = bitmap;\n- this.children = childHashes;\n- }\n-\n- @Override\n- public String serialize() {\n- return String.format(\"I/%s/%s\",\n- SerializationUtil.intToHex(bitmap),\n- Arrays.stream(children).reduce((a, b) -> a + \",\" + b).orElse(\"\")\n- );\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/CPHamtInternal.kt", "diff": "+package org.modelix.model.persistent\n+\n+import org.modelix.model.persistent.SerializationUtil.intToHex\n+import java.util.*\n+\n+class CPHamtInternal(var bitmap: Int,\n+ /**\n+ * SHA to CPHamtNode\n+ */\n+ val children: Array<String?>) : CPHamtNode() {\n+\n+ override fun serialize(): String {\n+ return String.format(\"I/%s/%s\",\n+ intToHex(bitmap),\n+ Arrays.stream(children).reduce { a: String?, b: String? -> \"$a,$b\" }.orElse(\"\")\n+ )\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CPHamtInternal
426,504
02.08.2020 08:38:59
-7,200
f60429f3e5f5a3d747a5b80b2e6b8bee66a17c78
translate CPHamtLeaf
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPHamtLeaf.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-public class CPHamtLeaf extends CPHamtNode {\n-\n- public final long key;\n-\n- /**\n- * SHA to CPElement\n- */\n- public final String value;\n-\n- public CPHamtLeaf(long key, String value) {\n- this.key = key;\n- this.value = value;\n- }\n-\n- public long getKey() {\n- return key;\n- }\n-\n- public String getValue() {\n- return value;\n- }\n-\n- @Override\n- public String serialize() {\n- return \"L/\" + SerializationUtil.longToHex(key) + \"/\" + value;\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/CPHamtLeaf.kt", "diff": "+package org.modelix.model.persistent\n+\n+import org.modelix.model.persistent.SerializationUtil.longToHex\n+\n+class CPHamtLeaf(val key: Long,\n+ /**\n+ * SHA to CPElement\n+ */\n+ val value: String) : CPHamtNode() {\n+\n+ override fun serialize(): String {\n+ return \"L/\" + longToHex(key) + \"/\" + value\n+ }\n+\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLHamtLeaf.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLHamtLeaf.kt", "diff": "@@ -24,10 +24,10 @@ class CLHamtLeaf : CLHamtNode<CPHamtLeaf?> {\n}\nval key: Long\n- get() = data.getKey()\n+ get() = data.key\nval value: String\n- get() = data.getValue()\n+ get() = data.value\noverride fun put(key: Long, value: String, shift: Int): CLHamtNode<*>? {\nreturn if (key == data.key) {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CPHamtLeaf
426,504
02.08.2020 08:39:40
-7,200
22b49eb33033e23f0d735a826fb5d0ba97f6c577
translate CPHamtNode
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPHamtNode.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-import java.util.Arrays;\n-import java.util.function.Function;\n-\n-public abstract class CPHamtNode {\n- public static final Function<String, CPHamtNode> DESERIALIZER = s -> deserialize(s);\n- public static CPHamtNode deserialize(String input) {\n- String[] parts = input.split(\"/\", -1);\n-\n- if (\"L\".equals(parts[0])) {\n- return new CPHamtLeaf(SerializationUtil.longFromHex(parts[1]), parts[2]);\n- } else if (\"I\".equals(parts[0])) {\n- return new CPHamtInternal(\n- SerializationUtil.intFromHex(parts[1]),\n- Arrays.stream(parts[2].split(\",\"))\n- .filter(it -> (it != null && it.length() > 0))\n- .toArray(String[]::new));\n- } else {\n- throw new RuntimeException(\"Unknown type: \" + parts[0] + \", input: \" + input);\n- }\n- }\n-\n- public abstract String serialize();\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/java/org/modelix/model/persistent/CPHamtNode.kt", "diff": "+package org.modelix.model.persistent\n+\n+import org.modelix.model.persistent.SerializationUtil.intFromHex\n+import org.modelix.model.persistent.SerializationUtil.longFromHex\n+import java.util.*\n+import java.util.function.Function\n+import java.util.stream.Collectors\n+\n+abstract class CPHamtNode {\n+ abstract fun serialize(): String?\n+\n+ companion object {\n+ val DESERIALIZER = Function { s: String? -> deserialize(s!!) }\n+ @JvmStatic\n+ fun deserialize(input: String): CPHamtNode {\n+ val parts = input.split(\"/\").dropLastWhile { it.isEmpty() }.toTypedArray()\n+ return if (\"L\" == parts[0]) {\n+ CPHamtLeaf(longFromHex(parts[1]), parts[2])\n+ } else if (\"I\" == parts[0]) {\n+ CPHamtInternal(\n+ intFromHex(parts[1]),\n+ Arrays.stream(parts[2].split(\",\").toTypedArray())\n+ .filter { it: String? -> it != null && it.length > 0 }\n+ .collect(Collectors.toList()).toTypedArray())\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + parts[0] + \", input: \" + input)\n+ }\n+ }\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "diff": "@@ -63,7 +63,7 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\n}\nprotected fun getChild(childHash: String?, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n- return bulkQuery.get(childHash, CPHamtNode.DESERIALIZER)!!.map(Function { childData: CPHamtNode? -> create(childData, store) })!!\n+ return bulkQuery.get(childHash, CPHamtNode.DESERIALIZER)!!.map(Function { childData: CPHamtNode -> create(childData, store) })!!\n}\nprotected fun getChild(logicalIndex: Int): CLHamtNode<*>? {\n@@ -78,7 +78,7 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\nif (child == null) {\nreturn deleteChild(logicalIndex)\n}\n- val childHash = HashUtil.sha256(child.data.serialize())\n+ val childHash = HashUtil.sha256(child.data.serialize()!!)\nval physicalIndex = logicalToPhysicalIndex(data.bitmap, logicalIndex)\nreturn if (LongKeyPMap.isBitNotSet(data.bitmap, logicalIndex)) {\nCLHamtInternal(data.bitmap or (1 shl logicalIndex), COWArrays.insert(data.children, physicalIndex, childHash), store)\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CPHamtNode
426,504
02.08.2020 08:58:40
-7,200
9ca52380aa81d94db2f63f86115694abe6539efb
convert CPElement
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPElement.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-public abstract class CPElement {\n-\n- public static CPElement deserialize(String input) {\n- return CPNode.deserialize(input);\n- }\n-\n- protected final long id;\n- protected final long parentId;\n- protected final String roleInParent;\n-\n- public CPElement(long id1, long parentId1, String roleInParent1) {\n- id = id1;\n- parentId = parentId1;\n- roleInParent = roleInParent1;\n- }\n-\n- public long getId() {\n- return id;\n- }\n-\n- public long getParentId() {\n- return parentId;\n- }\n-\n- public String getRoleInParent() {\n- return roleInParent;\n- }\n-\n- public abstract String serialize();\n-\n- public String getHash() {\n- return HashUtil.sha256(serialize());\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPNode.java", "new_path": "model-client/src/main/java/org/modelix/model/persistent/CPNode.java", "diff": "@@ -60,13 +60,13 @@ public class CPNode extends CPElement {\npublic String serialize() {\nStringBuilder sb = new StringBuilder();\n- sb.append(SerializationUtil.longToHex(id));\n+ sb.append(SerializationUtil.longToHex(getId()));\nsb.append(\"/\");\nsb.append(SerializationUtil.escape(concept));\nsb.append(\"/\");\n- sb.append(SerializationUtil.longToHex(parentId));\n+ sb.append(SerializationUtil.longToHex(getParentId()));\nsb.append(\"/\");\n- sb.append(SerializationUtil.escape(roleInParent));\n+ sb.append(SerializationUtil.escape(getRoleInParent()));\nsb.append(\"/\");\nsb.append(Arrays.stream(childrenIds).mapToObj(SerializationUtil::longToHex).reduce((a, b) -> a + \", \" + b));\nsb.append(\"/\");\n@@ -179,14 +179,14 @@ public class CPNode extends CPElement {\nif (index < 0) {\nreturn this;\n} else {\n- return create(id, concept, parentId, roleInParent, childrenIds, COWArrays.INSTANCE.removeAt(propertyRoles, index), COWArrays.INSTANCE.removeAt(propertyValues, index), referenceRoles, referenceTargets);\n+ return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, COWArrays.INSTANCE.removeAt(propertyRoles, index), COWArrays.INSTANCE.removeAt(propertyValues, index), referenceRoles, referenceTargets);\n}\n} else {\nif (index < 0) {\nindex = -(index + 1);\n- return create(id, concept, parentId, roleInParent, childrenIds, COWArrays.INSTANCE.insert(propertyRoles, index, role), COWArrays.INSTANCE.insert(propertyValues, index, value), referenceRoles, referenceTargets);\n+ return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, COWArrays.INSTANCE.insert(propertyRoles, index, role), COWArrays.INSTANCE.insert(propertyValues, index, value), referenceRoles, referenceTargets);\n} else {\n- return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, COWArrays.INSTANCE.set(propertyValues, index, value), referenceRoles, referenceTargets);\n+ return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, propertyRoles, COWArrays.INSTANCE.set(propertyValues, index, value), referenceRoles, referenceTargets);\n}\n}\n}\n@@ -197,14 +197,14 @@ public class CPNode extends CPElement {\nif (index < 0) {\nreturn this;\n} else {\n- return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, COWArrays.INSTANCE.removeAt(referenceRoles, index), COWArrays.INSTANCE.removeAt(referenceTargets, index));\n+ return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, propertyRoles, propertyValues, COWArrays.INSTANCE.removeAt(referenceRoles, index), COWArrays.INSTANCE.removeAt(referenceTargets, index));\n}\n} else {\nif (index < 0) {\nindex = -(index + 1);\n- return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, COWArrays.INSTANCE.insert(referenceRoles, index, role), COWArrays.INSTANCE.insert(referenceTargets, index, target));\n+ return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, propertyRoles, propertyValues, COWArrays.INSTANCE.insert(referenceRoles, index, role), COWArrays.INSTANCE.insert(referenceTargets, index, target));\n} else {\n- return create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, referenceRoles, COWArrays.INSTANCE.set(referenceTargets, index, target));\n+ return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, propertyRoles, propertyValues, referenceRoles, COWArrays.INSTANCE.set(referenceTargets, index, target));\n}\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/persistent/CPElement.kt", "diff": "+package org.modelix.model.persistent\n+\n+import org.modelix.model.persistent.HashUtil.sha256\n+\n+abstract class CPElement(val id: Long, val parentId: Long, val roleInParent: String?) {\n+\n+ abstract fun serialize(): String?\n+ val hash: String\n+ get() = sha256(serialize()!!)\n+\n+ companion object {\n+ @JvmStatic\n+ open fun deserialize(input: String?): CPElement {\n+ return CPNode.deserialize(input)\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
convert CPElement
426,504
02.08.2020 09:04:54
-7,200
7b17e1e6ee7dc8bc1cb1be9d6de5f3c76ec871aa
translate CLNode
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLNode.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.modelix.model.persistent.CPElementRef;\n-import org.modelix.model.persistent.CPNode;\n-\n-import java.util.List;\n-import java.util.function.Function;\n-import java.util.stream.Stream;\n-import java.util.stream.StreamSupport;\n-\n-public class CLNode extends CLElement {\n-\n- public CLNode(CLTree tree, CPNode data) {\n- super(tree, data);\n- }\n-\n- public CLNode(CLTree tree, long id, String concept, long parentId, String roleInParent, long[] childrenIds, String[] propertyRoles, String[] propertyValues, String[] referenceRoles, CPElementRef[] referenceTargets) {\n- this(tree, CPNode.create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, referenceRoles, referenceTargets));\n- }\n-\n- @Override\n- public CPNode getData() {\n- return (CPNode) super.getData();\n- }\n-\n- public IBulkQuery.Value<Iterable<CLNode>> getChildren(IBulkQuery bulkQuery) {\n- return ((CLTree)getTree()).resolveElements(getData().getChildrenIds(), bulkQuery).map(elements -> elements);\n- }\n-\n- public IBulkQuery.Value<Iterable<CLNode>> getDescendants(final IBulkQuery bulkQuery, boolean includeSelf) {\n- if (includeSelf) {\n- return getDescendants(bulkQuery, false)\n- .map(descendants -> Stream.concat(\n- Stream.of(this),\n- StreamSupport.stream(descendants.spliterator(), false)\n- )::iterator);\n- } else {\n- return getChildren(bulkQuery).mapBulk(children -> {\n- IBulkQuery.Value<Iterable<CLNode>> d = bulkQuery\n- .map(children, child -> child.getDescendants(bulkQuery, true))\n- .map(it -> it.stream().flatMap(n -> StreamSupport.stream(n.spliterator(), false))::iterator);\n- return d;\n- });\n- }\n- }\n-\n- public String getConcept() {\n- return getData().getConcept();\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLNode.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.modelix.model.persistent.CPElementRef\n+import org.modelix.model.persistent.CPNode\n+import java.util.function.Function\n+import java.util.stream.Stream\n+import java.util.stream.StreamSupport\n+\n+class CLNode(tree: CLTree?, data: CPNode?) : CLElement(tree!!, data!!) {\n+ constructor(tree: CLTree?, id: Long, concept: String?, parentId: Long, roleInParent: String?, childrenIds: LongArray?, propertyRoles: Array<String?>?, propertyValues: Array<String?>?, referenceRoles: Array<String?>?, referenceTargets: Array<CPElementRef?>?) : this(tree, CPNode.create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, referenceRoles, referenceTargets)) {}\n+\n+ override fun getData(): CPNode? {\n+ return super.getData() as CPNode?\n+ }\n+\n+ fun getChildren(bulkQuery: IBulkQuery?): IBulkQuery.Value<Iterable<CLNode>?>? {\n+ return (getTree() as CLTree).resolveElements(getData()!!.childrenIds, bulkQuery).map(Function<List<CLNode>, Iterable<CLNode>?> { elements: List<CLNode>? -> elements })\n+ }\n+\n+ fun getDescendants(bulkQuery: IBulkQuery, includeSelf: Boolean): IBulkQuery.Value<Iterable<CLNode>>? {\n+ return if (includeSelf) {\n+ getDescendants(bulkQuery, false)!!\n+ .map(Function { descendants: Iterable<CLNode> ->\n+ Iterable<CLNode> {\n+ Stream.concat(\n+ Stream.of(this),\n+ StreamSupport.stream(descendants.spliterator(), false)\n+ ).iterator()\n+ }\n+ })\n+ } else {\n+ getChildren(bulkQuery)!!.mapBulk(Function { children: Iterable<CLNode>? ->\n+ val d = bulkQuery\n+ .map(children, Function { child: CLNode -> child.getDescendants(bulkQuery, true) })!!\n+ .map(Function { it: List<Iterable<CLNode>>? -> Iterable<CLNode> { it!!.stream().flatMap { n: Iterable<CLNode> -> StreamSupport.stream(n.spliterator(), false) }.iterator() } })\n+ d\n+ })\n+ }\n+ }\n+\n+ val concept: String?\n+ get() = getData()!!.concept\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CLNode
426,504
02.08.2020 09:25:19
-7,200
afb9a4d424f6b13c165d80e4f4fef4577a6673f1
translate CLHamtNode
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLHamtNode.java", "new_path": null, "diff": "-package org.modelix.model.lazy;\n-\n-import org.modelix.model.persistent.CPElement;\n-import org.modelix.model.persistent.CPHamtInternal;\n-import org.modelix.model.persistent.CPHamtLeaf;\n-import org.modelix.model.persistent.CPHamtNode;\n-\n-import java.util.List;\n-import java.util.function.BiPredicate;\n-\n-public abstract class CLHamtNode<E extends CPHamtNode> {\n-\n- public static final int BITS_PER_LEVEL = 5;\n- public static final int ENTRIES_PER_LEVEL = 1 << BITS_PER_LEVEL;\n- public static final int LEVEL_MASK = 0xffffffff >>> (32 - BITS_PER_LEVEL);\n- public static final int MAX_BITS = 64;\n- public static final int MAX_SHIFT = MAX_BITS - BITS_PER_LEVEL;\n-\n- public static CLHamtNode create(CPHamtNode data, IDeserializingKeyValueStore store) {\n- if (data == null) {\n- return null;\n- }\n- if (data instanceof CPHamtLeaf) {\n- return new CLHamtLeaf((CPHamtLeaf) data, store);\n- } else if (data instanceof CPHamtInternal) {\n- return new CLHamtInternal((CPHamtInternal) data, store);\n- } else {\n- throw new RuntimeException(\"Unknown type: \" + data.getClass().getName());\n- }\n- }\n-\n-\n- protected IDeserializingKeyValueStore store;\n-\n- public CLHamtNode(IDeserializingKeyValueStore store) {\n- this.store = store;\n- }\n-\n- protected CLHamtNode createEmptyNode() {\n- return CLHamtInternal.create(new CPHamtInternal(0, new String[0]), store);\n- }\n-\n- public abstract CPHamtNode getData();\n-\n- public String get(long key) {\n- final IBulkQuery bulkQuery = new NonBulkQuery(store);\n- return get(key, 0, bulkQuery).execute();\n- }\n-\n- public IBulkQuery.Value<List<String>> getAll(Iterable<Long> keys, final IBulkQuery bulkQuery) {\n- return bulkQuery.map(keys, key -> get(key, 0, bulkQuery));\n- }\n-\n- public CLHamtNode put(long key, String value) {\n- return put(key, value, 0);\n- }\n-\n- public CLHamtNode put(CLElement element) {\n- return put(element.getId(), element.getData().getHash());\n- }\n-\n- public CLHamtNode put(CPElement data) {\n- return put(data.getId(), data.getHash());\n- }\n-\n- public CLHamtNode remove(long key) {\n- return remove(key, 0);\n- }\n-\n- public CLHamtNode remove(CLElement element) {\n- return remove(element.getId());\n- }\n-\n- public abstract IBulkQuery.Value<String> get(long key, int shift, IBulkQuery bulkQuery);\n- public abstract CLHamtNode put(long key, String value, int shift);\n- public abstract CLHamtNode remove(long key, int shift);\n-\n- public abstract boolean visitEntries(BiPredicate<Long, String> visitor);\n- public abstract void visitChanges(CLHamtNode oldNode, IChangeVisitor visitor);\n-\n- public interface IChangeVisitor {\n- void entryAdded(long key, String value);\n- void entryRemoved(long key, String value);\n- void entryChanged(long key, String oldValue, String newValue);\n- }\n-\n- public static int logicalToPhysicalIndex(int bitmap, int logicalIndex) {\n- return Integer.bitCount(bitmap & ((1 << logicalIndex) - 1));\n- }\n-\n- public static boolean isBitNotSet(int bitmap, int logicalIndex) {\n- return (bitmap & (1 << logicalIndex)) == 0;\n- }\n-\n-}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "new_path": "model-client/src/main/java/org/modelix/model/lazy/CLTree.java", "diff": "@@ -55,7 +55,7 @@ public class CLTree implements ITree {\nCLNode root = new CLNode(this, 1, null, 0, null, new long[0], new String[0], new String[0], new String[0], new CPElementRef[0]);\nCLHamtNode idToHash = storeElement(root, new CLHamtInternal(store));\n- this.data = new CPTree(treeId.getId(), 1, HashUtil.sha256(idToHash.getData().serialize()));\n+ this.data = new CPTree(treeId.getId(), 1, HashUtil.INSTANCE.sha256(idToHash.getData().serialize()));\nIDeserializingKeyValueStore_extensions.INSTANCE.put(store, this.data, this.data.serialize());\n} else {\n@@ -69,7 +69,7 @@ public class CLTree implements ITree {\ntreeId = TreeId.random().getId();\n}\nthis.store = store;\n- this.data = new CPTree(treeId, rootId, HashUtil.sha256(idToHash.getData().serialize()));\n+ this.data = new CPTree(treeId, rootId, HashUtil.INSTANCE.sha256(idToHash.getData().serialize()));\nIDeserializingKeyValueStore_extensions.INSTANCE.put(store, data, data.serialize());\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "diff": "@@ -9,20 +9,20 @@ import java.util.function.BiPredicate\nimport java.util.function.Function\nclass CLHamtInternal : CLHamtNode<CPHamtInternal?> {\n- private val data: CPHamtInternal\n+ private val data_: CPHamtInternal\nconstructor(store: IDeserializingKeyValueStore) : this(0, arrayOfNulls<String>(0), store) {}\n- constructor(data: CPHamtInternal, store: IDeserializingKeyValueStore?) : super(store) {\n- this.data = data\n+ constructor(data: CPHamtInternal, store: IDeserializingKeyValueStore?) : super(store!!) {\n+ this.data_ = data\n}\nprivate constructor(bitmap: Int, childHashes: Array<String?>, store: IDeserializingKeyValueStore) : super(store) {\n- data = CPHamtInternal(bitmap, childHashes)\n- val serialized = data.serialize()\n- store.put(HashUtil.sha256(serialized), data, serialized)\n+ data_ = CPHamtInternal(bitmap, childHashes)\n+ val serialized = data_.serialize()\n+ store.put(HashUtil.sha256(serialized), data_, serialized)\n}\n- override fun put(key: Long, value: String, shift: Int): CLHamtNode<*>? {\n+ override fun put(key: Long, value: String?, shift: Int): CLHamtNode<*>? {\nval childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\nval child = getChild(childIndex, NonBulkQuery(store)).execute()\nreturn if (child == null) {\n@@ -42,13 +42,13 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\n}\n}\n- override fun get(key: Long, shift: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<String?>? {\n+ override fun get(key: Long, shift: Int, bulkQuery: IBulkQuery?): IBulkQuery.Value<String?>? {\nval childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n// getChild(logicalIndex: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n- return getChild(childIndex, bulkQuery).mapBulk<String?>(\n+ return getChild(childIndex, bulkQuery!!).mapBulk<String?>(\nFunction { child: CLHamtNode<*>? ->\nif (child == null) {\n- bulkQuery.constant<String?>(null)\n+ bulkQuery!!.constant<String?>(null)\n} else {\nchild[key, shift + BITS_PER_LEVEL, bulkQuery]\n}\n@@ -57,11 +57,11 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\n}\nprotected fun getChild(logicalIndex: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n- if (isBitNotSet(data.bitmap, logicalIndex)) {\n+ if (isBitNotSet(data_.bitmap, logicalIndex)) {\nreturn bulkQuery.constant(null) as IBulkQuery.Value<CLHamtNode<*>?>\n}\n- val physicalIndex = logicalToPhysicalIndex(data.bitmap, logicalIndex)\n- return getChild(data.children[physicalIndex], bulkQuery)\n+ val physicalIndex = logicalToPhysicalIndex(data_.bitmap, logicalIndex)\n+ return getChild(data_.children[physicalIndex], bulkQuery)\n}\nprotected fun getChild(childHash: String?, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n@@ -80,25 +80,25 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\nif (child == null) {\nreturn deleteChild(logicalIndex)\n}\n- val childHash = HashUtil.sha256(child.data.serialize()!!)\n- val physicalIndex = logicalToPhysicalIndex(data.bitmap, logicalIndex)\n- return if (LongKeyPMap.isBitNotSet(data.bitmap, logicalIndex)) {\n- CLHamtInternal(data.bitmap or (1 shl logicalIndex), COWArrays.insert(data.children, physicalIndex, childHash), store)\n+ val childHash = HashUtil.sha256(child.getData()!!.serialize()!!)\n+ val physicalIndex = logicalToPhysicalIndex(data_.bitmap, logicalIndex)\n+ return if (LongKeyPMap.isBitNotSet(data_.bitmap, logicalIndex)) {\n+ CLHamtInternal(data_.bitmap or (1 shl logicalIndex), COWArrays.insert(data_.children, physicalIndex, childHash), store)\n} else {\n- CLHamtInternal(data.bitmap, COWArrays.set(data.children, physicalIndex, childHash), store)\n+ CLHamtInternal(data_.bitmap, COWArrays.set(data_.children, physicalIndex, childHash), store)\n}\n}\nfun deleteChild(logicalIndex: Int): CLHamtNode<*>? {\n- if (isBitNotSet(data.bitmap, logicalIndex)) {\n+ if (isBitNotSet(data_.bitmap, logicalIndex)) {\nreturn this\n}\n- val physicalIndex = LongKeyPMap.logicalToPhysicalIndex(data.bitmap, logicalIndex)\n- val newBitmap = data.bitmap and (1 shl logicalIndex).inv()\n+ val physicalIndex = LongKeyPMap.logicalToPhysicalIndex(data_.bitmap, logicalIndex)\n+ val newBitmap = data_.bitmap and (1 shl logicalIndex).inv()\nif (newBitmap == 0) {\nreturn null\n}\n- val newChildren = COWArrays.removeAt(data.children, physicalIndex)\n+ val newChildren = COWArrays.removeAt(data_.children, physicalIndex)\nif (newChildren.size == 1) {\nval child0 = getChild(newChildren[0], NonBulkQuery(store)).execute()\nif (child0 is CLHamtLeaf) {\n@@ -108,8 +108,8 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\nreturn CLHamtInternal(newBitmap, newChildren, store)\n}\n- override fun visitEntries(visitor: BiPredicate<Long, String>): Boolean {\n- for (childHash in data.children) {\n+ override fun visitEntries(visitor: BiPredicate<Long?, String?>?): Boolean {\n+ for (childHash in data_.children) {\nval child = getChild(childHash)\nval continueVisit = child!!.visitEntries(visitor)\nif (!continueVisit) {\n@@ -119,15 +119,15 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\nreturn true\n}\n- override fun visitChanges(oldNode: CLHamtNode<*>, visitor: IChangeVisitor) {\n+ override fun visitChanges(oldNode: CLHamtNode<*>?, visitor: IChangeVisitor?) {\nif (oldNode === this) {\nreturn\n}\nif (oldNode is CLHamtInternal) {\n- val oldInternalNode = oldNode\n- if (data.bitmap == oldInternalNode.data.bitmap) {\n- for (i in data.children.indices) {\n- getChild(data.children[i])!!.visitChanges(oldInternalNode.getChild(oldInternalNode.data.children[i]), visitor)\n+ val oldInternalNode : CLHamtInternal = oldNode\n+ if (data_.bitmap == oldInternalNode.data_.bitmap) {\n+ for (i in data_.children.indices) {\n+ getChild(data_.children[i])!!.visitChanges(oldInternalNode.getChild(oldInternalNode.data_.children[i]), visitor)\n}\n} else {\nfor (logicalIndex in 0 until ENTRIES_PER_LEVEL) {\n@@ -139,7 +139,7 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\n} else {\noldChild.visitEntries(\nBiPredicate { key, value ->\n- visitor.entryRemoved(key!!, value)\n+ visitor!!.entryRemoved(key!!, value)\ntrue\n}\n)\n@@ -148,7 +148,7 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\nif (oldChild == null) {\nchild.visitEntries(\nBiPredicate { key, value ->\n- visitor.entryAdded(key!!, value)\n+ visitor!!.entryAdded(key!!, value)\ntrue\n}\n)\n@@ -161,24 +161,24 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal?> {\n} else if (oldNode is CLHamtLeaf) {\nval oldLeafNode = oldNode\nvisitEntries(\n- BiPredicate<Long, String> { k, v ->\n+ BiPredicate<Long?, String?> { k, v ->\nif (k == oldLeafNode.key) {\nval oldValue = oldLeafNode.value\nif (v != oldValue) {\n- visitor.entryChanged(k, oldValue, v)\n+ visitor!!.entryChanged(k, oldValue, v)\n}\n} else {\n- visitor.entryAdded(k, v)\n+ visitor!!.entryAdded(k!!, v)\n}\ntrue\n}\n)\n} else {\n- throw RuntimeException(\"Unknown type: \" + oldNode.javaClass.name)\n+ throw RuntimeException(\"Unknown type: \" + oldNode!!.javaClass.name)\n}\n}\noverride fun getData(): CPHamtNode {\n- return data\n+ return data_\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLHamtLeaf.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLHamtLeaf.kt", "diff": "@@ -9,7 +9,7 @@ import java.util.function.BiPredicate\nclass CLHamtLeaf : CLHamtNode<CPHamtLeaf?> {\nprivate val data: CPHamtLeaf\n- constructor(data: CPHamtLeaf, store: IDeserializingKeyValueStore?) : super(store) {\n+ constructor(data: CPHamtLeaf, store: IDeserializingKeyValueStore?) : super(store!!) {\nthis.data = data\n}\n@@ -29,7 +29,7 @@ class CLHamtLeaf : CLHamtNode<CPHamtLeaf?> {\nval value: String\nget() = data.value\n- override fun put(key: Long, value: String, shift: Int): CLHamtNode<*>? {\n+ override fun put(key: Long, value: String?, shift: Int): CLHamtNode<*>? {\nreturn if (key == data.key) {\nif (value == data.value) {\nthis\n@@ -40,7 +40,7 @@ class CLHamtLeaf : CLHamtNode<CPHamtLeaf?> {\nif (shift > MAX_SHIFT) {\nthrow RuntimeException(\"$shift > $MAX_SHIFT\")\n}\n- var result = createEmptyNode()\n+ var result : CLHamtNode<*>?= createEmptyNode()\nresult = result!!.put(data.key, data.value, shift)\nif (result == null) {\nresult = createEmptyNode()\n@@ -58,31 +58,31 @@ class CLHamtLeaf : CLHamtNode<CPHamtLeaf?> {\n}\n}\n- override fun get(key: Long, shift: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<String?> {\n- return bulkQuery.constant<String?>(if (data.key == key) data.value else null)!!\n+ override fun get(key: Long, shift: Int, bulkQuery: IBulkQuery?): IBulkQuery.Value<String?> {\n+ return bulkQuery!!.constant<String?>(if (data.key == key) data.value else null)!!\n}\n- override fun visitEntries(visitor: BiPredicate<Long, String>): Boolean {\n- return visitor.test(data.key, data.value)\n+ override fun visitEntries(visitor: BiPredicate<Long?, String?>?): Boolean {\n+ return visitor!!.test(data.key, data.value)\n}\n- override fun visitChanges(oldNode: CLHamtNode<*>, visitor: IChangeVisitor) {\n+ override fun visitChanges(oldNode: CLHamtNode<*>?, visitor: IChangeVisitor?) {\nif (oldNode === this) {\nreturn\n}\nval oldValue = MutableObject<String?>()\n- oldNode.visitEntries { k, v ->\n+ val bp : BiPredicate<Long?, String?> = BiPredicate { k, v ->\nif (k == data.key) {\noldValue.setValue(v)\n} else {\n- visitor.entryRemoved(k!!, v)\n- }\n- true\n+ visitor!!.entryRemoved(k!!, v)\n}\n+ true }\n+ oldNode!!.visitEntries(bp)\nif (oldValue.value == null) {\n- visitor.entryAdded(data.key, data.value)\n+ visitor!!.entryAdded(data.key, data.value)\n} else if (oldValue.value !== data.value) {\n- visitor.entryChanged(data.key, oldValue.value, data.value)\n+ visitor!!.entryChanged(data.key, oldValue.value, data.value)\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLHamtNode.kt", "diff": "+package org.modelix.model.lazy\n+\n+import org.modelix.model.lazy.CLHamtInternal\n+import org.modelix.model.persistent.CPElement\n+import org.modelix.model.persistent.CPHamtInternal\n+import org.modelix.model.persistent.CPHamtLeaf\n+import org.modelix.model.persistent.CPHamtNode\n+import java.util.function.BiPredicate\n+import java.util.function.Function\n+\n+abstract class CLHamtNode<E : CPHamtNode?>(protected var store: IDeserializingKeyValueStore) {\n+ protected fun createEmptyNode(): CLHamtNode<*> {\n+ return create(CPHamtInternal(0, arrayOfNulls(0)), store)!!\n+ }\n+\n+ abstract fun getData() : CPHamtNode?\n+\n+ operator fun get(key: Long): String? {\n+ val bulkQuery: IBulkQuery = NonBulkQuery(store)\n+ return get(key, 0, bulkQuery)!!.execute()\n+ }\n+\n+ fun getAll(keys: Iterable<Long>?, bulkQuery: IBulkQuery): IBulkQuery.Value<List<String?>?>? {\n+ val f: Function<Long, IBulkQuery.Value<String?>?>? = Function { key: Long -> get(key, 0, bulkQuery) }\n+ return bulkQuery.map(keys, f)\n+ }\n+\n+ fun put(key: Long, value: String?): CLHamtNode<*>? {\n+ return put(key, value, 0)\n+ }\n+\n+ fun put(element: CLElement): CLHamtNode<*>? {\n+ return put(element.id, element.getData()!!.hash)\n+ }\n+\n+ fun put(data: CPElement): CLHamtNode<*>? {\n+ return put(data.id, data.hash)\n+ }\n+\n+ fun remove(key: Long): CLHamtNode<*>? {\n+ return remove(key, 0)\n+ }\n+\n+ fun remove(element: CLElement): CLHamtNode<*>? {\n+ return remove(element.id)\n+ }\n+\n+ abstract operator fun get(key: Long, shift: Int, bulkQuery: IBulkQuery?): IBulkQuery.Value<String?>?\n+ abstract fun put(key: Long, value: String?, shift: Int): CLHamtNode<*>?\n+ abstract fun remove(key: Long, shift: Int): CLHamtNode<*>?\n+ abstract fun visitEntries(visitor: BiPredicate<Long?, String?>?): Boolean\n+ abstract fun visitChanges(oldNode: CLHamtNode<*>?, visitor: IChangeVisitor?)\n+ interface IChangeVisitor {\n+ fun entryAdded(key: Long, value: String?)\n+ fun entryRemoved(key: Long, value: String?)\n+ fun entryChanged(key: Long, oldValue: String?, newValue: String?)\n+ }\n+\n+ companion object {\n+ const val BITS_PER_LEVEL = 5\n+ const val ENTRIES_PER_LEVEL = 1 shl BITS_PER_LEVEL\n+ const val LEVEL_MASK = -0x1 ushr 32 - BITS_PER_LEVEL\n+ const val MAX_BITS = 64\n+ const val MAX_SHIFT = MAX_BITS - BITS_PER_LEVEL\n+ @JvmStatic\n+ fun create(data: CPHamtNode?, store: IDeserializingKeyValueStore?): CLHamtNode<*>? {\n+ if (data == null) {\n+ return null\n+ }\n+ return if (data is CPHamtLeaf) {\n+ CLHamtLeaf((data as CPHamtLeaf?)!!, store)\n+ } else if (data is CPHamtInternal) {\n+ CLHamtInternal((data as CPHamtInternal?)!!, store)\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + data.javaClass.name)\n+ }\n+ }\n+\n+ fun logicalToPhysicalIndex(bitmap: Int, logicalIndex: Int): Int {\n+ return Integer.bitCount(bitmap and (1 shl logicalIndex) - 1)\n+ }\n+\n+ fun isBitNotSet(bitmap: Int, logicalIndex: Int): Boolean {\n+ return bitmap and (1 shl logicalIndex) == 0\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CLHamtNode
426,504
02.08.2020 09:44:19
-7,200
57b063fa2168cef891551c37ddc146fecba7572c
translate SmallPMap
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/util/pmap/SmallPMap.java", "new_path": null, "diff": "-package org.modelix.model.util.pmap;\n-\n-import org.modelix.model.util.StreamUtils;\n-\n-import java.util.Collections;\n-import java.util.Objects;\n-import java.util.stream.Collectors;\n-import java.util.stream.Stream;\n-\n-public abstract class SmallPMap<K, V> implements CustomPMap<K, V> {\n- private static final SmallPMap EMPTY = new Multiple(new Object[0], new Object[0]);\n- public static <K, V> SmallPMap<K, V> empty() {\n- return EMPTY;\n- }\n- private static <K, V> SmallPMap<K, V> create(Object[] keys, Object[] values) {\n- if (keys.length == 0) {\n- return empty();\n- }\n- if (keys.length == 1) {\n- return new Single<K, V>((K) keys[0], (V) values[0]);\n- }\n- return new Multiple<K, V>(keys, values);\n- }\n-\n- public static <K, V> SmallPMap<K, V> createS(Iterable<K> keys, Iterable<V> values) {\n- return create(\n- StreamUtils.INSTANCE.toStream(keys).toArray(Object[]::new),\n- StreamUtils.INSTANCE.toStream(values).toArray(Object[]::new));\n- }\n-\n- @Override\n- public abstract V get(K key);\n- @Override\n- public abstract SmallPMap<K, V> put(K key, V value);\n- @Override\n- public abstract SmallPMap<K, V> remove(K key);\n- @Override\n- public abstract Iterable<K> keys();\n- @Override\n- public abstract Iterable<V> values();\n-\n- public static class Single<K, V> extends SmallPMap<K, V> {\n- private K key;\n- private V value;\n-\n- private Single(K key, V value) {\n- this.key = key;\n- this.value = value;\n- }\n- @Override\n- public V get(K key) {\n- return (Objects.equals(this.key, key) ? value : null);\n- }\n- @Override\n- public Iterable<K> keys() {\n- return Collections.singleton(key);\n- }\n- @Override\n- public SmallPMap<K, V> put(K key, V value) {\n- if (value == null) {\n- return remove(key);\n- }\n- if (Objects.equals(key, this.key)) {\n- if (Objects.equals(value, this.value)) {\n- return this;\n- } else {\n- return new Single<K, V>(key, value);\n- }\n- }\n- return create(new Object[]{this.key, key}, new Object[]{this.value, value});\n- }\n- @Override\n- public SmallPMap<K, V> remove(K key) {\n- return (Objects.equals(key, this.key) ? EMPTY : this);\n- }\n- @Override\n- public Iterable<V> values() {\n- return Collections.singleton(value);\n- }\n- @Override\n- public boolean containsKey(K key) {\n- return Objects.equals(key, this.key);\n- }\n- }\n-\n- public static class Multiple<K, V> extends SmallPMap<K, V> {\n- private Object[] keys;\n- private Object[] values;\n-\n- private Multiple(Object[] keys, Object[] values) {\n- this.keys = keys;\n- this.values = values;\n- }\n-\n- @Override\n- public V get(K key) {\n- for (int i = 0; i < keys.length; i++) {\n- if (Objects.equals(keys[i], key)) {\n- return (V) values[i];\n- }\n- }\n- return null;\n- }\n-\n- @Override\n- public SmallPMap<K, V> put(K key, V value) {\n- if (value == null) {\n- return remove(key);\n- }\n-\n- int index = COWArrays.INSTANCE.indexOf(keys, key);\n- if (index != -1) {\n- if (Objects.equals(value, values[index])) {\n- return this;\n- } else {\n- return create(keys, COWArrays.INSTANCE.set(values, index, value));\n- }\n- } else {\n- return create(COWArrays.INSTANCE.add(keys, key), COWArrays.INSTANCE.add(values, value));\n- }\n- }\n-\n- @Override\n- public SmallPMap<K, V> remove(K key) {\n- int index = COWArrays.INSTANCE.indexOf(keys, key);\n- if (index != -1) {\n- return create(COWArrays.INSTANCE.removeAt(keys, index), COWArrays.INSTANCE.removeAt(values, index));\n- } else {\n- return this;\n- }\n- }\n-\n- @Override\n- public Iterable<K> keys() {\n- return Stream.of(keys).map(it -> (K)it).collect(Collectors.toList());\n- }\n-\n- @Override\n- public Iterable<V> values() {\n- return Stream.of(values).map(it -> (V)it).collect(Collectors.toList());\n- }\n-\n- @Override\n- public boolean containsKey(K key) {\n- for (Object k : this.keys) {\n- if (Objects.equals(k, key)) {\n- return true;\n- }\n- }\n- return false;\n- }\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/util/pmap/SmallPMap.kt", "diff": "+package org.modelix.model.util.pmap\n+\n+import org.modelix.model.util.StreamUtils.toStream\n+import org.modelix.model.util.pmap.COWArrays.add\n+import org.modelix.model.util.pmap.COWArrays.indexOf\n+import org.modelix.model.util.pmap.COWArrays.removeAt\n+import org.modelix.model.util.pmap.COWArrays.set\n+import java.util.stream.Collectors\n+import java.util.stream.Stream\n+\n+abstract class SmallPMap<K, V> : CustomPMap<K, V> {\n+ abstract override fun get(key: K): V\n+ abstract override fun put(key: K, value: V): SmallPMap<K, V>?\n+ abstract override fun remove(key: K): SmallPMap<K, V>?\n+ abstract override fun keys(): Iterable<K>?\n+ abstract override fun values(): Iterable<V>?\n+ class Single<K, V>(private val key: K, private val value: V) : SmallPMap<K, V?>() {\n+ override fun get(key: K): V? {\n+ return if (this.key == key) value else null\n+ }\n+\n+ override fun keys(): Iterable<K>? {\n+ return setOf(key)\n+ }\n+\n+ override fun put(key: K, value: V?): SmallPMap<K, V?>? {\n+ if (value == null) {\n+ return remove(key) as SmallPMap<K, V?>?\n+ }\n+ return if (key == this.key) {\n+ if (value == this.value) {\n+ this as SmallPMap<K, V?>?\n+ } else {\n+ Single<K, V>(key, value) as SmallPMap<K, V?>?\n+ }\n+ } else {\n+ var res : SmallPMap<K, V?>?\n+ val p1 : Array<Any?> = arrayOf(this.key, key)\n+ val p2 : Array<Any?> = arrayOf(this.value, value)\n+ res = create<K, V?>(p1, p2) as SmallPMap<K, V?>?\n+ return res as SmallPMap<K, V?>?\n+ }\n+ }\n+\n+ override fun remove(key: K): SmallPMap<K, V?>? {\n+ return if (key == this.key) EMPTY as SmallPMap<K, V?>? else this\n+ }\n+\n+ override fun values(): Iterable<V?>? {\n+ return setOf(value)\n+ }\n+\n+ override fun containsKey(key: K): Boolean {\n+ return key == this.key\n+ }\n+\n+ }\n+\n+ class Multiple<K, V>(private val keys: Array<Any?>, private val values: Array<Any?>) : SmallPMap<K, V?>() {\n+ override fun get(key: K): V? {\n+ for (i in keys.indices) {\n+ if (keys[i] == key) {\n+ return values[i] as V?\n+ }\n+ }\n+ return null\n+ }\n+\n+ override fun put(key: K, value: V?): SmallPMap<K, V?>? {\n+ if (value == null) {\n+ return remove(key)as SmallPMap<K, V?>?\n+ }\n+ val index = indexOf(keys, key)\n+ return if (index != -1) {\n+ if (value == values[index]) {\n+ this as SmallPMap<K, V?>?\n+ } else {\n+ create<K,V?>(keys, set(values, index, value)) as SmallPMap<K, V?>?\n+ }\n+ } else {\n+ create<K,V?>(add(keys, key), add(values, value)) as SmallPMap<K, V?>?\n+ }\n+ }\n+\n+ override fun remove(key: K): SmallPMap<K, V?>? {\n+ val index = indexOf(keys, key)\n+ return if (index != -1) {\n+ create<K,V?>(removeAt(keys, index), removeAt(values, index)) as SmallPMap<K, V?>?\n+ } else {\n+ this\n+ }\n+ }\n+\n+ override fun keys(): Iterable<K>? {\n+ return Stream.of<Any>(*keys).map { it: Any -> it as K }.collect(Collectors.toList())\n+ }\n+\n+ override fun values(): Iterable<V?>? {\n+ return Stream.of<Any>(*values).map { it: Any -> it as V }.collect(Collectors.toList())\n+ }\n+\n+ override fun containsKey(key: K): Boolean {\n+ for (k in keys) {\n+ if (k == key) {\n+ return true\n+ }\n+ }\n+ return false\n+ }\n+\n+ }\n+\n+ companion object {\n+ private val EMPTY: SmallPMap<*, *> = Multiple<Any?, Any?>(arrayOfNulls(0), arrayOfNulls(0))\n+ fun <K, V> empty(): SmallPMap<K, V> {\n+ return EMPTY as SmallPMap<K, V>\n+ }\n+\n+ private fun <K, V> create(keys: Array<Any?>, values: Array<Any?>): SmallPMap<K?, V?> {\n+ if (keys.size == 0) {\n+ return empty()\n+ }\n+ return if (keys.size == 1) {\n+ Single(keys[0] as K?, values[0] as V?)\n+ } else Multiple<K?, V?>(keys, values)\n+ }\n+\n+ fun <K, V> createS(keys: Iterable<K>?, values: Iterable<V>?): SmallPMap<K, V> {\n+ return create<K,V>(\n+ toStream(keys!!).collect(Collectors.toList()).toTypedArray(),\n+ toStream(values!!).collect(Collectors.toList()).toTypedArray()) as SmallPMap<K, V>\n+ }\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate SmallPMap
426,504
02.08.2020 09:55:33
-7,200
8e66aec8090870dc4f72308f66bda97e5e0ad752
translate OperationSerializer
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/OperationSerializer.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-import org.modelix.model.api.IConcept;\n-import org.modelix.model.api.INodeReference;\n-import org.modelix.model.api.PNodeReference;\n-import org.modelix.model.operations.AddNewChildOp;\n-import org.modelix.model.operations.DeleteNodeOp;\n-import org.modelix.model.operations.IOperation;\n-import org.modelix.model.operations.MoveNodeOp;\n-import org.modelix.model.operations.NoOp;\n-import org.modelix.model.operations.SetPropertyOp;\n-import org.modelix.model.operations.SetReferenceOp;\n-\n-import java.util.HashMap;\n-import java.util.Map;\n-\n-public class OperationSerializer {\n-\n- public static final OperationSerializer INSTANCE = new OperationSerializer();\n-\n- static {\n- INSTANCE.registerSerializer(AddNewChildOp.class, new Serializer<AddNewChildOp>() {\n- @Override\n- public String serialize(AddNewChildOp op) {\n- return SerializationUtil.longToHex(op.getParentId()) + SEPARATOR + SerializationUtil.escape(op.getRole()) + SEPARATOR + op.getIndex() + SEPARATOR + SerializationUtil.longToHex(op.getChildId()) + SEPARATOR + serializeConcept(op.getConcept());\n- }\n-\n- @Override\n- public AddNewChildOp deserialize(String serialized) {\n- String[] parts = serialized.split(SEPARATOR, -1);\n- return new AddNewChildOp(SerializationUtil.longFromHex(parts[0]), SerializationUtil.unescape(parts[1]), Integer.parseInt(parts[2]), SerializationUtil.longFromHex(parts[3]), deserializeConcept(parts[4]));\n- }\n- });\n- INSTANCE.registerSerializer(DeleteNodeOp.class, new Serializer<DeleteNodeOp>() {\n- @Override\n- public String serialize(DeleteNodeOp op) {\n- return SerializationUtil.longToHex(op.getParentId()) + SEPARATOR + SerializationUtil.escape(op.getRole()) + SEPARATOR + op.getIndex() + SEPARATOR + SerializationUtil.longToHex(op.getChildId());\n- }\n-\n- @Override\n- public DeleteNodeOp deserialize(String serialized) {\n- String[] parts = serialized.split(SEPARATOR, -1);\n- return new DeleteNodeOp(SerializationUtil.longFromHex(parts[0]), SerializationUtil.unescape(parts[1]), Integer.parseInt(parts[2]), SerializationUtil.longFromHex(parts[3]));\n- }\n- });\n- INSTANCE.registerSerializer(MoveNodeOp.class, new Serializer<MoveNodeOp>() {\n- @Override\n- public String serialize(MoveNodeOp op) {\n- return SerializationUtil.longToHex(op.getChildId()) + SEPARATOR + SerializationUtil.longToHex(op.getSourceParentId()) + SEPARATOR + SerializationUtil.escape(op.getSourceRole()) + SEPARATOR + op.getSourceIndex() + SEPARATOR + SerializationUtil.longToHex(op.getTargetParentId()) + SEPARATOR + SerializationUtil.escape(op.getTargetRole()) + SEPARATOR + op.getTargetIndex();\n- }\n-\n- @Override\n- public MoveNodeOp deserialize(String serialized) {\n- String[] parts = serialized.split(SEPARATOR, -1);\n- return new MoveNodeOp(SerializationUtil.longFromHex(parts[0]), SerializationUtil.longFromHex(parts[1]), SerializationUtil.unescape(parts[2]), Integer.parseInt(parts[3]), SerializationUtil.longFromHex(parts[4]), SerializationUtil.unescape(parts[5]), Integer.parseInt(parts[6]));\n- }\n- });\n- INSTANCE.registerSerializer(NoOp.class, new Serializer<NoOp>() {\n- @Override\n- public String serialize(NoOp op) {\n- return \"\";\n- }\n-\n- @Override\n- public NoOp deserialize(String serialized) {\n- return new NoOp();\n- }\n- });\n- INSTANCE.registerSerializer(SetPropertyOp.class, new Serializer<SetPropertyOp>() {\n- @Override\n- public String serialize(SetPropertyOp op) {\n- return SerializationUtil.longToHex(op.getNodeId()) + SEPARATOR + SerializationUtil.escape(op.getRole()) + SEPARATOR + SerializationUtil.escape(op.getValue());\n- }\n-\n- @Override\n- public SetPropertyOp deserialize(String serialized) {\n- String[] parts = serialized.split(SEPARATOR, -1);\n- return new SetPropertyOp(SerializationUtil.longFromHex(parts[0]), SerializationUtil.unescape(parts[1]), SerializationUtil.unescape(parts[2]));\n- }\n- });\n- INSTANCE.registerSerializer(SetReferenceOp.class, new Serializer<SetReferenceOp>() {\n- @Override\n- public String serialize(SetReferenceOp op) {\n- return SerializationUtil.longToHex(op.getSourceId()) + SEPARATOR + SerializationUtil.escape(op.getRole()) + SEPARATOR + serializeReference(op.getTarget());\n- }\n-\n- @Override\n- public SetReferenceOp deserialize(String serialized) {\n- String[] parts = serialized.split(SEPARATOR, -1);\n- return new SetReferenceOp(SerializationUtil.longFromHex(parts[0]), SerializationUtil.unescape(parts[1]), deserializeReference(parts[2]));\n- }\n- });\n-\n- }\n-\n- private static final String SEPARATOR = \";\";\n-\n- private Map<Class<? extends IOperation>, Serializer> serializers = new HashMap<>();\n- private Map<String, Serializer> deserializers = new HashMap<>();\n-\n- private OperationSerializer() {\n- }\n-\n- public <T extends IOperation> void registerSerializer(Class<T> type, Serializer<T> serializer) {\n- serializers.put(type, serializer);\n- deserializers.put(type.getSimpleName(), serializer);\n- }\n-\n- public String serialize(IOperation op) {\n- Serializer serializer = serializers.get(op.getClass());\n- if (serializer == null) {\n- throw new RuntimeException(\"Unknown operation type: \" + op.getClass().getSimpleName());\n- }\n- return op.getClass().getSimpleName() + SEPARATOR + serializer.serialize(op);\n- }\n-\n- public IOperation deserialize(String serialized) {\n- String[] parts = serialized.split(SEPARATOR, 2);\n- Serializer deserializer = deserializers.get(parts[0]);\n- if (deserializer == null) {\n- throw new RuntimeException(\"Unknown operation type: \" + parts[0]);\n- }\n- return deserializer.deserialize(parts[1]);\n- }\n-\n-\n- public interface Serializer<E extends IOperation> {\n- String serialize(E op);\n- E deserialize(String serialized);\n- }\n-\n- public static String serializeConcept(IConcept concept) {\n-// return SerializationUtil.escape(((SAbstractConceptAdapter) ((SConceptAdapter) concept).getAdapted()).serialize());\n- throw new UnsupportedOperationException();\n- }\n-\n- public static IConcept deserializeConcept(String serialized) {\n-// return new SConceptAdapter(SAbstractConceptAdapter.deserialize(SerializationUtil.unescape(serialized)));\n- throw new UnsupportedOperationException();\n- }\n-\n- public static String serializeReference(INodeReference object) {\n- if (object == null) {\n- return \"\";\n- } else if (object instanceof PNodeReference) {\n- return SerializationUtil.longToHex(((PNodeReference) object).getId());\n-// } else if (object instanceof SNodeReferenceAdapter) {\n-// return SerializationUtil.escape(SNodePointer.serialize(((SNodeReferenceAdapter) object).getReference()));\n- } else {\n- throw new RuntimeException(\"Unknown reference type: \" + object.getClass().getName());\n- }\n- }\n-\n- public static INodeReference deserializeReference(String serialized) {\n- if ((serialized == null || serialized.length() == 0)) {\n- return null;\n- }\n- if (serialized.matches(\"[a-fA-F0-9]+\")) {\n- return new PNodeReference(SerializationUtil.longFromHex(serialized));\n- }\n-// return new SNodeReferenceAdapter(SNodePointer.deserialize(SerializationUtil.unescape(serialized)));\n- throw new RuntimeException(\"Cannot deserialize concept: \" + serialized);\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/persistent/CPOperationsList.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/persistent/CPOperationsList.kt", "diff": "@@ -9,7 +9,7 @@ import java.util.stream.Stream\nclass CPOperationsList(val operations: Array<IOperation?>) {\nfun serialize(): String {\nreturn Stream.of(*operations)\n- .map { op: IOperation? -> OperationSerializer.INSTANCE.serialize(op) }\n+ .map { op: IOperation? -> OperationSerializer.INSTANCE.serialize(op!!) }\n.reduce { a: String, b: String -> \"$a,$b\" }\n.orElse(\"\")\n}\n@@ -22,7 +22,7 @@ class CPOperationsList(val operations: Array<IOperation?>) {\nreturn CPOperationsList(\nStream.of(*input.split(\",\").toTypedArray())\n.filter { cs: String? -> StringUtils.isNotEmpty(cs) }\n- .map { serialized: String? -> OperationSerializer.INSTANCE.deserialize(serialized) }\n+ .map { serialized: String? -> OperationSerializer.INSTANCE.deserialize(serialized!!) }\n.collect(Collectors.toList()).toTypedArray()\n)\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/persistent/CPVersion.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/persistent/CPVersion.kt", "diff": "@@ -32,7 +32,7 @@ class CPVersion(id: Long, time: String?, author: String?, treeHash: String?, pre\nfun serialize(): String {\nval opsPart = operationsHash\n?: operations!!.toList().stream()\n- .map(Function<IOperation?, String> { op: IOperation? -> OperationSerializer.INSTANCE.serialize(op) })\n+ .map(Function<IOperation?, String> { op: IOperation? -> OperationSerializer.INSTANCE.serialize(op!!) })\n.reduce { a: String, b: String -> \"$a,$b\" }\n.orElse(\"\")\nvar serialized = longToHex(id) +\n@@ -61,7 +61,7 @@ class CPVersion(id: Long, time: String?, author: String?, treeHash: String?, pre\n} else {\nops = Stream.of(*parts[5].split(\",\").toTypedArray())\n.filter { cs: String? -> StringUtils.isNotEmpty(cs) }\n- .map { serialized: String? -> OperationSerializer.INSTANCE.deserialize(serialized) }\n+ .map { serialized: String? -> OperationSerializer.INSTANCE.deserialize(serialized!!) }\n.collect(Collectors.toList()).toTypedArray()\n}\nval numOps = if (parts.size >= 7) parts[6].toInt() else -1\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/persistent/OperationSerializer.kt", "diff": "+package org.modelix.model.persistent\n+\n+import org.modelix.model.api.IConcept\n+import org.modelix.model.api.INodeReference\n+import org.modelix.model.api.PNodeReference\n+import org.modelix.model.operations.*\n+import org.modelix.model.persistent.SerializationUtil.escape\n+import org.modelix.model.persistent.SerializationUtil.longFromHex\n+import org.modelix.model.persistent.SerializationUtil.longToHex\n+import org.modelix.model.persistent.SerializationUtil.unescape\n+import java.lang.IllegalArgumentException\n+import java.lang.IllegalStateException\n+import java.util.*\n+\n+class OperationSerializer private constructor() {\n+ companion object {\n+ val INSTANCE = OperationSerializer()\n+ private const val SEPARATOR = \";\"\n+ fun serializeConcept(concept: IConcept?): String {\n+// return SerializationUtil.escape(((SAbstractConceptAdapter) ((SConceptAdapter) concept).getAdapted()).serialize());\n+ throw UnsupportedOperationException()\n+ }\n+\n+ fun deserializeConcept(serialized: String?): IConcept {\n+// return new SConceptAdapter(SAbstractConceptAdapter.deserialize(SerializationUtil.unescape(serialized)));\n+ throw UnsupportedOperationException()\n+ }\n+\n+ fun serializeReference(`object`: INodeReference?): String {\n+ return if (`object` == null) {\n+ \"\"\n+ } else if (`object` is PNodeReference) {\n+ longToHex(`object`.id)\n+ // } else if (object instanceof SNodeReferenceAdapter) {\n+// return SerializationUtil.escape(SNodePointer.serialize(((SNodeReferenceAdapter) object).getReference()));\n+ } else {\n+ throw RuntimeException(\"Unknown reference type: \" + `object`.javaClass.name)\n+ }\n+ }\n+\n+ fun deserializeReference(serialized: String?): INodeReference? {\n+ if (serialized == null || serialized.length == 0) {\n+ return null\n+ }\n+ if (serialized.matches(Regex(\"[a-fA-F0-9]+\"))) {\n+ return PNodeReference(longFromHex(serialized))\n+ }\n+ throw RuntimeException(\"Cannot deserialize concept: $serialized\")\n+ }\n+\n+ init {\n+ INSTANCE.registerSerializer(AddNewChildOp::class.java, object : Serializer<AddNewChildOp> {\n+ override fun serialize(op: AddNewChildOp): String {\n+ return longToHex(op.parentId) + SEPARATOR + escape(op.role) + SEPARATOR + op.index + SEPARATOR + longToHex(op.childId) + SEPARATOR + serializeConcept(op.concept)\n+ }\n+\n+ override fun deserialize(serialized: String): AddNewChildOp {\n+ val parts = serialized.split(SEPARATOR).dropLastWhile { it.isEmpty() }.toTypedArray()\n+ return AddNewChildOp(longFromHex(parts[0]), unescape(parts[1])!!, parts[2].toInt(), longFromHex(parts[3]), deserializeConcept(parts[4]))\n+ }\n+ })\n+ INSTANCE.registerSerializer(DeleteNodeOp::class.java, object : Serializer<DeleteNodeOp> {\n+ override fun serialize(op: DeleteNodeOp): String {\n+ return longToHex(op.parentId) + SEPARATOR + escape(op.role) + SEPARATOR + op.index + SEPARATOR + longToHex(op.childId)\n+ }\n+\n+ override fun deserialize(serialized: String): DeleteNodeOp {\n+ val parts = serialized.split(SEPARATOR).dropLastWhile { it.isEmpty() }.toTypedArray()\n+ return DeleteNodeOp(longFromHex(parts[0]), unescape(parts[1])!!, parts[2].toInt(), longFromHex(parts[3]))\n+ }\n+ })\n+ INSTANCE.registerSerializer(MoveNodeOp::class.java, object : Serializer<MoveNodeOp> {\n+ override fun serialize(op: MoveNodeOp): String {\n+ return longToHex(op.childId) + SEPARATOR + longToHex(op.sourceParentId) + SEPARATOR + escape(op.sourceRole) + SEPARATOR + op.sourceIndex + SEPARATOR + longToHex(op.targetParentId) + SEPARATOR + escape(op.targetRole) + SEPARATOR + op.targetIndex\n+ }\n+\n+ override fun deserialize(serialized: String): MoveNodeOp {\n+ val parts = serialized.split(SEPARATOR).dropLastWhile { it.isEmpty() }.toTypedArray()\n+ return MoveNodeOp(longFromHex(parts[0]), longFromHex(parts[1]), unescape(parts[2])!!, parts[3].toInt(), longFromHex(parts[4]), unescape(parts[5])!!, parts[6].toInt())\n+ }\n+ })\n+ INSTANCE.registerSerializer<NoOp>(NoOp::class.java, object : Serializer<NoOp> {\n+ override fun serialize(op: NoOp): String {\n+ return \"\"\n+ }\n+\n+ override fun deserialize(serialized: String): NoOp {\n+ return NoOp()\n+ }\n+ })\n+ INSTANCE.registerSerializer(SetPropertyOp::class.java, object : Serializer<SetPropertyOp> {\n+ override fun serialize(op: SetPropertyOp): String {\n+ return longToHex(op.nodeId) + SEPARATOR + escape(op.role) + SEPARATOR + escape(op.value)\n+ }\n+\n+ override fun deserialize(serialized: String): SetPropertyOp {\n+ val parts = serialized.split(SEPARATOR).dropLastWhile { it.isEmpty() }.toTypedArray()\n+ return SetPropertyOp(longFromHex(parts[0]), unescape(parts[1])!!, unescape(parts[2])!!)\n+ }\n+ })\n+ INSTANCE.registerSerializer(SetReferenceOp::class.java, object : Serializer<SetReferenceOp> {\n+ override fun serialize(op: SetReferenceOp): String {\n+ return longToHex(op.sourceId) + SEPARATOR + escape(op.role) + SEPARATOR + serializeReference(op.target)\n+ }\n+\n+ override fun deserialize(serialized: String): SetReferenceOp {\n+ val parts = serialized.split(SEPARATOR).dropLastWhile { it.isEmpty() }.toTypedArray()\n+ return SetReferenceOp(longFromHex(parts[0]), unescape(parts[1])!!, deserializeReference(parts[2])!!)\n+ }\n+ })\n+ }\n+ }\n+\n+ private val serializers: MutableMap<Class<out IOperation>, Serializer<*>> = HashMap()\n+ private val deserializers: MutableMap<String, Serializer<*>> = HashMap()\n+ fun <T : IOperation> registerSerializer(type: Class<T>, serializer: Serializer<T>) {\n+ serializers[type] = serializer\n+ deserializers[type.simpleName] = serializer\n+ }\n+\n+ fun serialize(op: IOperation): String {\n+ val serializer : Serializer<*> = serializers[op.javaClass]\n+ ?: throw RuntimeException(\"Unknown operation type: \" + op.javaClass.simpleName)\n+ return op.javaClass.simpleName + SEPARATOR + serializer.genericSerialize(op)\n+ }\n+\n+ fun deserialize(serialized: String): IOperation {\n+ val parts = serialized.split(Regex(SEPARATOR), 2).toTypedArray()\n+ val deserializer = deserializers[parts[0]]\n+ ?: throw RuntimeException(\"Unknown operation type: \" + parts[0])\n+ return deserializer.deserialize(parts[1])!!\n+ }\n+\n+ interface Serializer<E : IOperation?> {\n+ fun genericSerialize(op: Any) : String {\n+ val p = op as? E\n+ if (p == null) {\n+ throw IllegalArgumentException()\n+ } else {\n+ return serialize(p)\n+ }\n+ }\n+ fun serialize(op: E): String\n+ fun deserialize(serialized: String): E\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate OperationSerializer
426,504
02.08.2020 10:01:12
-7,200
41eac37d4e3718f51bf54f0d932e1e59c45b33a0
translate CPNode
[ { "change_type": "DELETE", "old_path": "model-client/src/main/java/org/modelix/model/persistent/CPNode.java", "new_path": null, "diff": "-package org.modelix.model.persistent;\n-\n-import org.modelix.model.util.pmap.COWArrays;\n-import org.apache.commons.lang3.StringUtils;\n-import org.apache.log4j.LogManager;\n-import org.apache.log4j.Logger;\n-\n-import java.util.Arrays;\n-import java.util.Iterator;\n-import java.util.List;\n-import java.util.function.Function;\n-import java.util.stream.Collectors;\n-\n-public class CPNode extends CPElement {\n- private static final Logger LOG = LogManager.getLogger(CPNode.class);\n- private static final long[] EMPTY_LONG_ARRAY = new long[0];\n- public static final Function<String, CPNode> DESERIALIZER = s -> deserialize(s);\n-\n- public static CPNode create(long id, String concept, long parentId, String roleInParent, long[] childrenIds, String[] propertyRoles, String[] propertyValues, String[] referenceRoles, CPElementRef[] referenceTargets) {\n- checkForDuplicates(childrenIds);\n- if (propertyRoles.length != propertyValues.length) {\n- throw new IllegalArgumentException(propertyRoles.length + \" != \" + propertyValues.length);\n- }\n- if (referenceRoles.length != referenceTargets.length) {\n- throw new IllegalArgumentException(referenceRoles.length + \" != \" + referenceTargets.length);\n- }\n- return new CPNode(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, referenceRoles, referenceTargets);\n- }\n-\n- private final long[] childrenIds;\n- private final String concept;\n- private String[] propertyRoles;\n- private String[] propertyValues;\n- private String[] referenceRoles;\n- private CPElementRef[] referenceTargets;\n-\n- protected CPNode(long id1, String concept, long parentId1, String roleInParent1, long[] childrenIds1, String[] propertyRoles, String[] propertyValues, String[] referenceRoles, CPElementRef[] referenceTargets) {\n- super(id1, parentId1, roleInParent1);\n-\n- this.childrenIds = childrenIds1;\n- this.concept = concept;\n- this.propertyRoles = propertyRoles;\n- this.propertyValues = propertyValues;\n- this.referenceRoles = referenceRoles;\n- this.referenceTargets = referenceTargets;\n- }\n-\n- private static void checkForDuplicates(long[] values) {\n- long[] copy = new long[values.length];\n- System.arraycopy(values, 0, copy, 0, values.length);\n- Arrays.sort(copy);\n- for (int i = 1; i < copy.length; i++) {\n- if (copy[i - 1] == copy[i]) {\n- throw new RuntimeException(\"Duplicate value: \" + copy[i]);\n- }\n- }\n- }\n-\n- @Override\n- public String serialize() {\n- StringBuilder sb = new StringBuilder();\n-\n- sb.append(SerializationUtil.longToHex(getId()));\n- sb.append(\"/\");\n- sb.append(SerializationUtil.escape(concept));\n- sb.append(\"/\");\n- sb.append(SerializationUtil.longToHex(getParentId()));\n- sb.append(\"/\");\n- sb.append(SerializationUtil.escape(getRoleInParent()));\n- sb.append(\"/\");\n- sb.append(Arrays.stream(childrenIds).mapToObj(SerializationUtil::longToHex).reduce((a, b) -> a + \", \" + b));\n- sb.append(\"/\");\n- boolean first = true;\n- {\n- Iterator<String> role_it = Arrays.stream(propertyRoles).iterator();\n- Iterator<String> value_it = Arrays.stream(propertyValues).iterator();\n- String role_var;\n- String value_var;\n- while (role_it.hasNext() && value_it.hasNext()) {\n- role_var = role_it.next();\n- value_var = value_it.next();\n- if (first) {\n- first = false;\n- } else {\n- sb.append(\",\");\n- }\n- sb.append(SerializationUtil.escape(role_var)).append(\"=\").append(SerializationUtil.escape(value_var));\n- }\n- }\n- sb.append(\"/\");\n- first = true;\n- {\n- Iterator<String> role_it = Arrays.stream(referenceRoles).iterator();\n- Iterator<CPElementRef> value_it = Arrays.stream(referenceTargets).iterator();\n- String role_var;\n- CPElementRef value_var;\n- while (role_it.hasNext() && value_it.hasNext()) {\n- role_var = role_it.next();\n- value_var = value_it.next();\n- if (first) {\n- first = false;\n- } else {\n- sb.append(\",\");\n- }\n- sb.append(SerializationUtil.escape(role_var)).append(\"=\").append(SerializationUtil.escape(value_var.toString()));\n- }\n- }\n-\n- return sb.toString();\n- }\n-\n- public static CPNode deserialize(String input) {\n- try {\n- String[] parts = input.split(\"/\", -1);\n-\n- List<String[]> properties = Arrays.stream(parts[5].split(\",\"))\n- .filter(StringUtils::isNotEmpty)\n- .map(it -> it.split(\"=\", -1))\n- .collect(Collectors.toList());\n- List<String[]> references = Arrays.stream(parts[6].split(\",\"))\n- .filter(StringUtils::isNotEmpty)\n- .map(it -> it.split(\"=\", -1))\n- .collect(Collectors.toList());\n-\n- return new CPNode(\n- SerializationUtil.longFromHex(parts[0]),\n- SerializationUtil.unescape(parts[1]),\n- SerializationUtil.longFromHex(parts[2]),\n- SerializationUtil.unescape(parts[3]),\n- Arrays.stream(parts[4].split(\",\"))\n- .filter(StringUtils::isNotEmpty)\n- .mapToLong(SerializationUtil::longFromHex)\n- .toArray(),\n- properties.stream().map(it -> SerializationUtil.unescape(it[0])).toArray(String[]::new),\n- properties.stream().map(it -> SerializationUtil.unescape(it[1])).toArray(String[]::new),\n- references.stream().map(it -> SerializationUtil.unescape(it[0])).toArray(String[]::new),\n- references.stream()\n- .map(it -> CPElementRef.fromString(SerializationUtil.unescape(it[1])))\n- .toArray(CPElementRef[]::new)\n- );\n- } catch (Exception ex) {\n- throw new RuntimeException(\"Failed to deserialize \" + input, ex);\n- }\n- }\n-\n- public Iterable<Long> getChildrenIds() {\n- return Arrays.stream(childrenIds)::iterator;\n- }\n-\n- public long[] getChildrenIdArray() {\n- return COWArrays.copy(childrenIds);\n- }\n-\n- public int getChildrenSize() {\n- return childrenIds.length;\n- }\n-\n- public long getChildId(int index) {\n- return childrenIds[index];\n- }\n-\n- public String getConcept() {\n- return concept;\n- }\n-\n- public String getPropertyValue(String role) {\n- int index = Arrays.binarySearch(propertyRoles, role);\n- return (index < 0 ? null : propertyValues[index]);\n- }\n-\n- public CPElementRef getReferenceTarget(String role) {\n- int index = Arrays.binarySearch(referenceRoles, role);\n- return (index < 0 ? null : referenceTargets[index]);\n- }\n-\n- public CPNode withPropertyValue(String role, String value) {\n- int index = Arrays.binarySearch(propertyRoles, role);\n- if (value == null) {\n- if (index < 0) {\n- return this;\n- } else {\n- return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, COWArrays.INSTANCE.removeAt(propertyRoles, index), COWArrays.INSTANCE.removeAt(propertyValues, index), referenceRoles, referenceTargets);\n- }\n- } else {\n- if (index < 0) {\n- index = -(index + 1);\n- return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, COWArrays.INSTANCE.insert(propertyRoles, index, role), COWArrays.INSTANCE.insert(propertyValues, index, value), referenceRoles, referenceTargets);\n- } else {\n- return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, propertyRoles, COWArrays.INSTANCE.set(propertyValues, index, value), referenceRoles, referenceTargets);\n- }\n- }\n- }\n-\n- public CPNode withReferenceTarget(String role, CPElementRef target) {\n- int index = Arrays.binarySearch(referenceRoles, role);\n- if (target == null) {\n- if (index < 0) {\n- return this;\n- } else {\n- return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, propertyRoles, propertyValues, COWArrays.INSTANCE.removeAt(referenceRoles, index), COWArrays.INSTANCE.removeAt(referenceTargets, index));\n- }\n- } else {\n- if (index < 0) {\n- index = -(index + 1);\n- return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, propertyRoles, propertyValues, COWArrays.INSTANCE.insert(referenceRoles, index, role), COWArrays.INSTANCE.insert(referenceTargets, index, target));\n- } else {\n- return create(getId(), concept, getParentId(), getRoleInParent(), childrenIds, propertyRoles, propertyValues, referenceRoles, COWArrays.INSTANCE.set(referenceTargets, index, target));\n- }\n- }\n- }\n-\n- public String[] getPropertyRoles() {\n- return this.propertyRoles;\n- }\n- public String[] getPropertyValues() {\n- return this.propertyValues;\n- }\n- public String[] getReferenceRoles() {\n- return this.referenceRoles;\n- }\n- public CPElementRef[] getReferenceTargets() {\n- return this.referenceTargets;\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLNode.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/lazy/CLNode.kt", "diff": "@@ -7,14 +7,17 @@ import java.util.stream.Stream\nimport java.util.stream.StreamSupport\nclass CLNode(tree: CLTree?, data: CPNode?) : CLElement(tree!!, data!!) {\n- constructor(tree: CLTree?, id: Long, concept: String?, parentId: Long, roleInParent: String?, childrenIds: LongArray?, propertyRoles: Array<String?>?, propertyValues: Array<String?>?, referenceRoles: Array<String?>?, referenceTargets: Array<CPElementRef?>?) : this(tree, CPNode.create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, referenceRoles, referenceTargets)) {}\n+ constructor(tree: CLTree?, id: Long, concept: String?, parentId: Long, roleInParent: String?, childrenIds: LongArray?, propertyRoles: Array<String?>?, propertyValues: Array<String?>?, referenceRoles: Array<String?>?, referenceTargets: Array<CPElementRef?>?)\n+ : this(tree, CPNode.create(id, concept, parentId, roleInParent, childrenIds!!,\n+ propertyRoles as Array<String>, propertyValues as Array<String>,\n+ referenceRoles as Array<String>, referenceTargets as Array<CPElementRef>)) {}\noverride fun getData(): CPNode? {\nreturn super.getData() as CPNode?\n}\nfun getChildren(bulkQuery: IBulkQuery?): IBulkQuery.Value<Iterable<CLNode>?>? {\n- return (getTree() as CLTree).resolveElements(getData()!!.childrenIds, bulkQuery).map(Function<List<CLNode>, Iterable<CLNode>?> { elements: List<CLNode>? -> elements })\n+ return (getTree() as CLTree).resolveElements(getData()!!.getChildrenIds().toList(), bulkQuery).map(Function<List<CLNode>, Iterable<CLNode>?> { elements: List<CLNode>? -> elements })\n}\nfun getDescendants(bulkQuery: IBulkQuery, includeSelf: Boolean): IBulkQuery.Value<Iterable<CLNode>>? {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/main/kotlin/org/modelix/model/persistent/CPElement.kt", "new_path": "model-client/src/main/kotlin/org/modelix/model/persistent/CPElement.kt", "diff": "@@ -11,7 +11,7 @@ abstract class CPElement(val id: Long, val parentId: Long, val roleInParent: Str\ncompanion object {\n@JvmStatic\nopen fun deserialize(input: String?): CPElement {\n- return CPNode.deserialize(input)\n+ return CPNode.deserialize(input!!)\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/main/kotlin/org/modelix/model/persistent/CPNode.kt", "diff": "+package org.modelix.model.persistent\n+\n+import org.apache.commons.lang3.StringUtils\n+import org.apache.log4j.LogManager\n+import org.modelix.model.persistent.CPElementRef.Companion.fromString\n+import org.modelix.model.persistent.SerializationUtil.escape\n+import org.modelix.model.persistent.SerializationUtil.longFromHex\n+import org.modelix.model.persistent.SerializationUtil.longToHex\n+import org.modelix.model.persistent.SerializationUtil.unescape\n+import org.modelix.model.util.pmap.COWArrays.copy\n+import org.modelix.model.util.pmap.COWArrays.insert\n+import org.modelix.model.util.pmap.COWArrays.removeAt\n+import org.modelix.model.util.pmap.COWArrays.set\n+import java.util.*\n+import java.util.function.Function\n+import java.util.stream.Collectors\n+\n+class CPNode protected constructor(id1: Long, val concept: String?, parentId1: Long, roleInParent1: String?, private val childrenIds: LongArray, val propertyRoles: Array<String>, val propertyValues: Array<String>, val referenceRoles: Array<String>, val referenceTargets: Array<CPElementRef>) : CPElement(id1, parentId1, roleInParent1) {\n+ override fun serialize(): String? {\n+ val sb = StringBuilder()\n+ sb.append(longToHex(id))\n+ sb.append(\"/\")\n+ sb.append(escape(concept))\n+ sb.append(\"/\")\n+ sb.append(longToHex(parentId))\n+ sb.append(\"/\")\n+ sb.append(escape(roleInParent))\n+ sb.append(\"/\")\n+ sb.append(Arrays.stream(childrenIds).mapToObj<String> { obj: Long -> SerializationUtil.longToHex(obj) }.reduce { a: String, b: String -> \"$a, $b\" })\n+ sb.append(\"/\")\n+ var first = true\n+ run {\n+ val role_it = Arrays.stream(propertyRoles).iterator()\n+ val value_it = Arrays.stream(propertyValues).iterator()\n+ var role_var: String?\n+ var value_var: String?\n+ while (role_it.hasNext() && value_it.hasNext()) {\n+ role_var = role_it.next()\n+ value_var = value_it.next()\n+ if (first) {\n+ first = false\n+ } else {\n+ sb.append(\",\")\n+ }\n+ sb.append(escape(role_var)).append(\"=\").append(escape(value_var))\n+ }\n+ }\n+ sb.append(\"/\")\n+ first = true\n+ run {\n+ val role_it = Arrays.stream(referenceRoles).iterator()\n+ val value_it = Arrays.stream(referenceTargets).iterator()\n+ var role_var: String?\n+ var value_var: CPElementRef\n+ while (role_it.hasNext() && value_it.hasNext()) {\n+ role_var = role_it.next()\n+ value_var = value_it.next()\n+ if (first) {\n+ first = false\n+ } else {\n+ sb.append(\",\")\n+ }\n+ sb.append(escape(role_var)).append(\"=\").append(escape(value_var.toString()))\n+ }\n+ }\n+ return sb.toString()\n+ }\n+\n+ fun getChildrenIds(): Iterable<Long> {\n+ return Iterable { Arrays.stream(childrenIds).iterator() }\n+ }\n+\n+ val childrenIdArray: LongArray\n+ get() = copy(childrenIds)\n+\n+ val childrenSize: Int\n+ get() = childrenIds.size\n+\n+ fun getChildId(index: Int): Long {\n+ return childrenIds[index]\n+ }\n+\n+ fun getPropertyValue(role: String?): String? {\n+ val index = Arrays.binarySearch(propertyRoles, role)\n+ return if (index < 0) null else propertyValues[index]\n+ }\n+\n+ fun getReferenceTarget(role: String?): CPElementRef? {\n+ val index = Arrays.binarySearch(referenceRoles, role)\n+ return if (index < 0) null else referenceTargets[index]\n+ }\n+\n+ fun withPropertyValue(role: String, value: String?): CPNode {\n+ var index = Arrays.binarySearch(propertyRoles, role)\n+ return if (value == null) {\n+ if (index < 0) {\n+ this\n+ } else {\n+ create(id, concept, parentId, roleInParent, childrenIds, removeAt(propertyRoles, index), removeAt(propertyValues, index), referenceRoles, referenceTargets)\n+ }\n+ } else {\n+ if (index < 0) {\n+ index = -(index + 1)\n+ create(id, concept, parentId, roleInParent, childrenIds, insert(propertyRoles, index, role), insert(propertyValues, index, value), referenceRoles, referenceTargets)\n+ } else {\n+ create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, set(propertyValues, index, value), referenceRoles, referenceTargets)\n+ }\n+ }\n+ }\n+\n+ fun withReferenceTarget(role: String, target: CPElementRef?): CPNode {\n+ var index = Arrays.binarySearch(referenceRoles, role)\n+ return if (target == null) {\n+ if (index < 0) {\n+ this\n+ } else {\n+ create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, removeAt(referenceRoles, index), removeAt(referenceTargets, index))\n+ }\n+ } else {\n+ if (index < 0) {\n+ index = -(index + 1)\n+ create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, insert(referenceRoles, index, role), insert(referenceTargets, index, target))\n+ } else {\n+ create(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, referenceRoles, set(referenceTargets, index, target))\n+ }\n+ }\n+ }\n+\n+ companion object {\n+ private val LOG = LogManager.getLogger(CPNode::class.java)\n+ private val EMPTY_LONG_ARRAY = LongArray(0)\n+ val DESERIALIZER = Function { s: String -> deserialize(s) }\n+ @JvmStatic\n+ fun create(id: Long, concept: String?, parentId: Long, roleInParent: String?, childrenIds: LongArray, propertyRoles: Array<String>, propertyValues: Array<String>, referenceRoles: Array<String>, referenceTargets: Array<CPElementRef>): CPNode {\n+ checkForDuplicates(childrenIds)\n+ require(propertyRoles.size == propertyValues.size) { propertyRoles.size.toString() + \" != \" + propertyValues.size }\n+ require(referenceRoles.size == referenceTargets.size) { referenceRoles.size.toString() + \" != \" + referenceTargets.size }\n+ return CPNode(id, concept, parentId, roleInParent, childrenIds, propertyRoles, propertyValues, referenceRoles, referenceTargets)\n+ }\n+\n+ private fun checkForDuplicates(values: LongArray) {\n+ val copy = LongArray(values.size)\n+ System.arraycopy(values, 0, copy, 0, values.size)\n+ Arrays.sort(copy)\n+ for (i in 1 until copy.size) {\n+ if (copy[i - 1] == copy[i]) {\n+ throw RuntimeException(\"Duplicate value: \" + copy[i])\n+ }\n+ }\n+ }\n+\n+ @JvmStatic\n+ fun deserialize(input: String): CPNode {\n+ return try {\n+ val parts = input.split(\"/\").dropLastWhile { it.isEmpty() }.toTypedArray()\n+ val properties = Arrays.stream(parts[5].split(\",\").toTypedArray())\n+ .filter { cs: String? -> StringUtils.isNotEmpty(cs) }\n+ .map { it: String -> it.split(\"=\").dropLastWhile { it.isEmpty() }.toTypedArray() }\n+ .collect(Collectors.toList())\n+ val references = Arrays.stream(parts[6].split(\",\").toTypedArray())\n+ .filter { cs: String? -> StringUtils.isNotEmpty(cs) }\n+ .map { it: String -> it.split(\"=\").dropLastWhile { it.isEmpty() }.toTypedArray() }\n+ .collect(Collectors.toList())\n+ CPNode(\n+ longFromHex(parts[0]),\n+ unescape(parts[1]),\n+ longFromHex(parts[2]),\n+ unescape(parts[3]),\n+ Arrays.stream(parts[4].split(\",\").toTypedArray())\n+ .filter { cs: String? -> StringUtils.isNotEmpty(cs) }\n+ .mapToLong { obj: String -> SerializationUtil.longFromHex(obj) }\n+ .toArray(),\n+ properties.stream().map { it: Array<String> -> unescape(it[0])!! }.collect(Collectors.toList()).toTypedArray(),\n+ properties.stream().map { it: Array<String> -> unescape(it[1])!! }.collect(Collectors.toList()).toTypedArray(),\n+ references.stream().map { it: Array<String> -> unescape(it[0])!! }.collect(Collectors.toList()).toTypedArray(),\n+ references.stream()\n+ .map { it: Array<String> -> fromString(unescape(it[1])!!) }\n+ .collect(Collectors.toList()).toTypedArray()\n+ )\n+ } catch (ex: Exception) {\n+ throw RuntimeException(\"Failed to deserialize $input\", ex)\n+ }\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate CPNode
426,504
02.08.2020 10:14:27
-7,200
09e1afc58f070397b6bb1470bf53a15dae4956ed
translate TreeTestUtil
[ { "change_type": "DELETE", "old_path": "model-client/src/test/java/org/modelix/model/TreeTestUtil.java", "new_path": null, "diff": "-package org.modelix.model;\n-\n-import org.modelix.model.api.ITree;\n-\n-import java.util.Random;\n-import java.util.stream.LongStream;\n-import java.util.stream.Stream;\n-\n-public class TreeTestUtil {\n- private ITree tree;\n- private Random rand;\n-\n- public TreeTestUtil(ITree tree, Random rand) {\n- this.tree = tree;\n- this.rand = rand;\n- }\n-\n- public LongStream getAncestors(long descendant, boolean includeSelf) {\n- if (descendant == 0L) {\n- return LongStream.empty();\n- }\n- if (includeSelf) {\n- return LongStream.concat(LongStream.of(descendant), getAncestors(descendant, false));\n- } else {\n- long parent = tree.getParent(descendant);\n- return getAncestors(parent, true);\n- }\n- }\n-\n- public LongStream getAllNodes() {\n- return getDescendants(ITree.ROOT_ID, true);\n- }\n-\n- public LongStream getAllNodesWithoutRoot() {\n- return getDescendants(ITree.ROOT_ID, false);\n- }\n-\n- public LongStream getDescendants(long parent, boolean includeSelf) {\n- if (includeSelf) {\n- return LongStream.concat(LongStream.of(parent), getDescendants(parent, false));\n- } else {\n- return tree.getAllChildren(parent).flatMap(it -> getDescendants(it, true));\n- }\n- }\n-\n- public long getRandomNodeWithoutRoot() {\n- return getRandomNode(getAllNodesWithoutRoot().toArray());\n- }\n-\n- public long getRandomNodeWithRoot() {\n- return getRandomNode(getAllNodes().toArray());\n- }\n-\n- public long getRandomNode(long[] nodes) {\n- if (nodes.length == 0) {\n- return 0L;\n- }\n- return LongStream.of(nodes).skip(rand.nextInt(nodes.length)).findFirst().orElse(0L);\n- }\n-\n- public long getRandomLeafNode() {\n- return getRandomNode(getAllNodes().filter(it -> !tree.getAllChildren(it).iterator().hasNext()).toArray());\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/test/kotlin/org/modelix/model/TreeTestUtil.kt", "diff": "+package org.modelix.model\n+\n+import org.modelix.model.api.ITree\n+import java.util.*\n+import java.util.stream.LongStream\n+\n+class TreeTestUtil(private val tree: ITree, private val rand: Random) {\n+ fun getAncestors(descendant: Long, includeSelf: Boolean): LongStream {\n+ if (descendant == 0L) {\n+ return LongStream.empty()\n+ }\n+ return if (includeSelf) {\n+ LongStream.concat(LongStream.of(descendant), getAncestors(descendant, false))\n+ } else {\n+ val parent = tree.getParent(descendant)\n+ getAncestors(parent, true)\n+ }\n+ }\n+\n+ val allNodes: LongStream\n+ get() = getDescendants(ITree.ROOT_ID, true)\n+\n+ val allNodesWithoutRoot: LongStream\n+ get() = getDescendants(ITree.ROOT_ID, false)\n+\n+ fun getDescendants(parent: Long, includeSelf: Boolean): LongStream {\n+ return if (includeSelf) {\n+ LongStream.concat(LongStream.of(parent), getDescendants(parent, false))\n+ } else {\n+ tree.getAllChildren(parent)!!.flatMap { it: Long -> getDescendants(it, true) }\n+ }\n+ }\n+\n+ val randomNodeWithoutRoot: Long\n+ get() = getRandomNode(allNodesWithoutRoot.toArray())\n+\n+ val randomNodeWithRoot: Long\n+ get() = getRandomNode(allNodes.toArray())\n+\n+ fun getRandomNode(nodes: LongArray): Long {\n+ return if (nodes.size == 0) {\n+ 0L\n+ } else LongStream.of(*nodes).skip(rand.nextInt(nodes.size).toLong()).findFirst().orElse(0L)\n+ }\n+\n+ val randomLeafNode: Long\n+ get() = getRandomNode(allNodes.filter { it: Long -> !tree.getAllChildren(it)!!.iterator().hasNext() }.toArray())\n+\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate TreeTestUtil
426,504
02.08.2020 10:15:57
-7,200
278a43aee60a37105a607c8f0e0ecc5cb633ce06
translate tests to Kotlin
[ { "change_type": "DELETE", "old_path": "model-client/src/test/java/org/modelix/model/Hamt_Test.java", "new_path": null, "diff": "-package org.modelix.model;\n-\n-import org.junit.Assert;\n-import org.junit.Test;\n-import org.modelix.model.lazy.CLHamtInternal;\n-import org.modelix.model.lazy.CLHamtNode;\n-import org.modelix.model.lazy.ObjectStoreCache;\n-import org.modelix.model.persistent.MapBaseStore;\n-\n-import java.util.ArrayList;\n-import java.util.HashMap;\n-import java.util.List;\n-import java.util.Map;\n-import java.util.Random;\n-\n-public class Hamt_Test {\n- @Test\n- public void test_random() {\n- Random rand = new Random(1);\n-\n- Map<Long, String> expectedMap = new HashMap<>();\n- MapBaseStore store = new MapBaseStore();\n- ObjectStoreCache storeCache = new ObjectStoreCache(store);\n- CLHamtNode hamt = new CLHamtInternal(storeCache);\n-\n- for (int i = 0; i < 10000; i++) {\n- if (expectedMap.isEmpty() || rand.nextBoolean()) {\n- // add entry\n- long key = rand.nextInt(1000);\n- String value = Long.toString(rand.nextLong());\n- hamt = hamt.put(key, value);\n- expectedMap.put(key, value);\n-\n- } else {\n- List<Long> keys = new ArrayList<>(expectedMap.keySet());\n- long key = keys.get(rand.nextInt(keys.size()));\n- if (rand.nextBoolean()) {\n- // remove entry\n- hamt = hamt.remove(key);\n- expectedMap.remove(key);\n- } else {\n- // replace entry\n- String value = Long.toString(rand.nextLong());\n- hamt = hamt.put(key, value);\n- expectedMap.put(key, value);\n- }\n- }\n-\n- storeCache.clearCache();\n- for (var entry : expectedMap.entrySet()) {\n- Assert.assertEquals(entry.getValue(), hamt.get(entry.getKey()));\n- }\n- }\n-\n- }\n-}\n" }, { "change_type": "DELETE", "old_path": "model-client/src/test/java/org/modelix/model/Tree_Test.java", "new_path": null, "diff": "-package org.modelix.model;\n-\n-import io.vavr.Tuple;\n-import io.vavr.Tuple2;\n-import org.junit.Assert;\n-import org.junit.Before;\n-import org.junit.Test;\n-import org.modelix.model.api.ITree;\n-import org.modelix.model.api.PNodeReference;\n-import org.modelix.model.lazy.CLTree;\n-import org.modelix.model.lazy.ObjectStoreCache;\n-import org.modelix.model.persistent.MapBaseStore;\n-\n-import java.util.ArrayList;\n-import java.util.Arrays;\n-import java.util.HashMap;\n-import java.util.HashSet;\n-import java.util.List;\n-import java.util.Map;\n-import java.util.Objects;\n-import java.util.Random;\n-import java.util.Set;\n-\n-public class Tree_Test {\n- private boolean DEBUG = false;\n- private Map<Tuple2<Long, String>, List<Long>> expectedChildren;\n- @Test\n- public void test_random() throws Exception {\n-\n- List<String> roles = Arrays.asList(\"role1\", \"role2\", \"role3\");\n- Random rand = new Random(1906823);\n- long idSequence = 1000000L;\n-\n- MapBaseStore store = new MapBaseStore();\n- ObjectStoreCache storeCache = new ObjectStoreCache(store);\n- ITree tree = new CLTree(storeCache);\n-\n- Map<Long, Long> expectedParents = new HashMap<>();\n- Map<Long, String> expectedRoles = new HashMap<>();\n- Set<Long> expectedDeletes = new HashSet<>();\n-\n- for (int i = 0; i < 10000; i++) {\n- switch (rand.nextInt(5)) {\n- case 0:\n- // Delete node\n- {\n- long nodeToDelete = new TreeTestUtil(tree, rand).getRandomLeafNode();\n- if (nodeToDelete != 0L && nodeToDelete != ITree.ROOT_ID) {\n- if (DEBUG) {\n- System.out.println(\"Delete \" + nodeToDelete);\n- }\n- tree = tree.deleteNode(nodeToDelete);\n- removeChild(expectedParents.get(nodeToDelete), expectedRoles.get(nodeToDelete), nodeToDelete);\n- expectedParents.put(nodeToDelete, 0L);\n- expectedRoles.remove(nodeToDelete);\n- expectedDeletes.add(nodeToDelete);\n- }\n- }\n- break;\n- case 1:\n- // New node\n- {\n- long parent = new TreeTestUtil(tree, rand).getRandomNodeWithRoot();\n- if (parent != 0L) {\n- long childId = ++idSequence;\n- String role = roles.get(rand.nextInt(roles.size()));\n- int index = (rand.nextBoolean() ? rand.nextInt((int) tree.getChildren(parent, role).count() + 1) : -1);\n- if (DEBUG) {\n- System.out.println(\"AddNew \" + childId + \" to \" + parent + \".\" + role + \"[\" + index + \"]\");\n- }\n- tree = tree.addNewChild(parent, role, index, childId, null);\n- expectedParents.put(childId, parent);\n- expectedRoles.put(childId, role);\n- insertChild(parent, role, index, childId);\n- }\n- }\n- break;\n- case 2:\n- // Set property\n- {\n- long nodeId = new TreeTestUtil(tree, rand).getRandomNodeWithoutRoot();\n- if (nodeId != 0L) {\n- String role = roles.get(rand.nextInt(roles.size()));\n- String value = Long.toString(rand.nextLong());\n- if (DEBUG) {\n- System.out.println(\"SetProperty \" + nodeId + \".\" + role + \" = \" + value);\n- }\n- tree = tree.setProperty(nodeId, role, value);\n- }\n- }\n-\n- break;\n- case 3:\n- // Set reference\n- {\n- long sourceId = new TreeTestUtil(tree, rand).getRandomNodeWithoutRoot();\n- long targetId = new TreeTestUtil(tree, rand).getRandomNodeWithoutRoot();\n- if (sourceId != 0L && targetId != 0L) {\n- String role = roles.get(rand.nextInt(roles.size()));\n- if (DEBUG) {\n- System.out.println(\"SetReference \" + sourceId + \".\" + role + \" = \" + targetId);\n- }\n- tree = tree.setReferenceTarget(sourceId, role, new PNodeReference(targetId));\n- }\n- }\n- break;\n- case 4:\n- // Move node\n- {\n- final TreeTestUtil util = new TreeTestUtil(tree, rand);\n- final long childId = util.getRandomNodeWithoutRoot();\n- long parent = util.getRandomNode(util\n- .getAllNodes()\n- .filter(it -> util.getAncestors(it, true).noneMatch(it2 -> it2 == childId))\n- .toArray());\n- if (childId != 0L && parent != 0L) {\n- String role = roles.get(rand.nextInt(roles.size()));\n- int index = (rand.nextBoolean() ? rand.nextInt((int) tree.getChildren(parent, role).count() + 1) : -1);\n- if (DEBUG) {\n- System.out.println(\"MoveNode \" + childId + \" to \" + parent + \".\" + role + \"[\" + index + \"]\");\n- }\n- tree = tree.moveChild(parent, role, index, childId);\n- long oldParent = expectedParents.get(childId);\n- String oldRole = expectedRoles.get(childId);\n- if (Objects.equals(oldParent, parent) && Objects.equals(oldRole, role)) {\n- int oldIndex = expectedChildren.get(Tuple.of(oldParent, oldRole)).indexOf(childId);\n- if (oldIndex < index) {\n- index--;\n- }\n- }\n- removeChild(oldParent, oldRole, childId);\n- expectedParents.put(childId, parent);\n- expectedRoles.put(childId, role);\n- insertChild(parent, role, index, childId);\n- }\n- }\n- break;\n- }\n-\n- for (var entry : expectedParents.entrySet()) {\n- if (Objects.equals(entry.getValue(), 0L)) {\n- Assert.assertFalse(tree.containsNode(entry.getKey()));\n- } else {\n- long expectedParent = entry.getValue();\n- long actualParent = tree.getParent(entry.getKey());\n- Assert.assertEquals(expectedParent, actualParent);\n- }\n- }\n-\n- for (var entry : expectedChildren.entrySet()) {\n- if (expectedDeletes.contains((long) entry.getKey()._1())) {\n- continue;\n- }\n- long[] expected = entry.getValue().stream().mapToLong(it -> it).toArray();\n- long[] actual = tree.getChildren((long) entry.getKey()._1(), entry.getKey()._2()).toArray();\n- Assert.assertArrayEquals(expected, actual);\n- }\n-\n- for (var entry : expectedRoles.entrySet()) {\n- Assert.assertEquals(entry.getValue(), tree.getRole(entry.getKey()));\n- }\n-\n- for (long node : expectedDeletes) {\n- Assert.assertFalse(tree.containsNode(node));\n- }\n- }\n-\n- }\n- @Before\n- public void setUp() {\n- expectedChildren = new HashMap<>();\n- }\n- public void insertChild(long parent, String role, int index, long child) {\n- List<Long> list = expectedChildren.computeIfAbsent(Tuple.of(parent, role), k -> new ArrayList<>());\n- if (index == -1) {\n- list.add(child);\n- } else {\n- list.add(index, child);\n- }\n- }\n- public void removeChild(long parent, String role, long child) {\n- List<Long> list = expectedChildren.computeIfAbsent(Tuple.of(parent, role), k -> new ArrayList<>());\n- list.remove(child);\n- }\n-}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/test/kotlin/org/modelix/model/Hamt_Test.kt", "diff": "+package org.modelix.model\n+\n+import org.junit.Assert\n+import org.junit.Test\n+import org.modelix.model.lazy.CLHamtInternal\n+import org.modelix.model.lazy.CLHamtNode\n+import org.modelix.model.lazy.ObjectStoreCache\n+import org.modelix.model.persistent.MapBaseStore\n+import java.util.*\n+\n+class Hamt_Test {\n+ @Test\n+ fun test_random() {\n+ val rand = Random(1)\n+ val expectedMap: MutableMap<Long, String> = HashMap()\n+ val store = MapBaseStore()\n+ val storeCache = ObjectStoreCache(store)\n+ var hamt: CLHamtNode<*>? = CLHamtInternal(storeCache)\n+ for (i in 0..9999) {\n+ if (expectedMap.isEmpty() || rand.nextBoolean()) {\n+ // add entry\n+ val key = rand.nextInt(1000).toLong()\n+ val value = java.lang.Long.toString(rand.nextLong())\n+ hamt = hamt!!.put(key, value)\n+ expectedMap[key] = value\n+ } else {\n+ val keys: List<Long> = ArrayList(expectedMap.keys)\n+ val key = keys[rand.nextInt(keys.size)]\n+ if (rand.nextBoolean()) {\n+ // remove entry\n+ hamt = hamt!!.remove(key)\n+ expectedMap.remove(key)\n+ } else {\n+ // replace entry\n+ val value = java.lang.Long.toString(rand.nextLong())\n+ hamt = hamt!!.put(key, value)\n+ expectedMap[key] = value\n+ }\n+ }\n+ storeCache.clearCache()\n+ for ((key, value) in expectedMap) {\n+ Assert.assertEquals(value, hamt!![key])\n+ }\n+ }\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/test/kotlin/org/modelix/model/Tree_Test.kt", "diff": "+package org.modelix.model\n+\n+import io.vavr.Tuple\n+import io.vavr.Tuple2\n+import org.junit.Assert\n+import org.junit.Before\n+import org.junit.Test\n+import org.modelix.model.api.ITree\n+import org.modelix.model.api.PNodeReference\n+import org.modelix.model.lazy.CLTree\n+import org.modelix.model.lazy.ObjectStoreCache\n+import org.modelix.model.persistent.MapBaseStore\n+import java.util.*\n+\n+class Tree_Test {\n+ private val DEBUG = false\n+ private var expectedChildren: MutableMap<Tuple2<Long, String?>, MutableList<Long?>>? = null\n+\n+ @Test\n+ @Throws(Exception::class)\n+ fun test_random() {\n+ val roles = Arrays.asList(\"role1\", \"role2\", \"role3\")\n+ val rand = Random(1906823)\n+ var idSequence = 1000000L\n+ val store = MapBaseStore()\n+ val storeCache = ObjectStoreCache(store)\n+ var tree: ITree? = CLTree(storeCache)\n+ val expectedParents: MutableMap<Long, Long> = HashMap()\n+ val expectedRoles: MutableMap<Long, String> = HashMap()\n+ val expectedDeletes: MutableSet<Long> = HashSet()\n+ for (i in 0..9999) {\n+ when (rand.nextInt(5)) {\n+ 0 -> // Delete node\n+ {\n+ val nodeToDelete = TreeTestUtil(tree!!, rand).randomLeafNode\n+ if (nodeToDelete != 0L && nodeToDelete != ITree.ROOT_ID) {\n+ if (DEBUG) {\n+ println(\"Delete $nodeToDelete\")\n+ }\n+ tree = tree.deleteNode(nodeToDelete)\n+ removeChild(expectedParents[nodeToDelete]!!, expectedRoles[nodeToDelete], nodeToDelete)\n+ expectedParents[nodeToDelete] = 0L\n+ expectedRoles.remove(nodeToDelete)\n+ expectedDeletes.add(nodeToDelete)\n+ }\n+ }\n+ 1 -> // New node\n+ {\n+ val parent = TreeTestUtil(tree!!, rand).randomNodeWithRoot\n+ if (parent != 0L) {\n+ val childId = ++idSequence\n+ val role = roles[rand.nextInt(roles.size)]\n+ val index = if (rand.nextBoolean()) rand.nextInt(tree.getChildren(parent, role)!!.count().toInt() + 1) else -1\n+ if (DEBUG) {\n+ println(\"AddNew $childId to $parent.$role[$index]\")\n+ }\n+ tree = tree.addNewChild(parent, role, index, childId, null)\n+ expectedParents[childId] = parent\n+ expectedRoles[childId] = role\n+ insertChild(parent, role, index, childId)\n+ }\n+ }\n+ 2 -> // Set property\n+ {\n+ val nodeId = TreeTestUtil(tree!!, rand).randomNodeWithoutRoot\n+ if (nodeId != 0L) {\n+ val role = roles[rand.nextInt(roles.size)]\n+ val value = java.lang.Long.toString(rand.nextLong())\n+ if (DEBUG) {\n+ println(\"SetProperty $nodeId.$role = $value\")\n+ }\n+ tree = tree.setProperty(nodeId, role, value)\n+ }\n+ }\n+ 3 -> // Set reference\n+ {\n+ val sourceId = TreeTestUtil(tree!!, rand).randomNodeWithoutRoot\n+ val targetId = TreeTestUtil(tree, rand).randomNodeWithoutRoot\n+ if (sourceId != 0L && targetId != 0L) {\n+ val role = roles[rand.nextInt(roles.size)]\n+ if (DEBUG) {\n+ println(\"SetReference $sourceId.$role = $targetId\")\n+ }\n+ tree = tree.setReferenceTarget(sourceId, role, PNodeReference(targetId))\n+ }\n+ }\n+ 4 -> // Move node\n+ {\n+ val util = TreeTestUtil(tree!!, rand)\n+ val childId = util.randomNodeWithoutRoot\n+ val parent = util.getRandomNode(util\n+ .allNodes\n+ .filter { it: Long -> util.getAncestors(it, true).noneMatch { it2: Long -> it2 == childId } }\n+ .toArray())\n+ if (childId != 0L && parent != 0L) {\n+ val role = roles[rand.nextInt(roles.size)]\n+ var index = if (rand.nextBoolean()) rand.nextInt(tree.getChildren(parent, role)!!.count().toInt() + 1) else -1\n+ if (DEBUG) {\n+ println(\"MoveNode $childId to $parent.$role[$index]\")\n+ }\n+ tree = tree.moveChild(parent, role, index, childId)\n+ val oldParent = expectedParents[childId]!!\n+ val oldRole = expectedRoles[childId]\n+ if (oldParent == parent && oldRole == role) {\n+ val oldIndex = expectedChildren!![Tuple.of(oldParent, oldRole)]!!.indexOf(childId)\n+ if (oldIndex < index) {\n+ index--\n+ }\n+ }\n+ removeChild(oldParent, oldRole, childId)\n+ expectedParents[childId] = parent\n+ expectedRoles[childId] = role\n+ insertChild(parent, role, index, childId)\n+ }\n+ }\n+ }\n+ for ((key, expectedParent) in expectedParents) {\n+ if (expectedParent == 0L) {\n+ Assert.assertFalse(tree!!.containsNode(key))\n+ } else {\n+ val actualParent = tree!!.getParent(key)\n+ Assert.assertEquals(expectedParent, actualParent)\n+ }\n+ }\n+ for ((key, value) in expectedChildren!!) {\n+ if (expectedDeletes.contains(key._1() as Long)) {\n+ continue\n+ }\n+ val expected = value.stream().mapToLong { it: Long? -> it!! }.toArray()\n+ val actual = tree!!.getChildren(key._1() as Long, key._2())!!.toArray()\n+ Assert.assertArrayEquals(expected, actual)\n+ }\n+ for ((key, value) in expectedRoles) {\n+ Assert.assertEquals(value, tree!!.getRole(key))\n+ }\n+ for (node in expectedDeletes) {\n+ Assert.assertFalse(tree!!.containsNode(node))\n+ }\n+ }\n+ }\n+\n+ @Before\n+ fun setUp() {\n+ expectedChildren = HashMap()\n+ }\n+\n+ fun insertChild(parent: Long, role: String?, index: Int, child: Long) {\n+ val list = expectedChildren!!.computeIfAbsent(Tuple.of(parent, role)) { k: Tuple2<Long, String?>? -> ArrayList() }\n+ if (index == -1) {\n+ list.add(child)\n+ } else {\n+ list.add(index, child)\n+ }\n+ }\n+\n+ fun removeChild(parent: Long, role: String?, child: Long) {\n+ val list = expectedChildren!!.computeIfAbsent(Tuple.of(parent, role)) { k: Tuple2<Long, String?>? -> ArrayList() }\n+ list.remove(child)\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
translate tests to Kotlin
426,504
02.08.2020 10:18:58
-7,200
fd01dd2f1fab9cf7c55d5129a29f235491bc51c8
add github actions for modelclient
[ { "change_type": "ADD", "old_path": null, "new_path": ".github/workflows/modelclient.yml", "diff": "+name: ModelClient_BuildAndTest\n+\n+on: [push]\n+\n+jobs:\n+ build:\n+\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - uses: actions/checkout@v1\n+ - name: Set up JDK 1.8\n+ uses: actions/setup-java@v1\n+ with:\n+ java-version: 1.8\n+ - name: Run tests for model client\n+ run: ./gradlew check\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add github actions for modelclient
426,504
02.08.2020 10:23:35
-7,200
5ae3fc4bd410966a9a79df731bf71f32327ae791
move to JDK 11
[ { "change_type": "MODIFY", "old_path": ".github/workflows/modelclient.yml", "new_path": ".github/workflows/modelclient.yml", "diff": "@@ -12,6 +12,6 @@ jobs:\n- name: Set up JDK 1.8\nuses: actions/setup-java@v1\nwith:\n- java-version: 1.8\n+ java-version: 11\n- name: Run tests for model client\nrun: cd model-client && ./gradlew check\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
move to JDK 11
426,496
05.08.2020 10:04:12
-7,200
83ae72cfae66545375a5c396dd2238006749eaeb
Run MPS tests
[ { "change_type": "MODIFY", "old_path": "build.gradle", "new_path": "build.gradle", "diff": "@@ -148,7 +148,7 @@ assemble.dependsOn(buildMpsModules)\ntask runMpsTests(type: TestLanguages, dependsOn: buildMpsModules) {\nscriptArgs = defaultAntScriptArgs\nscriptClasspath = buildScriptClasspath\n- script new File(\"$projectDir/build-tests.xml\")\n+ script new File(\"$rootDir/build/test.org.modelix/build-tests.xml\")\n}\nspotless {\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.build/models/org.modelix.build.mps", "new_path": "mps/org.modelix.build/models/org.modelix.build.mps", "diff": "<use id=\"798100da-4f0a-421a-b991-71f8c50ce5d2\" name=\"jetbrains.mps.build\" version=\"0\" />\n<use id=\"0cf935df-4699-4e9c-a132-fa109541cba3\" name=\"jetbrains.mps.build.mps\" version=\"7\" />\n<use id=\"692446e8-74c9-4c9a-86dd-9828438db54b\" name=\"org.modelix.buildhacks\" version=\"0\" />\n+ <use id=\"3600cb0a-44dd-4a5b-9968-22924406419e\" name=\"jetbrains.mps.build.mps.tests\" version=\"1\" />\n</languages>\n<imports>\n<import index=\"ffeo\" ref=\"r:874d959d-e3b4-4d04-b931-ca849af130dd(jetbrains.mps.ide.build)\" />\n<import index=\"90a9\" ref=\"r:fb24ac52-5985-4947-bba9-25be6fd32c1a(de.itemis.mps.extensions.build)\" />\n</imports>\n<registry>\n+ <language id=\"3600cb0a-44dd-4a5b-9968-22924406419e\" name=\"jetbrains.mps.build.mps.tests\">\n+ <concept id=\"4560297596904469357\" name=\"jetbrains.mps.build.mps.tests.structure.BuildMpsLayout_TestModules\" flags=\"nn\" index=\"22LTRH\">\n+ <child id=\"4560297596904469360\" name=\"modules\" index=\"22LTRK\" />\n+ <child id=\"6593674873639474544\" name=\"options\" index=\"24cAkG\" />\n+ </concept>\n+ <concept id=\"4560297596904469362\" name=\"jetbrains.mps.build.mps.tests.structure.BuildMpsLayout_TestModule\" flags=\"nn\" index=\"22LTRM\">\n+ <reference id=\"4560297596904469363\" name=\"module\" index=\"22LTRN\" />\n+ </concept>\n+ <concept id=\"6593674873639474400\" name=\"jetbrains.mps.build.mps.tests.structure.BuildMpsLayout_TestModules_Options\" flags=\"ng\" index=\"24cAiW\" />\n+ <concept id=\"4005526075820600484\" name=\"jetbrains.mps.build.mps.tests.structure.BuildModuleTestsPlugin\" flags=\"ng\" index=\"1gjT0q\" />\n+ </language>\n<language id=\"798100da-4f0a-421a-b991-71f8c50ce5d2\" name=\"jetbrains.mps.build\">\n<concept id=\"5481553824944787378\" name=\"jetbrains.mps.build.structure.BuildSourceProjectRelativePath\" flags=\"ng\" index=\"55IIr\" />\n<concept id=\"7321017245476976379\" name=\"jetbrains.mps.build.structure.BuildRelativePath\" flags=\"ng\" index=\"iG8Mu\">\n</concept>\n<concept id=\"5617550519002745364\" name=\"jetbrains.mps.build.structure.BuildLayout\" flags=\"ng\" index=\"1l3spV\" />\n<concept id=\"5617550519002745363\" name=\"jetbrains.mps.build.structure.BuildProject\" flags=\"ng\" index=\"1l3spW\">\n+ <property id=\"4915877860348071612\" name=\"fileName\" index=\"turDy\" />\n<property id=\"5204048710541015587\" name=\"internalBaseDirectory\" index=\"2DA0ip\" />\n+ <child id=\"4796668409958418110\" name=\"scriptsDir\" index=\"auvoZ\" />\n<child id=\"6647099934206700656\" name=\"plugins\" index=\"10PD9s\" />\n<child id=\"7389400916848080626\" name=\"parts\" index=\"3989C9\" />\n<child id=\"3542413272732620719\" name=\"aspects\" index=\"1hWBAP\" />\n<ref role=\"3bR37D\" node=\"7gF2HTviNPn\" resolve=\"org.modelix.ui.sm\" />\n</node>\n</node>\n- <node concept=\"1SiIV0\" id=\"4tfK3zZNTuT\" role=\"3bR37C\">\n- <node concept=\"1BurEX\" id=\"4tfK3zZNTuU\" role=\"1SiIV1\">\n- <node concept=\"398BVA\" id=\"4tfK3zZNTuK\" role=\"1BurEY\">\n- <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n- <node concept=\"2Ry0Ak\" id=\"4tfK3zZNTuL\" role=\"iGT6I\">\n- <property role=\"2Ry0Am\" value=\"org.modelix.ui.server\" />\n- <node concept=\"2Ry0Ak\" id=\"4tfK3zZNTuM\" role=\"2Ry0An\">\n- <property role=\"2Ry0Am\" value=\"lib\" />\n- <node concept=\"2Ry0Ak\" id=\"4tfK3zZNTuN\" role=\"2Ry0An\">\n- <property role=\"2Ry0Am\" value=\"ui-client.jar\" />\n- </node>\n- </node>\n- </node>\n- </node>\n- </node>\n- </node>\n<node concept=\"1SiIV0\" id=\"4cICdlebXxQ\" role=\"3bR37C\">\n<node concept=\"3bR9La\" id=\"4cICdlebXxR\" role=\"1SiIV1\">\n<ref role=\"3bR37D\" node=\"7gF2HTviNPK\" resolve=\"org.modelix.model\" />\n<ref role=\"3bR37D\" node=\"27MnIrahxUD\" resolve=\"org.modelix.ui.diff\" />\n</node>\n</node>\n+ <node concept=\"1SiIV0\" id=\"1yReInD1fW\" role=\"3bR37C\">\n+ <node concept=\"1BurEX\" id=\"1yReInD1fX\" role=\"1SiIV1\">\n+ <node concept=\"398BVA\" id=\"1yReInD1fN\" role=\"1BurEY\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD1fO\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.ui.server\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD1fP\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"lib\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD1fQ\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"ui-client-2020.1-SNAPSHOT.jar\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"1E1JtA\" id=\"27MnIrahxUD\" role=\"2G$12L\">\n<property role=\"BnDLt\" value=\"true\" />\n<node concept=\"3LEDTy\" id=\"7BujJjYSJ9v\" role=\"3LEDUa\">\n<ref role=\"3LEDTV\" node=\"7gF2HTviNPn\" resolve=\"org.modelix.ui.sm\" />\n</node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYd\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KYb\" resolve=\"jetbrains.mps.baseLanguage\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYe\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L0h\" resolve=\"jetbrains.mps.baseLanguage.collections\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYf\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZ0\" resolve=\"jetbrains.mps.baseLanguageInternal\" />\n+ <node concept=\"3LEDTy\" id=\"1yReInD1ms\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZc\" resolve=\"jetbrains.mps.baseLanguage.checkedDots\" />\n</node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYg\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:2$QnGbtLXzL\" resolve=\"de.q60.mps.shadowmodels.gen.desugar\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYh\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:4iIKqJTZ5Hs\" resolve=\"de.q60.mps.polymorphicfunctions\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYi\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L4j\" resolve=\"jetbrains.mps.lang.actions\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYj\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:4iIKqJTZ5HO\" resolve=\"de.q60.mps.shadowmodels.transformation\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYk\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZG\" resolve=\"jetbrains.mps.baseLanguage.closures\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYl\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:7c10t$7lQIA\" resolve=\"de.q60.mps.shadowmodels.gen.typesystem\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYm\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L9O\" resolve=\"jetbrains.mps.lang.smodel\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYn\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:4iIKqJTZ5Hg\" resolve=\"de.q60.mps.shadowmodels.gen.afterPF\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYo\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:14x5$qAUbkb\" resolve=\"jetbrains.mps.lang.access\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYp\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L2F\" resolve=\"jetbrains.mps.baseLanguage.tuples\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"JSgV4jSLYq\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L2l\" resolve=\"jetbrains.mps.baseLanguage.logging\" />\n+ <node concept=\"3LEDTy\" id=\"1yReInD1mt\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L9c\" resolve=\"jetbrains.mps.lang.quotation\" />\n</node>\n</node>\n<node concept=\"1E1JtD\" id=\"7BujJjXYVmv\" role=\"2G$12L\">\n<property role=\"3UIfUI\" value=\"1024\" />\n</node>\n</node>\n+ <node concept=\"1l3spW\" id=\"1yReInD20V\">\n+ <property role=\"2DA0ip\" value=\"../../build/test.org.modelix\" />\n+ <property role=\"TrG5h\" value=\"test.org.modelix\" />\n+ <property role=\"turDy\" value=\"build-tests.xml\" />\n+ <node concept=\"2_Ic$z\" id=\"1yReInD222\" role=\"3989C9\">\n+ <property role=\"2_Ic$$\" value=\"true\" />\n+ </node>\n+ <node concept=\"1wNqPr\" id=\"1yReInD228\" role=\"3989C9\" />\n+ <node concept=\"2sgV4H\" id=\"1yReInD21N\" role=\"1l3spa\">\n+ <ref role=\"1l3spb\" to=\"ffeo:3IKDaVZmzS6\" resolve=\"mps\" />\n+ <node concept=\"398BVA\" id=\"1yReInD2if\" role=\"2JcizS\">\n+ <ref role=\"398BVh\" node=\"1yReInD212\" resolve=\"mps.home\" />\n+ </node>\n+ </node>\n+ <node concept=\"2sgV4H\" id=\"1yReInD21T\" role=\"1l3spa\">\n+ <ref role=\"1l3spb\" to=\"ffeo:ymnOULAEsd\" resolve=\"mpsTesting\" />\n+ <node concept=\"398BVA\" id=\"1yReInD2ih\" role=\"2JcizS\">\n+ <ref role=\"398BVh\" node=\"1yReInD212\" resolve=\"mps.home\" />\n+ </node>\n+ </node>\n+ <node concept=\"2sgV4H\" id=\"1yReInD22L\" role=\"1l3spa\">\n+ <ref role=\"1l3spb\" node=\"7gF2HTviNP8\" resolve=\"org.modelix\" />\n+ <node concept=\"398BVA\" id=\"1yReInD6Av\" role=\"2JcizS\">\n+ <ref role=\"398BVh\" node=\"1yReInD21e\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD6A_\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"..\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD6AE\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"build\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD6AJ\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD7r0\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"build\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD7r5\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"artifacts\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD8fo\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"2sgV4H\" id=\"1yReInD9a_\" role=\"1l3spa\">\n+ <ref role=\"1l3spb\" to=\"90a9:2Xjt3l56m0V\" resolve=\"de.itemis.mps.extensions\" />\n+ <node concept=\"398BVA\" id=\"1yReInD9aA\" role=\"2JcizS\">\n+ <ref role=\"398BVh\" node=\"1yReInD21b\" resolve=\"extensions.artifacts\" />\n+ </node>\n+ </node>\n+ <node concept=\"398rNT\" id=\"1yReInD20Y\" role=\"1l3spd\">\n+ <property role=\"TrG5h\" value=\"modelix.home\" />\n+ <node concept=\"55IIr\" id=\"1yReInD20Z\" role=\"398pKh\">\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD210\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"..\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD211\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"..\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"398rNT\" id=\"1yReInD212\" role=\"1l3spd\">\n+ <property role=\"TrG5h\" value=\"mps.home\" />\n+ <node concept=\"398BVA\" id=\"1yReInD213\" role=\"398pKh\">\n+ <ref role=\"398BVh\" node=\"1yReInD20Y\" resolve=\"modelix.home\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD214\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"artifacts\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD215\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"mps\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"398rNT\" id=\"1yReInD216\" role=\"1l3spd\">\n+ <property role=\"TrG5h\" value=\"mps_home\" />\n+ <node concept=\"398BVA\" id=\"1yReInD217\" role=\"398pKh\">\n+ <ref role=\"398BVh\" node=\"1yReInD212\" resolve=\"mps.home\" />\n+ </node>\n+ </node>\n+ <node concept=\"398rNT\" id=\"1yReInD218\" role=\"1l3spd\">\n+ <property role=\"TrG5h\" value=\"artifacts.root\" />\n+ <node concept=\"398BVA\" id=\"1yReInD219\" role=\"398pKh\">\n+ <ref role=\"398BVh\" node=\"1yReInD20Y\" resolve=\"modelix.home\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD21a\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"artifacts\" />\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"398rNT\" id=\"1yReInD21b\" role=\"1l3spd\">\n+ <property role=\"TrG5h\" value=\"extensions.artifacts\" />\n+ <node concept=\"398BVA\" id=\"1yReInD21c\" role=\"398pKh\">\n+ <ref role=\"398BVh\" node=\"1yReInD218\" resolve=\"artifacts.root\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD21d\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"de.itemis.mps.extensions\" />\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"398rNT\" id=\"1yReInD21e\" role=\"1l3spd\">\n+ <property role=\"TrG5h\" value=\"modelix.modules\" />\n+ <node concept=\"398BVA\" id=\"1yReInD21f\" role=\"398pKh\">\n+ <ref role=\"398BVh\" node=\"1yReInD20Y\" resolve=\"modelix.home\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInD21g\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"mps\" />\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"55IIr\" id=\"1yReInD20W\" role=\"auvoZ\" />\n+ <node concept=\"1l3spV\" id=\"1yReInD20X\" role=\"1l3spN\" />\n+ <node concept=\"10PD9b\" id=\"1yReInD21$\" role=\"10PD9s\" />\n+ <node concept=\"3b7kt6\" id=\"1yReInD21D\" role=\"10PD9s\" />\n+ <node concept=\"1gjT0q\" id=\"6$6tsX_CKLI\" role=\"10PD9s\" />\n+ <node concept=\"22LTRH\" id=\"1yReInD22F\" role=\"1hWBAP\">\n+ <property role=\"TrG5h\" value=\"all\" />\n+ <node concept=\"22LTRM\" id=\"1yReInD22Q\" role=\"22LTRK\">\n+ <ref role=\"22LTRN\" node=\"7gF2HTviNPs\" resolve=\"org.modelix.model.mpsplugin\" />\n+ </node>\n+ <node concept=\"22LTRM\" id=\"1yReInD2ib\" role=\"22LTRK\">\n+ <ref role=\"22LTRN\" node=\"5npwda7lJQ3\" resolve=\"org.modelix.ui.common\" />\n+ </node>\n+ <node concept=\"24cAiW\" id=\"1yReInEzbz\" role=\"24cAkG\" />\n+ </node>\n+ </node>\n</model>\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.build/org.modelix.build.msd", "new_path": "mps/org.modelix.build/org.modelix.build.msd", "diff": "<languageVersions>\n<language slang=\"l:798100da-4f0a-421a-b991-71f8c50ce5d2:jetbrains.mps.build\" version=\"0\" />\n<language slang=\"l:0cf935df-4699-4e9c-a132-fa109541cba3:jetbrains.mps.build.mps\" version=\"7\" />\n+ <language slang=\"l:3600cb0a-44dd-4a5b-9968-22924406419e:jetbrains.mps.build.mps.tests\" version=\"1\" />\n<language slang=\"l:ceab5195-25ea-4f22-9b92-103b95ca8c0c:jetbrains.mps.lang.core\" version=\"2\" />\n<language slang=\"l:692446e8-74c9-4c9a-86dd-9828438db54b:org.modelix.buildhacks\" version=\"0\" />\n</languageVersions>\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.server/org.modelix.ui.server.msd", "new_path": "mps/org.modelix.ui.server/org.modelix.ui.server.msd", "diff": "<modelRoot contentPath=\"${module}\" type=\"default\">\n<sourceRoot location=\"models\" />\n</modelRoot>\n+ <modelRoot contentPath=\"${module}/lib\" type=\"java_classes\">\n+ <sourceRoot location=\"ui-client-2020.1-SNAPSHOT.jar\" />\n+ </modelRoot>\n</models>\n<facets>\n- <facet type=\"java\">\n+ <facet type=\"java\" languageLevel=\"JAVA_8\">\n<classes generated=\"true\" path=\"${module}/classes_gen\" />\n</facet>\n</facets>\n<stubModelEntries>\n- <stubModelEntry path=\"${module}/lib/ui-client.jar\" />\n+ <stubModelEntry path=\"${module}/lib/ui-client-2020.1-SNAPSHOT.jar\" />\n</stubModelEntries>\n<sourcePath />\n<dependencies>\n<module reference=\"fc3c2aa8-0d4b-463f-a774-40d450aa04a0(org.modelix.jetty)\" version=\"0\" />\n<module reference=\"87f4b21e-a3a5-459e-a54b-408fd9eb7350(org.modelix.lib)\" version=\"0\" />\n<module reference=\"5622e615-959d-4843-9df6-ef04ee578c18(org.modelix.model)\" version=\"0\" />\n+ <module reference=\"0a2651ab-f212-45c2-a2f0-343e76cbc26b(org.modelix.model.client)\" version=\"0\" />\n<module reference=\"c5e5433e-201f-43e2-ad14-a6cba8c80cd6(org.modelix.model.mpsplugin)\" version=\"0\" />\n<module reference=\"25f5c7b1-6312-4074-a012-654b813b8083(org.modelix.ui.diff)\" version=\"0\" />\n<module reference=\"39aab22b-473f-4e44-b037-0c602964897d(org.modelix.ui.server)\" version=\"0\" />\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Run MPS tests
426,496
05.08.2020 12:07:34
-7,200
fd19870f5e083deffad05b990ca79e55502f513a
Kotlin multiplatform project for the model-client (2)
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.model.client/org.modelix.model.client.msd", "new_path": "mps/org.modelix.model.client/org.modelix.model.client.msd", "diff": "<sourceRoot location=\"models\" />\n</modelRoot>\n<modelRoot contentPath=\"${module}/lib\" type=\"java_classes\">\n- <sourceRoot location=\"annotations-19.0.0.jar\" />\n<sourceRoot location=\"kotlin-stdlib-1.3.72.jar\" />\n<sourceRoot location=\"kotlin-stdlib-common-1.3.72.jar\" />\n<sourceRoot location=\"jersey-client-2.31.jar\" />\n<sourceRoot location=\"jersey-media-sse-2.31.jar\" />\n<sourceRoot location=\"jersey-server-2.31.jar\" />\n<sourceRoot location=\"model-client-2020.1-SNAPSHOT.jar\" />\n+ <sourceRoot location=\"model-client-jvm-2020.1-SNAPSHOT.jar\" />\n</modelRoot>\n</models>\n<facets>\n</facet>\n</facets>\n<stubModelEntries>\n- <stubModelEntry path=\"${module}/lib/annotations-19.0.0.jar\" />\n<stubModelEntry path=\"${module}/lib/aopalliance-repackaged-2.6.1.jar\" />\n<stubModelEntry path=\"${module}/lib/checker-qual-2.11.1.jar\" />\n<stubModelEntry path=\"${module}/lib/commons-collections4-4.4.jar\" />\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Kotlin multiplatform project for the model-client (2)
426,496
05.08.2020 12:26:35
-7,200
6a6f9173d10b1126d755372ba174ef3ce1e4bb93
Kotlin multiplatform project for the model-client (3)
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.build/models/org.modelix.build.mps", "new_path": "mps/org.modelix.build/models/org.modelix.build.mps", "diff": "<ref role=\"3bR37D\" to=\"ffeo:1TaHNgiIbIZ\" resolve=\"MPS.Editor\" />\n</node>\n</node>\n+ <node concept=\"3rtmxn\" id=\"1yReInH2Rk\" role=\"3bR31x\">\n+ <node concept=\"3LXTmp\" id=\"1yReInH2Rl\" role=\"3rtmxm\">\n+ <node concept=\"398BVA\" id=\"1yReInH2Rm\" role=\"3LXTmr\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInH2Rn\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.ui.sm\" />\n+ </node>\n+ </node>\n+ <node concept=\"3qWCbU\" id=\"1yReInH2Rp\" role=\"3LXTna\">\n+ <property role=\"3qWCbO\" value=\"icons/**, resources/**\" />\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"1E1JtD\" id=\"7gF2HTviNPx\" role=\"2G$12L\">\n<property role=\"BnDLt\" value=\"true\" />\n</node>\n</node>\n</node>\n+ <node concept=\"3rtmxn\" id=\"1yReInH3aX\" role=\"3bR31x\">\n+ <node concept=\"3LXTmp\" id=\"1yReInH3aY\" role=\"3rtmxm\">\n+ <node concept=\"398BVA\" id=\"1yReInH3aZ\" role=\"3LXTmr\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInH3b0\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.ui.sm.json\" />\n+ </node>\n+ </node>\n+ <node concept=\"3qWCbU\" id=\"1yReInH3b2\" role=\"3LXTna\">\n+ <property role=\"3qWCbO\" value=\"icons/**, resources/**\" />\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"1E1JtD\" id=\"7gF2HTviNPF\" role=\"2G$12L\">\n<property role=\"BnDLt\" value=\"true\" />\n</node>\n</node>\n</node>\n+ <node concept=\"3rtmxn\" id=\"1yReInH3uA\" role=\"3bR31x\">\n+ <node concept=\"3LXTmp\" id=\"1yReInH3uB\" role=\"3rtmxm\">\n+ <node concept=\"398BVA\" id=\"1yReInH3uC\" role=\"3LXTmr\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInH3uD\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.ui.sm.dom\" />\n+ </node>\n+ </node>\n+ <node concept=\"3qWCbU\" id=\"1yReInH3uF\" role=\"3LXTna\">\n+ <property role=\"3qWCbO\" value=\"icons/**, resources/**\" />\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"1E1JtA\" id=\"7gF2HTviNPU\" role=\"2G$12L\">\n<property role=\"BnDLt\" value=\"true\" />\n<ref role=\"3bR37D\" to=\"ffeo:mXGwHwhVPj\" resolve=\"JDK\" />\n</node>\n</node>\n- <node concept=\"1SiIV0\" id=\"7Hbm57D_HRx\" role=\"3bR37C\">\n- <node concept=\"1BurEX\" id=\"7Hbm57D_HRy\" role=\"1SiIV1\">\n- <node concept=\"398BVA\" id=\"7Hbm57D_HRo\" role=\"1BurEY\">\n- <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n- <node concept=\"2Ry0Ak\" id=\"7Hbm57D_HRp\" role=\"iGT6I\">\n- <property role=\"2Ry0Am\" value=\"org.modelix.model.client\" />\n- <node concept=\"2Ry0Ak\" id=\"7Hbm57D_HRq\" role=\"2Ry0An\">\n- <property role=\"2Ry0Am\" value=\"lib\" />\n- <node concept=\"2Ry0Ak\" id=\"7Hbm57D_HRr\" role=\"2Ry0An\">\n- <property role=\"2Ry0Am\" value=\"annotations-19.0.0.jar\" />\n- </node>\n- </node>\n- </node>\n- </node>\n- </node>\n- </node>\n<node concept=\"1SiIV0\" id=\"7Hbm57D_HRG\" role=\"3bR37C\">\n<node concept=\"1BurEX\" id=\"7Hbm57D_HRH\" role=\"1SiIV1\">\n<node concept=\"398BVA\" id=\"7Hbm57D_HRz\" role=\"1BurEY\">\n</node>\n</node>\n</node>\n+ <node concept=\"1SiIV0\" id=\"1yReInHWaw\" role=\"3bR37C\">\n+ <node concept=\"1BurEX\" id=\"1yReInHWax\" role=\"1SiIV1\">\n+ <node concept=\"398BVA\" id=\"1yReInHWan\" role=\"1BurEY\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInHWao\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.model.client\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInHWap\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"lib\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInHWaq\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"model-client-jvm-2020.1-SNAPSHOT.jar\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"1E1JtA\" id=\"7gF2HTviNPs\" role=\"2G$12L\">\n<property role=\"BnDLt\" value=\"true\" />\n</node>\n</node>\n</node>\n+ <node concept=\"3rtmxn\" id=\"1yReInH45S\" role=\"3bR31x\">\n+ <node concept=\"3LXTmp\" id=\"1yReInH45T\" role=\"3rtmxm\">\n+ <node concept=\"398BVA\" id=\"1yReInH45U\" role=\"3LXTmr\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInH45V\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.aspect\" />\n+ </node>\n+ </node>\n+ <node concept=\"3qWCbU\" id=\"1yReInH45X\" role=\"3LXTna\">\n+ <property role=\"3qWCbO\" value=\"icons/**, resources/**\" />\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"1E1JtA\" id=\"6HlxtAUSOXT\" role=\"2G$12L\">\n<property role=\"BnDLt\" value=\"true\" />\n<ref role=\"3bR37D\" node=\"7gF2HTviNPP\" resolve=\"org.modelix.lib\" />\n</node>\n</node>\n+ <node concept=\"3rtmxn\" id=\"1yReInH3Mf\" role=\"3bR31x\">\n+ <node concept=\"3LXTmp\" id=\"1yReInH3Mg\" role=\"3rtmxm\">\n+ <node concept=\"398BVA\" id=\"1yReInH3Mh\" role=\"3LXTmr\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInH3Mi\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.notation\" />\n+ </node>\n+ </node>\n+ <node concept=\"3qWCbU\" id=\"1yReInH3Mk\" role=\"3LXTna\">\n+ <property role=\"3qWCbO\" value=\"icons/**, resources/**\" />\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"3LEwk6\" id=\"6HlxtAUSHCt\" role=\"2G$12L\">\n<property role=\"BnDLt\" value=\"true\" />\n<node concept=\"3LEDTy\" id=\"7BujJjYSJ9v\" role=\"3LEDUa\">\n<ref role=\"3LEDTV\" node=\"7gF2HTviNPn\" resolve=\"org.modelix.ui.sm\" />\n</node>\n- <node concept=\"3LEDTy\" id=\"1yReInD1ms\" role=\"3LEDUa\">\n+ <node concept=\"3LEDTy\" id=\"1yReInHWbn\" role=\"3LEDUa\">\n<ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZc\" resolve=\"jetbrains.mps.baseLanguage.checkedDots\" />\n</node>\n- <node concept=\"3LEDTy\" id=\"1yReInD1mt\" role=\"3LEDUa\">\n+ <node concept=\"3LEDTy\" id=\"1yReInHWbo\" role=\"3LEDUa\">\n<ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L9c\" resolve=\"jetbrains.mps.lang.quotation\" />\n</node>\n</node>\n<ref role=\"3bR37D\" node=\"7gF2HTviNPF\" resolve=\"org.modelix.ui.sm.dom\" />\n</node>\n</node>\n+ <node concept=\"3rtmxn\" id=\"1yReInH4px\" role=\"3bR31x\">\n+ <node concept=\"3LXTmp\" id=\"1yReInH4py\" role=\"3rtmxm\">\n+ <node concept=\"398BVA\" id=\"1yReInH4pz\" role=\"3LXTmr\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1yReInH4p$\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.notation.impl.baseLanguage\" />\n+ </node>\n+ </node>\n+ <node concept=\"3qWCbU\" id=\"1yReInH4pA\" role=\"3LXTna\">\n+ <property role=\"3qWCbO\" value=\"icons/**, resources/**\" />\n+ </node>\n+ </node>\n+ </node>\n</node>\n</node>\n<node concept=\"2_Ic$z\" id=\"7BujJjXgSfB\" role=\"3989C9\">\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.model.client/org.modelix.model.client.msd", "new_path": "mps/org.modelix.model.client/org.modelix.model.client.msd", "diff": "<stubModelEntry path=\"${module}/lib/vavr-0.10.3.jar\" />\n<stubModelEntry path=\"${module}/lib/vavr-match-0.10.3.jar\" />\n<stubModelEntry path=\"${module}/lib/model-client-2020.1-SNAPSHOT.jar\" />\n+ <stubModelEntry path=\"${module}/lib/model-client-jvm-2020.1-SNAPSHOT.jar\" />\n</stubModelEntries>\n<sourcePath />\n<dependencies>\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.model/models/org.modelix.model.mps.mps", "new_path": "mps/org.modelix.model/models/org.modelix.model.mps.mps", "diff": "<import index=\"n7xv\" ref=\"0a2651ab-f212-45c2-a2f0-343e76cbc26b/java:org.modelix.model.util.pmap(org.modelix.model.client/)\" />\n<import index=\"1ctc\" ref=\"6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.util.stream(JDK/)\" />\n<import index=\"wyt6\" ref=\"6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.lang(JDK/)\" />\n- <import index=\"urs3\" ref=\"r:fc76aa36-3cff-41c7-b94b-eee0e8341932(jetbrains.mps.internal.collections.runtime)\" />\n<import index=\"18ew\" ref=\"6ed54515-acc8-4d1e-a16c-9fd6cfe951ea/java:jetbrains.mps.util(MPS.Core/)\" />\n<import index=\"dj5d\" ref=\"r:8bca245c-17c6-44f4-9367-ad6ce25cabf5(de.q60.mps.shadowmodels.runtimelang.structure)\" />\n<import index=\"3p1j\" ref=\"0a2651ab-f212-45c2-a2f0-343e76cbc26b/java:org.modelix.model.util(org.modelix.model.client/)\" />\n<import index=\"tqvn\" ref=\"6ed54515-acc8-4d1e-a16c-9fd6cfe951ea/java:jetbrains.mps.smodel.tempmodel(MPS.Core/)\" />\n- <import index=\"vndm\" ref=\"6ed54515-acc8-4d1e-a16c-9fd6cfe951ea/java:jetbrains.mps.smodel.language(MPS.Core/)\" />\n<import index=\"xkhl\" ref=\"0a2651ab-f212-45c2-a2f0-343e76cbc26b/java:org.modelix.model.lazy(org.modelix.model.client/)\" />\n- <import index=\"mhfn\" ref=\"0a2651ab-f212-45c2-a2f0-343e76cbc26b/java:org.jetbrains.annotations(org.modelix.model.client/)\" />\n<import index=\"vxxo\" ref=\"6ed54515-acc8-4d1e-a16c-9fd6cfe951ea/java:jetbrains.mps.smodel.adapter.structure.concept(MPS.Core/)\" />\n<import index=\"2k9e\" ref=\"6ed54515-acc8-4d1e-a16c-9fd6cfe951ea/java:jetbrains.mps.smodel.adapter.structure(MPS.Core/)\" />\n</imports>\n<property role=\"TrG5h\" value=\"serialize\" />\n<node concept=\"3Tm1VV\" id=\"1cGcLVgvFrJ\" role=\"1B3o_S\" />\n<node concept=\"2AHcQZ\" id=\"1cGcLVgvFrL\" role=\"2AJF6D\">\n- <ref role=\"2AI5Lk\" to=\"mhfn:~Nullable\" resolve=\"Nullable\" />\n+ <ref role=\"2AI5Lk\" to=\"mhfm:~Nullable\" resolve=\"Nullable\" />\n</node>\n<node concept=\"17QB3L\" id=\"1cGcLVgvGst\" role=\"3clF45\" />\n<node concept=\"37vLTG\" id=\"1cGcLVgvFrN\" role=\"3clF46\">\n<ref role=\"3uigEE\" to=\"jks5:~IConcept\" resolve=\"IConcept\" />\n</node>\n<node concept=\"2AHcQZ\" id=\"1cGcLVgvFrP\" role=\"2AJF6D\">\n- <ref role=\"2AI5Lk\" to=\"mhfn:~NotNull\" resolve=\"NotNull\" />\n+ <ref role=\"2AI5Lk\" to=\"mhfm:~NotNull\" resolve=\"NotNull\" />\n</node>\n</node>\n<node concept=\"3clFbS\" id=\"1cGcLVgvFrQ\" role=\"3clF47\">\n<property role=\"TrG5h\" value=\"deserialize\" />\n<node concept=\"3Tm1VV\" id=\"1cGcLVgvFrV\" role=\"1B3o_S\" />\n<node concept=\"2AHcQZ\" id=\"1cGcLVgvFrX\" role=\"2AJF6D\">\n- <ref role=\"2AI5Lk\" to=\"mhfn:~Nullable\" resolve=\"Nullable\" />\n+ <ref role=\"2AI5Lk\" to=\"mhfm:~Nullable\" resolve=\"Nullable\" />\n</node>\n<node concept=\"3uibUv\" id=\"1cGcLVgvFrY\" role=\"3clF45\">\n<ref role=\"3uigEE\" to=\"jks5:~IConcept\" resolve=\"IConcept\" />\n<property role=\"TrG5h\" value=\"serialized\" />\n<node concept=\"17QB3L\" id=\"1cGcLVgvG6r\" role=\"1tU5fm\" />\n<node concept=\"2AHcQZ\" id=\"1cGcLVgvFs1\" role=\"2AJF6D\">\n- <ref role=\"2AI5Lk\" to=\"mhfn:~NotNull\" resolve=\"NotNull\" />\n+ <ref role=\"2AI5Lk\" to=\"mhfm:~NotNull\" resolve=\"NotNull\" />\n</node>\n</node>\n<node concept=\"3clFbS\" id=\"1cGcLVgvFs2\" role=\"3clF47\">\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Kotlin multiplatform project for the model-client (3)
426,496
05.08.2020 13:59:41
-7,200
cfd8c055e5159c86e641c34b0ae16f232f938a7d
Kotlin multiplatform project for the model-client (4)
[ { "change_type": "MODIFY", "old_path": "build.gradle", "new_path": "build.gradle", "diff": "@@ -8,11 +8,14 @@ buildscript {\nrepositories {\nmaven { url 'https://projects.itemis.de/nexus/content/repositories/mbeddr' }\n+ maven { url \"https://repo.maven.apache.org/maven2\" }\n+ maven { url 'https://plugins.gradle.org/m2/' }\nmavenCentral()\n}\ndependencies {\nclasspath 'de.itemis.mps:mps-gradle-plugin:1.2.168.+'\n+ classpath 'com.google.googlejavaformat:google-java-format:1.8+'\n}\n}\n@@ -24,13 +27,7 @@ plugins {\nid \"com.jfrog.bintray\" version \"1.8.5\"\n}\n-repositories {\n- maven {\n- url 'https://projects.itemis.de/nexus/content/groups/OS/'\n- }\n- mavenCentral()\n- mavenLocal()\n-}\n+\nconfigurations {\nktlint\n@@ -39,6 +36,13 @@ configurations {\nallprojects {\ngroup 'org.modelix'\nversion '2020.1-SNAPSHOT'\n+\n+ repositories {\n+ maven { url 'https://projects.itemis.de/nexus/content/groups/OS/' }\n+ maven { url \"https://repo.maven.apache.org/maven2\" }\n+ mavenCentral()\n+ mavenLocal()\n+ }\n}\ndescription = \"Cloud storage and web UI for MPS\"\n@@ -150,42 +154,3 @@ task runMpsTests(type: TestLanguages, dependsOn: buildMpsModules) {\nscriptClasspath = buildScriptClasspath\nscript new File(\"$rootDir/build/test.org.modelix/build-tests.xml\")\n}\n\\ No newline at end of file\n-\n-spotless {\n- java {\n- googleJavaFormat(sourceCompatibility.toString()).aosp()\n- licenseHeader '/*\\n' +\n- ' * Licensed under the Apache License, Version 2.0 (the \"License\");\\n' +\n- ' * you may not use this file except in compliance with the License.\\n' +\n- ' * You may obtain a copy of the License at\\n' +\n- ' *\\n' +\n- ' * http://www.apache.org/licenses/LICENSE-2.0\\n' +\n- ' *\\n' +\n- ' * Unless required by applicable law or agreed to in writing,\\n' +\n- ' * software distributed under the License is distributed on an\\n' +\n- ' * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\\n' +\n- ' * KIND, either express or implied. See the License for the\\n' +\n- ' * specific language governing permissions and limitations\\n' +\n- ' * under the License. \\n' +\n- ' */\\n' +\n- '\\n'\n- }\n-\n- kotlin {\n- licenseHeader '/*\\n' +\n- ' * Licensed under the Apache License, Version 2.0 (the \"License\");\\n' +\n- ' * you may not use this file except in compliance with the License.\\n' +\n- ' * You may obtain a copy of the License at\\n' +\n- ' *\\n' +\n- ' * http://www.apache.org/licenses/LICENSE-2.0\\n' +\n- ' *\\n' +\n- ' * Unless required by applicable law or agreed to in writing,\\n' +\n- ' * software distributed under the License is distributed on an\\n' +\n- ' * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\\n' +\n- ' * KIND, either express or implied. See the License for the\\n' +\n- ' * specific language governing permissions and limitations\\n' +\n- ' * under the License. \\n' +\n- ' */\\n' +\n- '\\n'\n- }\n-}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/build.gradle", "new_path": "model-client/build.gradle", "diff": "@@ -7,10 +7,6 @@ plugins {\nid \"org.jlleitschuh.gradle.ktlint\"\n}\n-repositories {\n- mavenCentral()\n-}\n-\ntasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {\nkotlinOptions {\njvmTarget = \"11\"\n@@ -82,6 +78,26 @@ kotlin {\n}\n}\n+spotless {\n+ kotlin {\n+ licenseHeader '/*\\n' +\n+ ' * Licensed under the Apache License, Version 2.0 (the \"License\");\\n' +\n+ ' * you may not use this file except in compliance with the License.\\n' +\n+ ' * You may obtain a copy of the License at\\n' +\n+ ' *\\n' +\n+ ' * http://www.apache.org/licenses/LICENSE-2.0\\n' +\n+ ' *\\n' +\n+ ' * Unless required by applicable law or agreed to in writing,\\n' +\n+ ' * software distributed under the License is distributed on an\\n' +\n+ ' * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\\n' +\n+ ' * KIND, either express or implied. See the License for the\\n' +\n+ ' * specific language governing permissions and limitations\\n' +\n+ ' * under the License. \\n' +\n+ ' */\\n' +\n+ '\\n'\n+ }\n+}\n+\ntask deleteMpsLibs() {\ndelete \"$projectDir/../mps/org.modelix.model.client/lib\"\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -12,9 +12,8 @@ version = '1.0-SNAPSHOT'\ndefaultTasks 'build'\n-repositories {\n- maven { url \"https://repo.maven.apache.org/maven2\" }\n-}\n+sourceCompatibility = 1.8\n+targetCompatibility = 1.8\ndependencies {\ncompile group: 'org.json', name: 'json', version:'20180813'\n@@ -82,3 +81,24 @@ bintray {\npublish = true\noverride = true\n}\n+\n+spotless {\n+ java {\n+ googleJavaFormat(sourceCompatibility.toString()).aosp()\n+ licenseHeader '/*\\n' +\n+ ' * Licensed under the Apache License, Version 2.0 (the \"License\");\\n' +\n+ ' * you may not use this file except in compliance with the License.\\n' +\n+ ' * You may obtain a copy of the License at\\n' +\n+ ' *\\n' +\n+ ' * http://www.apache.org/licenses/LICENSE-2.0\\n' +\n+ ' *\\n' +\n+ ' * Unless required by applicable law or agreed to in writing,\\n' +\n+ ' * software distributed under the License is distributed on an\\n' +\n+ ' * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\\n' +\n+ ' * KIND, either express or implied. See the License for the\\n' +\n+ ' * specific language governing permissions and limitations\\n' +\n+ ' * under the License. \\n' +\n+ ' */\\n' +\n+ '\\n'\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "ui-client/build.gradle", "new_path": "ui-client/build.gradle", "diff": "-buildscript {\n- repositories {\n- mavenCentral()\n- maven {\n- url 'https://plugins.gradle.org/m2/'\n- }\n- }\n-}\nplugins {\nid \"com.github.node-gradle.node\" version \"2.2.4\"\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Kotlin multiplatform project for the model-client (4)
426,496
05.08.2020 14:03:50
-7,200
fd78a216687229c7ba8d6a651510b7571b9a955c
Kotlin multiplatform project for the model-client (5)
[ { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -12,9 +12,6 @@ version = '1.0-SNAPSHOT'\ndefaultTasks 'build'\n-sourceCompatibility = 1.8\n-targetCompatibility = 1.8\n-\ndependencies {\ncompile group: 'org.json', name: 'json', version:'20180813'\ncompile group: 'org.java-websocket', name: 'Java-WebSocket', version:'1.4.0'\n@@ -84,7 +81,7 @@ bintray {\nspotless {\njava {\n- googleJavaFormat(sourceCompatibility.toString()).aosp()\n+ googleJavaFormat(\"1.8\").aosp()\nlicenseHeader '/*\\n' +\n' * Licensed under the Apache License, Version 2.0 (the \"License\");\\n' +\n' * you may not use this file except in compliance with the License.\\n' +\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Kotlin multiplatform project for the model-client (5)
426,496
05.08.2020 14:40:25
-7,200
9173742540d69383940b4a5bbcf5866ee615907f
Disable karma test execution in ui-client as there are no tests and this fails on CI
[ { "change_type": "MODIFY", "old_path": "ui-client/build.gradle", "new_path": "ui-client/build.gradle", "diff": "@@ -42,6 +42,10 @@ task packageNpmApp(type: Zip) {\n}\n}\n+clean {\n+ delete packageNpmApp.archiveFile\n+}\n+\n// declare a dedicated scope for publishing the packaged JAR\nconfigurations {\nnpmResources\n@@ -59,6 +63,7 @@ artifacts {\nassemble.dependsOn packageNpmApp\n+/*\nString testsExecutedMarkerName = \"${projectDir}/.tests.executed\"\ntask test(type: NpmTask) {\n@@ -83,6 +88,6 @@ task test(type: NpmTask) {\ncheck.dependsOn test\nclean {\n- delete packageNpmApp.archivePath\ndelete testsExecutedMarkerName\n}\n+*/\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Disable karma test execution in ui-client as there are no tests and this fails on CI
426,496
05.08.2020 16:45:45
-7,200
c7d0d32bdb4f12570b2fb271ad51dea4e7cd167e
First classes moved to the kolin common subproject (2)
[ { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/api/PBranch.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/api/PBranch.kt", "diff": "@@ -21,7 +21,6 @@ import org.apache.log4j.LogManager\nimport org.modelix.model.api.DefaultIdGenerator.Companion.instance\nimport org.modelix.model.util.ContextValue\nimport org.modelix.model.util.pmap.COWArrays\n-import java.util.function.Supplier\nclass PBranch @JvmOverloads constructor(@field:Volatile private var tree: ITree, private val idGenerator: IIdGenerator = instance) : IBranch {\nprivate val writeLock = Any()\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/api/PNodeAdapter.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/api/PNodeAdapter.kt", "diff": "package org.modelix.model.api\nimport java.lang.IllegalArgumentException\n-import java.util.function.Supplier\n-import java.util.stream.Stream\nopen class PNodeAdapter(val nodeId: Long, val branch: IBranch) : INode {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/lazy/CLTree.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/lazy/CLTree.kt", "diff": "@@ -34,7 +34,6 @@ import java.util.*\nimport java.util.function.Consumer\nimport java.util.function.Function\nimport java.util.stream.Collectors\n-import java.util.stream.LongStream\nimport java.util.stream.Stream\nimport java.util.stream.StreamSupport\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/operations/OTBranch.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/operations/OTBranch.kt", "diff": "@@ -19,7 +19,6 @@ import io.vavr.Tuple\nimport io.vavr.Tuple2\nimport org.modelix.model.api.*\nimport java.util.*\n-import java.util.function.Supplier\nclass OTBranch(private val branch: IBranch, private val idGenerator: IIdGenerator) : IBranch {\nprivate var operations: MutableList<IAppliedOperation> = ArrayList()\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "diff": "@@ -25,7 +25,6 @@ import org.modelix.model.api.ITree\nimport org.modelix.model.api.IWriteTransaction\nimport org.modelix.model.api.PNodeAdapter\nimport org.modelix.model.util.StreamUtils.indexOf\n-import java.util.stream.LongStream\nclass OTWriteTransaction(private val transaction: IWriteTransaction, private val otBranch: OTBranch, protected var idGenerator: IIdGenerator) : IWriteTransaction {\nprotected fun apply(op: IOperation) {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmTest/kotlin/org/modelix/model/TreeTestUtil.kt", "new_path": "model-client/src/jvmTest/kotlin/org/modelix/model/TreeTestUtil.kt", "diff": "@@ -32,32 +32,32 @@ class TreeTestUtil(private val tree: ITree, private val rand: Random) {\n}\n}\n- val allNodes: LongStream\n+ val allNodes: Iterable<Long>\nget() = getDescendants(ITree.ROOT_ID, true)\n- val allNodesWithoutRoot: LongStream\n+ val allNodesWithoutRoot: Iterable<Long>\nget() = getDescendants(ITree.ROOT_ID, false)\n- fun getDescendants(parent: Long, includeSelf: Boolean): LongStream {\n+ fun getDescendants(parent: Long, includeSelf: Boolean): Iterable<Long> {\nreturn if (includeSelf) {\n- LongStream.concat(LongStream.of(parent), getDescendants(parent, false))\n+ (sequenceOf(parent) + getDescendants(parent, false)).asIterable()\n} else {\n- tree.getAllChildren(parent)!!.flatMap { it: Long -> getDescendants(it, true) }\n+ tree.getAllChildren(parent).flatMap { it: Long -> getDescendants(it, true) }\n}\n}\nval randomNodeWithoutRoot: Long\n- get() = getRandomNode(allNodesWithoutRoot.toArray())\n+ get() = getRandomNode(allNodesWithoutRoot)\nval randomNodeWithRoot: Long\n- get() = getRandomNode(allNodes.toArray())\n+ get() = getRandomNode(allNodes)\n- fun getRandomNode(nodes: LongArray): Long {\n- return if (nodes.size == 0) {\n+ fun getRandomNode(nodes: Iterable<Long>): Long {\n+ return if (nodes.count() == 0) {\n0L\n- } else LongStream.of(*nodes).skip(rand.nextInt(nodes.size).toLong()).findFirst().orElse(0L)\n+ } else nodes.drop(rand.nextInt(nodes.count())).first()\n}\nval randomLeafNode: Long\n- get() = getRandomNode(allNodes.filter { it: Long -> !tree.getAllChildren(it)!!.iterator().hasNext() }.toArray())\n+ get() = getRandomNode(allNodes.filter { tree.getAllChildren(it).count() == 0 })\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmTest/kotlin/org/modelix/model/Tree_Test.kt", "new_path": "model-client/src/jvmTest/kotlin/org/modelix/model/Tree_Test.kt", "diff": "@@ -26,6 +26,7 @@ import org.modelix.model.lazy.CLTree\nimport org.modelix.model.lazy.ObjectStoreCache\nimport org.modelix.model.persistent.MapBaseStore\nimport java.util.*\n+import kotlin.streams.toList\nclass Tree_Test {\nprivate val DEBUG = false\n@@ -107,7 +108,6 @@ class Tree_Test {\nutil\n.allNodes\n.filter { it: Long -> util.getAncestors(it, true).noneMatch { it2: Long -> it2 == childId } }\n- .toArray()\n)\nif (childId != 0L && parent != 0L) {\nval role = roles[rand.nextInt(roles.size)]\n@@ -143,9 +143,9 @@ class Tree_Test {\nif (expectedDeletes.contains(key._1() as Long)) {\ncontinue\n}\n- val expected = value.stream().mapToLong { it: Long? -> it!! }.toArray()\n- val actual = tree!!.getChildren(key._1() as Long, key._2())!!.toArray()\n- Assert.assertArrayEquals(expected, actual)\n+ val expected = value.toList()\n+ val actual = tree!!.getChildren(key._1() as Long, key._2()).toList()\n+ Assert.assertEquals(expected, actual)\n}\nfor ((key, value) in expectedRoles) {\nAssert.assertEquals(value, tree!!.getRole(key))\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
First classes moved to the kolin common subproject (2)
426,496
07.08.2020 19:59:39
-7,200
ca01a71909e8af77972f829f55c06a2994839d69
Adjusted MPS code to API changes
[ { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/util/pmap/CustomPMap.kt", "diff": "+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.modelix.model.util.pmap\n+\n+interface CustomPMap<K, V> {\n+ fun put(key: K, value: V): CustomPMap<K, V>?\n+ operator fun get(key: K): V\n+ fun remove(key: K): CustomPMap<K, V>?\n+ fun keys(): Iterable<K>?\n+ fun values(): Iterable<V>?\n+ fun containsKey(key: K): Boolean\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/util/pmap/LongKeyPMap.kt", "diff": "+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.modelix.model.util.pmap\n+\n+import org.apache.commons.lang3.mutable.MutableObject\n+import org.modelix.model.util.pmap.COWArrays.insert\n+import org.modelix.model.util.pmap.COWArrays.removeAt\n+import org.modelix.model.util.pmap.COWArrays.set\n+import java.util.function.BiPredicate\n+\n+class LongKeyPMap<V> protected constructor(root: INode<V?>?) {\n+ private val root: INode<V?>\n+\n+ constructor() : this(null) {}\n+\n+ operator fun get(key: Long): V {\n+ return root[key, 0]!!\n+ }\n+\n+ fun put(key: Long, value: V): LongKeyPMap<V?> {\n+ return LongKeyPMap<V?>(this.root.put(key, value, 0) as INode<V?>)\n+ }\n+\n+ fun remove(key: Long): LongKeyPMap<V?> {\n+ return LongKeyPMap<V?>(root.remove(key, 0) as INode<V?>)\n+ }\n+\n+ fun visitEntries(visitor: BiPredicate<Long, V?>?) {\n+ root.visitEntries(visitor!!)\n+ }\n+\n+ fun visitChanges(oldMap: LongKeyPMap<V>, visitor: IChangeVisitor<V?>?) {\n+ root.visitChanges(oldMap.root, visitor!!)\n+ }\n+\n+ interface INode<V> {\n+ fun put(key: Long, value: V?, shift: Int): INode<*>?\n+ fun remove(key: Long, shift: Int): INode<*>?\n+ operator fun get(key: Long, shift: Int): V\n+ fun visitEntries(visitor: BiPredicate<Long, V>): Boolean\n+ fun visitChanges(oldNode: INode<V>, visitor: IChangeVisitor<V>)\n+ }\n+\n+ interface IChangeVisitor<V> {\n+ fun entryAdded(key: Long, value: V)\n+ fun entryRemoved(key: Long, value: V)\n+ fun entryChanged(key: Long, oldValue: V, newValue: V)\n+ }\n+\n+ class InternalNode<V>(private val bitmap: Int, children: Array<INode<V?>>) : INode<V?> {\n+ private val children: Array<INode<V?>>\n+ override fun put(key: Long, value: V?, shift: Int): INode<V?>? {\n+ val childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ val child = getChild(childIndex)\n+ return if (child == null) {\n+ setChild(childIndex, LeafNode.create(key, value))\n+ } else {\n+ setChild(childIndex, child.put(key, value, shift + BITS_PER_LEVEL))\n+ }\n+ }\n+\n+ override fun remove(key: Long, shift: Int): INode<V?>? {\n+ val childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ val child = getChild(childIndex)\n+ return if (child == null) {\n+ this as INode<V?>\n+ } else {\n+ setChild(childIndex, child.remove(key, shift + BITS_PER_LEVEL))\n+ }\n+ }\n+\n+ override fun get(key: Long, shift: Int): V? {\n+ val childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ val child = getChild(childIndex) ?: return null\n+ return child[key, shift + BITS_PER_LEVEL]\n+ }\n+\n+ fun getChild(logicalIndex: Int): INode<V?>? {\n+ if (isBitNotSet(bitmap, logicalIndex)) {\n+ return null\n+ }\n+ val physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex)\n+ return children[physicalIndex]\n+ }\n+\n+ fun setChild(logicalIndex: Int, child: INode<*>?): INode<V?>? {\n+ if (child == null) {\n+ return deleteChild(logicalIndex)\n+ }\n+ val physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex)\n+ return if (isBitNotSet(bitmap, logicalIndex)) {\n+ val bm: Int = bitmap or (1 shl logicalIndex)\n+ val resultingArray: Array<INode<V?>> = insert<INode<V?>>(children as Array<INode<V?>>, physicalIndex, child as INode<V?>) as Array<INode<V?>>\n+ InternalNode(bm, resultingArray)\n+ } else {\n+ InternalNode(bitmap, set<INode<V?>>(children, physicalIndex, child as INode<V?>))\n+ }\n+ }\n+\n+ fun deleteChild(logicalIndex: Int): INode<V?>? {\n+ if (isBitNotSet(bitmap, logicalIndex)) {\n+ return this\n+ }\n+ val physicalIndex = logicalToPhysicalIndex(bitmap, logicalIndex)\n+ val newBitmap = bitmap and (1 shl logicalIndex).inv()\n+ if (newBitmap == 0) {\n+ return null\n+ }\n+ val newChildren: Array<INode<V?>> = removeAt(children, physicalIndex)\n+ return if (newChildren.size == 1 && newChildren[0] is LeafNode<*>) {\n+ newChildren[0]\n+ } else InternalNode(newBitmap, newChildren)\n+ }\n+\n+ override fun visitEntries(visitor: BiPredicate<Long, V?>): Boolean {\n+ for (child in children) {\n+ val continueVisit = child.visitEntries(visitor)\n+ if (!continueVisit) {\n+ return false\n+ }\n+ }\n+ return true\n+ }\n+\n+ override fun visitChanges(oldNode: INode<V?>, visitor: IChangeVisitor<V?>) {\n+ if (oldNode === this) {\n+ return\n+ }\n+ if (oldNode is InternalNode<*>) {\n+ if (bitmap == (oldNode as InternalNode<*>).bitmap) {\n+ for (i in children.indices) {\n+ children[i].visitChanges((oldNode as InternalNode<V?>).children[i], visitor)\n+ }\n+ } else {\n+ for (logicalIndex in 0 until ENTRIES_PER_LEVEL) {\n+ val child = getChild(logicalIndex)\n+ val oldChild = (oldNode as InternalNode<V?>).getChild(logicalIndex)\n+ if (child == null) {\n+ if (oldChild == null) {\n+ // no change\n+ } else {\n+ oldChild.visitEntries(\n+ BiPredicate { key: Long?, value: V? ->\n+ visitor.entryRemoved(key!!, value)\n+ true\n+ }\n+ )\n+ }\n+ } else {\n+ if (oldChild == null) {\n+ child.visitEntries(\n+ BiPredicate { key: Long?, value: V? ->\n+ visitor.entryAdded(key!!, value)\n+ true\n+ }\n+ )\n+ } else {\n+ child.visitChanges(oldChild, visitor)\n+ }\n+ }\n+ }\n+ }\n+ } else if (oldNode is LeafNode<*>) {\n+ visitEntries(\n+ BiPredicate { k: Long, v: V? ->\n+ if (k == (oldNode as LeafNode<V?>).key) {\n+ if (v !== oldNode.value) {\n+ visitor.entryChanged(k, oldNode.value, v)\n+ }\n+ } else {\n+ visitor.entryAdded(k, v)\n+ }\n+ true\n+ }\n+ )\n+ } else {\n+ throw RuntimeException(\"Unknown type: \" + oldNode.javaClass.name)\n+ }\n+ }\n+\n+ companion object {\n+ private val EMPTY_CHILDREN: Array<INode<*>?> = arrayOfNulls(0)\n+ val EMPTY: InternalNode<*> = InternalNode<Any?>(0, EMPTY_CHILDREN as Array<INode<Any?>>)\n+ fun <T> empty(): InternalNode<T> {\n+ return EMPTY as InternalNode<T>\n+ }\n+ }\n+\n+ init {\n+ this.children = children\n+ }\n+ }\n+\n+ class LeafNode<V>(val key: Long, val value: V) : INode<V?> {\n+ override fun put(key: Long, value: V?, shift: Int): INode<*>? {\n+ return if (key == this.key) {\n+ if (value === this.value) {\n+ this\n+ } else {\n+ create(key, value)\n+ }\n+ } else {\n+ if (shift > MAX_SHIFT) {\n+ throw RuntimeException(\"$shift > $MAX_SHIFT\")\n+ }\n+ var result: INode<V?>? = InternalNode.empty<V?>()\n+ result = result!!.put(this.key, this.value, shift) as INode<V?>\n+ if (result == null) {\n+ result = InternalNode.empty<V?>()\n+ }\n+ result = result.put(key, value, shift) as INode<V?>\n+ result\n+ }\n+ }\n+\n+ override fun remove(key: Long, shift: Int): INode<*>? {\n+ return if (key == this.key) {\n+ null\n+ } else {\n+ this\n+ }\n+ }\n+\n+ override fun get(key: Long, shift: Int): V? {\n+ return if (this.key == key) value else null\n+ }\n+\n+ override fun visitEntries(visitor: BiPredicate<Long, V?>): Boolean {\n+ return visitor.test(key, value)\n+ }\n+\n+ override fun visitChanges(oldNode: INode<V?>, visitor: IChangeVisitor<V?>) {\n+ if (oldNode === this) {\n+ return\n+ }\n+ val oldValue = MutableObject<V?>()\n+ oldNode.visitEntries(\n+ BiPredicate { k: Long, v: V? ->\n+ if (k == key) {\n+ oldValue.setValue(v)\n+ } else {\n+ visitor.entryRemoved(k, v)\n+ }\n+ true\n+ }\n+ )\n+ if (oldValue.value == null) {\n+ visitor.entryAdded(key, value)\n+ } else if (oldValue.value !== value) {\n+ visitor.entryChanged(key, oldValue.value, value)\n+ }\n+ }\n+\n+ companion object {\n+ fun <V> create(key: Long, value: V?): LeafNode<V>? {\n+ return value?.let { LeafNode(key, it) }\n+ }\n+ }\n+ }\n+\n+ class EmptyNode<V> : INode<V?> {\n+ override fun put(key: Long, value: V?, shift: Int): INode<*>? {\n+ return LeafNode.create(key, value)\n+ }\n+\n+ override fun get(key: Long, shift: Int): V? {\n+ return null\n+ }\n+\n+ override fun remove(key: Long, shift: Int): INode<*> {\n+ return this\n+ }\n+\n+ override fun visitEntries(visitor: BiPredicate<Long, V?>): Boolean {\n+ return true\n+ }\n+\n+ override fun visitChanges(oldNode: INode<V?>, visitor: IChangeVisitor<V?>) {\n+ if (oldNode === this) {\n+ return\n+ }\n+ oldNode.visitEntries(\n+ BiPredicate { k: Long?, v: V? ->\n+ visitor.entryRemoved(k!!, v)\n+ true\n+ }\n+ )\n+ }\n+ }\n+\n+ companion object {\n+ private const val BITS_PER_LEVEL = 5\n+ private const val ENTRIES_PER_LEVEL = 1 shl BITS_PER_LEVEL\n+ private const val LEVEL_MASK = -0x1 ushr 32 - BITS_PER_LEVEL\n+ private const val MAX_BITS = 64\n+ private const val MAX_SHIFT = MAX_BITS - BITS_PER_LEVEL\n+ fun logicalToPhysicalIndex(bitmap: Int, logicalIndex: Int): Int {\n+ return Integer.bitCount(bitmap and (1 shl logicalIndex) - 1)\n+ }\n+\n+ fun isBitNotSet(bitmap: Int, logicalIndex: Int): Boolean {\n+ return bitmap and (1 shl logicalIndex) == 0\n+ }\n+ }\n+\n+ init {\n+ this.root = root ?: EmptyNode<V?>()\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/util/pmap/SmallPMap.kt", "diff": "+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.modelix.model.util.pmap\n+\n+import org.modelix.model.util.StreamUtils.toStream\n+import org.modelix.model.util.pmap.COWArrays.add\n+import org.modelix.model.util.pmap.COWArrays.indexOf\n+import org.modelix.model.util.pmap.COWArrays.removeAt\n+import org.modelix.model.util.pmap.COWArrays.set\n+import java.util.stream.Collectors\n+import java.util.stream.Stream\n+\n+abstract class SmallPMap<K, V> : CustomPMap<K, V> {\n+ abstract override fun get(key: K): V\n+ abstract override fun put(key: K, value: V): SmallPMap<K, V>?\n+ abstract override fun remove(key: K): SmallPMap<K, V>?\n+ abstract override fun keys(): Iterable<K>?\n+ abstract override fun values(): Iterable<V>?\n+ class Single<K, V>(private val key: K, private val value: V) : SmallPMap<K, V?>() {\n+ override fun get(key: K): V? {\n+ return if (this.key == key) value else null\n+ }\n+\n+ override fun keys(): Iterable<K>? {\n+ return setOf(key)\n+ }\n+\n+ override fun put(key: K, value: V?): SmallPMap<K, V?>? {\n+ if (value == null) {\n+ return remove(key) as SmallPMap<K, V?>?\n+ }\n+ return if (key == this.key) {\n+ if (value == this.value) {\n+ this as SmallPMap<K, V?>?\n+ } else {\n+ Single<K, V>(key, value) as SmallPMap<K, V?>?\n+ }\n+ } else {\n+ var res: SmallPMap<K, V?>?\n+ val p1: Array<Any?> = arrayOf(this.key, key)\n+ val p2: Array<Any?> = arrayOf(this.value, value)\n+ res = create<K, V?>(p1, p2) as SmallPMap<K, V?>?\n+ return res as SmallPMap<K, V?>?\n+ }\n+ }\n+\n+ override fun remove(key: K): SmallPMap<K, V?>? {\n+ return if (key == this.key) EMPTY as SmallPMap<K, V?>? else this\n+ }\n+\n+ override fun values(): Iterable<V?>? {\n+ return setOf(value)\n+ }\n+\n+ override fun containsKey(key: K): Boolean {\n+ return key == this.key\n+ }\n+ }\n+\n+ class Multiple<K, V>(private val keys: Array<Any?>, private val values: Array<Any?>) : SmallPMap<K, V?>() {\n+ override fun get(key: K): V? {\n+ for (i in keys.indices) {\n+ if (keys[i] == key) {\n+ return values[i] as V?\n+ }\n+ }\n+ return null\n+ }\n+\n+ override fun put(key: K, value: V?): SmallPMap<K, V?>? {\n+ if (value == null) {\n+ return remove(key)as SmallPMap<K, V?>?\n+ }\n+ val index = indexOf(keys, key)\n+ return if (index != -1) {\n+ if (value == values[index]) {\n+ this as SmallPMap<K, V?>?\n+ } else {\n+ create<K, V?>(keys, set(values, index, value)) as SmallPMap<K, V?>?\n+ }\n+ } else {\n+ create<K, V?>(add(keys, key), add(values, value)) as SmallPMap<K, V?>?\n+ }\n+ }\n+\n+ override fun remove(key: K): SmallPMap<K, V?>? {\n+ val index = indexOf(keys, key)\n+ return if (index != -1) {\n+ create<K, V?>(removeAt(keys, index), removeAt(values, index)) as SmallPMap<K, V?>?\n+ } else {\n+ this\n+ }\n+ }\n+\n+ override fun keys(): Iterable<K>? {\n+ return Stream.of<Any>(*keys).map { it: Any -> it as K }.collect(Collectors.toList())\n+ }\n+\n+ override fun values(): Iterable<V?>? {\n+ return Stream.of<Any>(*values).map { it: Any -> it as V }.collect(Collectors.toList())\n+ }\n+\n+ override fun containsKey(key: K): Boolean {\n+ for (k in keys) {\n+ if (k == key) {\n+ return true\n+ }\n+ }\n+ return false\n+ }\n+ }\n+\n+ companion object {\n+ private val EMPTY: SmallPMap<*, *> = Multiple<Any?, Any?>(arrayOfNulls(0), arrayOfNulls(0))\n+ fun <K, V> empty(): SmallPMap<K, V> {\n+ return EMPTY as SmallPMap<K, V>\n+ }\n+\n+ private fun <K, V> create(keys: Array<Any?>, values: Array<Any?>): SmallPMap<K?, V?> {\n+ if (keys.size == 0) {\n+ return empty()\n+ }\n+ return if (keys.size == 1) {\n+ Single(keys[0] as K?, values[0] as V?)\n+ } else Multiple<K?, V?>(keys, values)\n+ }\n+\n+ fun <K, V> createS(keys: Iterable<K>?, values: Iterable<V>?): SmallPMap<K, V> {\n+ return create<K, V>(\n+ toStream(keys!!).collect(Collectors.toList()).toTypedArray(),\n+ toStream(values!!).collect(Collectors.toList()).toTypedArray()\n+ ) as SmallPMap<K, V>\n+ }\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.model.client/org.modelix.model.client.msd", "new_path": "mps/org.modelix.model.client/org.modelix.model.client.msd", "diff": "<sourceRoot location=\"jersey-server-2.31.jar\" />\n<sourceRoot location=\"model-client-2020.1-SNAPSHOT.jar\" />\n<sourceRoot location=\"model-client-jvm-2020.1-SNAPSHOT.jar\" />\n+ <sourceRoot location=\"kotlin-stdlib-jdk7-1.3.72.jar\" />\n+ <sourceRoot location=\"kotlin-stdlib-jdk8-1.3.72.jar\" />\n+ <sourceRoot location=\"annotations-13.0.jar\" />\n+ <sourceRoot location=\"log4j-1.2.17.jar\" />\n+ <sourceRoot location=\"model-client-js-2020.1-SNAPSHOT.jar\" />\n+ <sourceRoot location=\"model-client-metadata-2020.1-SNAPSHOT.jar\" />\n</modelRoot>\n</models>\n<facets>\n</facet>\n</facets>\n<stubModelEntries>\n+ <stubModelEntry path=\"${module}/lib/annotations-13.0.jar\" />\n<stubModelEntry path=\"${module}/lib/aopalliance-repackaged-2.6.1.jar\" />\n<stubModelEntry path=\"${module}/lib/checker-qual-2.11.1.jar\" />\n<stubModelEntry path=\"${module}/lib/commons-collections4-4.4.jar\" />\n<stubModelEntry path=\"${module}/lib/jsr305-3.0.2.jar\" />\n<stubModelEntry path=\"${module}/lib/kotlin-stdlib-1.3.72.jar\" />\n<stubModelEntry path=\"${module}/lib/kotlin-stdlib-common-1.3.72.jar\" />\n+ <stubModelEntry path=\"${module}/lib/kotlin-stdlib-jdk7-1.3.72.jar\" />\n+ <stubModelEntry path=\"${module}/lib/kotlin-stdlib-jdk8-1.3.72.jar\" />\n<stubModelEntry path=\"${module}/lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar\" />\n+ <stubModelEntry path=\"${module}/lib/log4j-1.2.17.jar\" />\n+ <stubModelEntry path=\"${module}/lib/model-client-2020.1-SNAPSHOT.jar\" />\n+ <stubModelEntry path=\"${module}/lib/model-client-js-2020.1-SNAPSHOT.jar\" />\n+ <stubModelEntry path=\"${module}/lib/model-client-jvm-2020.1-SNAPSHOT.jar\" />\n+ <stubModelEntry path=\"${module}/lib/model-client-metadata-2020.1-SNAPSHOT.jar\" />\n<stubModelEntry path=\"${module}/lib/osgi-resource-locator-1.0.3.jar\" />\n<stubModelEntry path=\"${module}/lib/trove4j-3.0.3.jar\" />\n<stubModelEntry path=\"${module}/lib/vavr-0.10.3.jar\" />\n<stubModelEntry path=\"${module}/lib/vavr-match-0.10.3.jar\" />\n- <stubModelEntry path=\"${module}/lib/model-client-2020.1-SNAPSHOT.jar\" />\n- <stubModelEntry path=\"${module}/lib/model-client-jvm-2020.1-SNAPSHOT.jar\" />\n</stubModelEntries>\n<sourcePath />\n<dependencies>\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.model.mpsplugin/models/org.modelix.model.mpsplugin.mps", "new_path": "mps/org.modelix.model.mpsplugin/models/org.modelix.model.mpsplugin.mps", "diff": "<import index=\"n7xv\" ref=\"0a2651ab-f212-45c2-a2f0-343e76cbc26b/java:org.modelix.model.util.pmap(org.modelix.model.client/)\" />\n<import index=\"fbzs\" ref=\"6354ebe7-c22a-4a0f-ac54-50b52ab9b065/java:java.awt.geom(JDK/)\" />\n<import index=\"v18h\" ref=\"0a2651ab-f212-45c2-a2f0-343e76cbc26b/java:kotlin(org.modelix.model.client/)\" />\n+ <import index=\"ouht\" ref=\"0a2651ab-f212-45c2-a2f0-343e76cbc26b/java:kotlin.jvm.functions(org.modelix.model.client/)\" />\n</imports>\n<registry>\n<language id=\"f3061a53-9226-4cc5-a443-f952ceaf5816\" name=\"jetbrains.mps.baseLanguage\">\n<concept id=\"1080120340718\" name=\"jetbrains.mps.baseLanguage.structure.AndExpression\" flags=\"nn\" index=\"1Wc70l\" />\n<concept id=\"1170345865475\" name=\"jetbrains.mps.baseLanguage.structure.AnonymousClass\" flags=\"ig\" index=\"1Y3b0j\">\n<reference id=\"1170346070688\" name=\"classifier\" index=\"1Y3XeK\" />\n+ <child id=\"1201186121363\" name=\"typeParameter\" index=\"2Ghqu4\" />\n</concept>\n</language>\n<language id=\"63650c59-16c8-498a-99c8-005c7ee9515d\" name=\"jetbrains.mps.lang.access\">\n<node concept=\"37vLTI\" id=\"6aRQr1X2cuN\" role=\"3clFbG\">\n<node concept=\"2ShNRf\" id=\"6aRQr1X2cQB\" role=\"37vLTx\">\n<node concept=\"1pGfFk\" id=\"6aRQr1X2cEg\" role=\"2ShVmc\">\n- <ref role=\"37wK5l\" to=\"5440:~ActiveBranch.&lt;init&gt;(org.modelix.model.client.IModelClient,org.modelix.model.lazy.TreeId,java.lang.String,java.util.function.Supplier)\" resolve=\"ActiveBranch\" />\n+ <ref role=\"37wK5l\" to=\"5440:~ActiveBranch.&lt;init&gt;(org.modelix.model.client.IModelClient,org.modelix.model.lazy.TreeId,java.lang.String,kotlin.jvm.functions.Function0)\" resolve=\"ActiveBranch\" />\n<node concept=\"37vLTw\" id=\"6aRQr1X2d2U\" role=\"37wK5m\">\n<ref role=\"3cqZAo\" node=\"6aRQr1WVnku\" resolve=\"client\" />\n</node>\n</node>\n<node concept=\"37vLTG\" id=\"2EzI5qKsi96\" role=\"3clF46\">\n<property role=\"TrG5h\" value=\"user\" />\n+ <property role=\"3TUv4t\" value=\"true\" />\n<node concept=\"3uibUv\" id=\"47nE3z_w6A0\" role=\"1tU5fm\">\n<ref role=\"3uigEE\" to=\"82uw:~Supplier\" resolve=\"Supplier\" />\n<node concept=\"17QB3L\" id=\"47nE3z_w6SI\" role=\"11_B2D\" />\n<node concept=\"3Tm1VV\" id=\"6aRQr1WXtja\" role=\"1B3o_S\" />\n<node concept=\"3clFbS\" id=\"6aRQr1WXtjb\" role=\"3clF47\">\n<node concept=\"XkiVB\" id=\"47nE3z_w6la\" role=\"3cqZAp\">\n- <ref role=\"37wK5l\" to=\"5440:~ReplicatedTree.&lt;init&gt;(org.modelix.model.client.IModelClient,org.modelix.model.lazy.TreeId,java.lang.String,java.util.function.Supplier)\" resolve=\"ReplicatedTree\" />\n+ <ref role=\"37wK5l\" to=\"5440:~ReplicatedTree.&lt;init&gt;(org.modelix.model.client.IModelClient,org.modelix.model.lazy.TreeId,java.lang.String,kotlin.jvm.functions.Function0)\" resolve=\"ReplicatedTree\" />\n<node concept=\"37vLTw\" id=\"47nE3z_w6t2\" role=\"37wK5m\">\n<ref role=\"3cqZAo\" node=\"6aRQr1WXtjz\" resolve=\"client\" />\n</node>\n<node concept=\"37vLTw\" id=\"47nE3z_w6t4\" role=\"37wK5m\">\n<ref role=\"3cqZAo\" node=\"6aRQr1WXvTI\" resolve=\"branchName\" />\n</node>\n- <node concept=\"37vLTw\" id=\"47nE3z_w70Z\" role=\"37wK5m\">\n+ <node concept=\"2ShNRf\" id=\"1ZljNrEtb1h\" role=\"37wK5m\">\n+ <node concept=\"YeOm9\" id=\"1ZljNrEtiYs\" role=\"2ShVmc\">\n+ <node concept=\"1Y3b0j\" id=\"1ZljNrEtiYv\" role=\"YeSDq\">\n+ <property role=\"2bfB8j\" value=\"true\" />\n+ <ref role=\"1Y3XeK\" to=\"ouht:~Function0\" resolve=\"Function0\" />\n+ <ref role=\"37wK5l\" to=\"wyt6:~Object.&lt;init&gt;()\" resolve=\"Object\" />\n+ <node concept=\"3Tm1VV\" id=\"1ZljNrEtiYw\" role=\"1B3o_S\" />\n+ <node concept=\"3clFb_\" id=\"1ZljNrEtiYA\" role=\"jymVt\">\n+ <property role=\"TrG5h\" value=\"invoke\" />\n+ <node concept=\"3Tm1VV\" id=\"1ZljNrEtiYB\" role=\"1B3o_S\" />\n+ <node concept=\"17QB3L\" id=\"1ZljNrEtjkR\" role=\"3clF45\" />\n+ <node concept=\"3clFbS\" id=\"1ZljNrEtiYE\" role=\"3clF47\">\n+ <node concept=\"3clFbF\" id=\"1ZljNrEtj7V\" role=\"3cqZAp\">\n+ <node concept=\"2OqwBi\" id=\"1ZljNrEqcZa\" role=\"3clFbG\">\n+ <node concept=\"37vLTw\" id=\"1ZljNrEqcNx\" role=\"2Oq$k0\">\n<ref role=\"3cqZAo\" node=\"2EzI5qKsi96\" resolve=\"user\" />\n</node>\n+ <node concept=\"liA8E\" id=\"1ZljNrEqdfw\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"82uw:~Supplier.get()\" resolve=\"get\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"2AHcQZ\" id=\"1ZljNrEtiYG\" role=\"2AJF6D\">\n+ <ref role=\"2AI5Lk\" to=\"wyt6:~Override\" resolve=\"Override\" />\n+ </node>\n+ </node>\n+ <node concept=\"17QB3L\" id=\"1ZljNrEtjIg\" role=\"2Ghqu4\" />\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"3clFbF\" id=\"2lKlK7f4DzC\" role=\"3cqZAp\">\n<node concept=\"2OqwBi\" id=\"2lKlK7f4HMy\" role=\"3clFbG\">\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.model.mpsplugin/models/org.modelix.model.mpsplugin.plugin.mps", "new_path": "mps/org.modelix.model.mpsplugin/models/org.modelix.model.mpsplugin.plugin.mps", "diff": "<node concept=\"3uibUv\" id=\"1me6UesGLCX\" role=\"1tU5fm\">\n<ref role=\"3uigEE\" to=\"xkhl:~CLVersion\" resolve=\"CLVersion\" />\n</node>\n- <node concept=\"2YIFZM\" id=\"1me6UesGLDK\" role=\"33vP2m\">\n- <ref role=\"1Pybhc\" to=\"xkhl:~CLVersion\" resolve=\"CLVersion\" />\n- <ref role=\"37wK5l\" to=\"xkhl:~CLVersion.loadFromHash(java.lang.String,org.modelix.model.lazy.IDeserializingKeyValueStore)\" resolve=\"loadFromHash\" />\n- <node concept=\"37vLTw\" id=\"1me6UesGLDL\" role=\"37wK5m\">\n+ <node concept=\"2OqwBi\" id=\"1ZljNrEqerX\" role=\"33vP2m\">\n+ <node concept=\"10M0yZ\" id=\"1ZljNrEqeiX\" role=\"2Oq$k0\">\n+ <ref role=\"1PxDUh\" to=\"xkhl:~CLVersion\" resolve=\"CLVersion\" />\n+ <ref role=\"3cqZAo\" to=\"xkhl:~CLVersion.Companion\" resolve=\"Companion\" />\n+ </node>\n+ <node concept=\"liA8E\" id=\"1ZljNrEqeAx\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"xkhl:~CLVersion$Companion.loadFromHash(java.lang.String,org.modelix.model.lazy.IDeserializingKeyValueStore)\" resolve=\"loadFromHash\" />\n+ <node concept=\"37vLTw\" id=\"1ZljNrEqeEg\" role=\"37wK5m\">\n<ref role=\"3cqZAo\" node=\"1me6UesGJMZ\" resolve=\"versionHash\" />\n</node>\n- <node concept=\"2OqwBi\" id=\"1me6UesGLDM\" role=\"37wK5m\">\n- <node concept=\"37vLTw\" id=\"1me6UesGLDN\" role=\"2Oq$k0\">\n+ <node concept=\"2OqwBi\" id=\"1ZljNrEqeEh\" role=\"37wK5m\">\n+ <node concept=\"37vLTw\" id=\"1ZljNrEqeEi\" role=\"2Oq$k0\">\n<ref role=\"3cqZAo\" node=\"1me6UesGKJ2\" resolve=\"client\" />\n</node>\n- <node concept=\"liA8E\" id=\"1me6UesGLDO\" role=\"2OqNvi\">\n+ <node concept=\"liA8E\" id=\"1ZljNrEqeEj\" role=\"2OqNvi\">\n<ref role=\"37wK5l\" to=\"5440:~IModelClient.getStoreCache()\" resolve=\"getStoreCache\" />\n</node>\n</node>\n</node>\n</node>\n</node>\n+ </node>\n<node concept=\"3clFbF\" id=\"1me6UesGQ5v\" role=\"3cqZAp\">\n<node concept=\"2YIFZM\" id=\"1me6UesGQ8L\" role=\"3clFbG\">\n<ref role=\"37wK5l\" to=\"dxuu:~SwingUtilities.invokeLater(java.lang.Runnable)\" resolve=\"invokeLater\" />\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.model.mpsplugin/models/[email protected]", "new_path": "mps/org.modelix.model.mpsplugin/models/[email protected]", "diff": "</node>\n<node concept=\"2ShNRf\" id=\"7zuOo8oN5Th\" role=\"33vP2m\">\n<node concept=\"1pGfFk\" id=\"7zuOo8oN5Ti\" role=\"2ShVmc\">\n- <ref role=\"37wK5l\" to=\"jks5:~PBranch.&lt;init&gt;(org.modelix.model.api.ITree)\" resolve=\"PBranch\" />\n+ <ref role=\"37wK5l\" to=\"jks5:~PBranch.&lt;init&gt;(org.modelix.model.api.ITree,org.modelix.model.api.IIdGenerator)\" resolve=\"PBranch\" />\n<node concept=\"2ShNRf\" id=\"7zuOo8oN64Q\" role=\"37wK5m\">\n<node concept=\"1pGfFk\" id=\"7zuOo8oN7AS\" role=\"2ShVmc\">\n<ref role=\"37wK5l\" to=\"xkhl:~CLTree.&lt;init&gt;(org.modelix.model.lazy.IDeserializingKeyValueStore)\" resolve=\"CLTree\" />\n</node>\n</node>\n</node>\n+ <node concept=\"2ShNRf\" id=\"1ZljNrEqscW\" role=\"37wK5m\">\n+ <node concept=\"1pGfFk\" id=\"1ZljNrEqxab\" role=\"2ShVmc\">\n+ <ref role=\"37wK5l\" to=\"5440:~IdGenerator.&lt;init&gt;(int)\" resolve=\"IdGenerator\" />\n+ <node concept=\"3cmrfG\" id=\"1ZljNrEq_9l\" role=\"37wK5m\">\n+ <property role=\"3cmrfH\" value=\"1\" />\n+ </node>\n+ </node>\n+ </node>\n</node>\n</node>\n</node>\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Adjusted MPS code to API changes
426,496
07.08.2020 20:18:23
-7,200
e20ee1ab219625dcdf0ece4a388972b98a374a06
Remove experimental API usages
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -54,7 +54,6 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n}\n}\n- @OptIn(ExperimentalStdlibApi::class)\nprotected fun mergeHistory(leftVersionHash: String, rightVersionHash: String): CLVersion {\nval commonBase = commonBaseVersion(leftVersionHash, rightVersionHash)\nval leftHistory = getHistory(leftVersionHash, commonBase)\n@@ -80,7 +79,7 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nval appliedVersionIds: MutableSet<Long> = HashSet()\nwhile (!leftHistory.isEmpty() || !rightHistory.isEmpty()) {\nval useLeft = rightHistory.isEmpty() || !leftHistory.isEmpty() && leftHistory.last().id < rightHistory.last().id\n- val versionToApply = (if (useLeft) leftHistory else rightHistory).removeLast()\n+ val versionToApply = (if (useLeft) leftHistory else rightHistory).let { it.removeAt(it.size - 1) }\nif (appliedVersionIds.contains(versionToApply.id)) {\ncontinue\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPNode.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPNode.kt", "diff": "@@ -27,7 +27,6 @@ import org.modelix.model.util.pmap.COWArrays.set\nimport kotlin.jvm.JvmStatic\nclass CPNode protected constructor(id1: Long, val concept: String?, parentId1: Long, roleInParent1: String?, private val childrenIds: LongArray, val propertyRoles: Array<String>, val propertyValues: Array<String>, val referenceRoles: Array<String>, val referenceTargets: Array<CPElementRef>) : CPElement(id1, parentId1, roleInParent1) {\n- @OptIn(ExperimentalStdlibApi::class)\noverride fun serialize(): String? {\nval sb = StringBuilder()\nsb.append(longToHex(id))\n@@ -38,7 +37,7 @@ class CPNode protected constructor(id1: Long, val concept: String?, parentId1: L\nsb.append(\"/\")\nsb.append(escape(roleInParent))\nsb.append(\"/\")\n- sb.append(childrenIds.map { obj: Long -> longToHex(obj) }.reduceOrNull { a: String, b: String -> \"$a, $b\" } ?: \"\")\n+ sb.append(if (childrenIds.isEmpty()) \"\" else childrenIds.map { obj: Long -> longToHex(obj) }.reduce { a: String, b: String -> \"$a, $b\" })\nsb.append(\"/\")\nvar first = true\nrun {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Remove experimental API usages
426,496
07.08.2020 20:29:26
-7,200
e8ef9e763bfbdf4b27eb0c023de2f42bd1796767
JS implementation for bitCount
[ { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/PlatformSpecific.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/PlatformSpecific.kt", "diff": "@@ -19,7 +19,13 @@ actual fun logDebug(message: () -> String, contextClass: KClass<*>) {\n}\nactual fun bitCount(bits: Int): Int {\n- TODO(\"Not yet implemented\")\n+ var i = bits\n+ i = i - (i ushr 1 and 0x55555555)\n+ i = (i and 0x33333333) + (i ushr 2 and 0x33333333)\n+ i = i + (i ushr 4) and 0x0f0f0f0f\n+ i = i + (i ushr 8)\n+ i = i + (i ushr 16)\n+ return i and 0x3f\n}\nactual fun <K, V> createLRUMap(size: Int): MutableMap<K, V> {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
JS implementation for bitCount
426,504
08.08.2020 17:50:39
-7,200
f28f6c839ff576018ba0f05e0c06e37545384576
support UUID on JS
[ { "change_type": "MODIFY", "old_path": "model-client/build.gradle", "new_path": "model-client/build.gradle", "diff": "@@ -65,6 +65,7 @@ kotlin {\njsMain {\ndependencies {\nimplementation kotlin('stdlib-js')\n+ implementation(npm(\"uuid\", \"^8.3.0\"))\n}\n}\njsTest {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/PlatformSpecific.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/PlatformSpecific.kt", "diff": "@@ -20,18 +20,22 @@ actual fun logDebug(message: () -> String, contextClass: KClass<*>) {\nactual fun bitCount(bits: Int): Int {\nvar i = bits\n- i = i - (i ushr 1 and 0x55555555)\n+ i -= (i ushr 1 and 0x55555555)\ni = (i and 0x33333333) + (i ushr 2 and 0x33333333)\ni = i + (i ushr 4) and 0x0f0f0f0f\n- i = i + (i ushr 8)\n- i = i + (i ushr 16)\n+ i += (i ushr 8)\n+ i += (i ushr 16)\nreturn i and 0x3f\n}\nactual fun <K, V> createLRUMap(size: Int): MutableMap<K, V> {\n- TODO(\"Not yet implemented\")\n+ return HashMap()\n}\n+@JsModule(\"uuid\")\n+@JsNonModule\n+external fun uuidv4() : String\n+\nactual fun randomUUID(): String {\n- TODO(\"Not yet implemented\")\n+ return uuidv4();\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
support UUID on JS
426,504
08.08.2020 18:01:24
-7,200
cba0a726edac3f240770b3e5463e74611f1fb768
initial support for sha256 in JS
[ { "change_type": "MODIFY", "old_path": "model-client/build.gradle", "new_path": "model-client/build.gradle", "diff": "@@ -66,6 +66,7 @@ kotlin {\ndependencies {\nimplementation kotlin('stdlib-js')\nimplementation(npm(\"uuid\", \"^8.3.0\"))\n+ implementation(npm(\"js-sha256\", \"^0.9.0\"))\n}\n}\njsTest {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "diff": "@@ -2,13 +2,20 @@ package org.modelix.model.persistent\nimport kotlin.browser.window\n+@JsNonModule\n+@JsModule(\"js-sha256\")\n+external fun sha256(s: String) : String\n+\n+// Just to avoid having this shadowed in HashUtil...\n+fun wrapperSha256(s: String) = sha256(s)\n+\nactual object HashUtil {\nactual fun sha256(input: ByteArray?): String {\nTODO(\"Not yet implemented\")\n}\nactual fun sha256(input: String): String {\n- TODO(\"Not yet implemented\")\n+ return wrapperSha256(input)\n}\nactual fun isSha256(value: String?): Boolean {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "package org.modelix.model.persistent\n+import kotlin.js.Math\n+\nactual object SerializationUtil {\nactual fun escape(value: String?): String {\nTODO(\"Not yet implemented\")\n@@ -17,9 +19,19 @@ actual object SerializationUtil {\nTODO(\"Not yet implemented\")\n}\n+ /**\n+ * The unsigned integer value is the argument plus 2<sup>32</sup>\n+ * if the argument is negative; otherwise, it is equal to the\n+ * argument. This value is converted to a string of ASCII digits\n+ * in hexadecimal (base&nbsp;16) with no extra leading\n+ * {@code 0}s.\n+ */\nactual fun intToHex(value: Int): String {\n+ if (value < 0) {\nTODO(\"Not yet implemented\")\n}\n+ return value.toString(16)\n+ }\nactual fun intFromHex(hex: String): Int {\nTODO(\"Not yet implemented\")\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "@@ -55,7 +55,7 @@ actual object SerializationUtil {\nif (str == null) {\nreturn \"\"\n}\n- if (str.length == 0) {\n+ if (str.isEmpty()) {\nthrow RuntimeException(\"Empty string not allowed\")\n}\nreturn str\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
initial support for sha256 in JS
426,504
08.08.2020 18:04:17
-7,200
6b1aa8b03ab847870ac499a9e260363ad205309b
initial conversion number <-> hex
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/NonBulkQuery.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/NonBulkQuery.kt", "diff": "@@ -26,7 +26,7 @@ class NonBulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery\n}\noverride fun <T> get(hash: String, deserializer: (String) -> T): IBulkQuery.Value<T?> {\n- return constant(store.get(hash, deserializer)!!)\n+ return constant(store[hash, deserializer] ?: throw RuntimeException(\"store expected to have entry for hash=$hash, deserializer=$deserializer\"))\n}\nclass Value<T>(private val value: T) : IBulkQuery.Value<T> {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPHamtNode.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPHamtNode.kt", "diff": "@@ -27,18 +27,22 @@ abstract class CPHamtNode {\n@JvmStatic\nfun deserialize(input: String): CPHamtNode {\nval parts = input.split(\"/\").dropLastWhile { it.isEmpty() }.toTypedArray()\n- return if (\"L\" == parts[0]) {\n+ return when {\n+ \"L\" == parts[0] -> {\nCPHamtLeaf(longFromHex(parts[1]), parts[2])\n- } else if (\"I\" == parts[0]) {\n+ }\n+ \"I\" == parts[0] -> {\nCPHamtInternal(\nintFromHex(parts[1]),\nparts[2].split(\",\")\n.filter { it: String? -> it != null && it.length > 0 }\n.toTypedArray()\n)\n- } else {\n+ }\n+ else -> {\nthrow RuntimeException(\"Unknown type: \" + parts[0] + \", input: \" + input)\n}\n}\n}\n}\n+}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "@@ -12,11 +12,11 @@ actual object SerializationUtil {\n}\nactual fun longToHex(value: Long): String {\n- TODO(\"Not yet implemented\")\n+ return value.toString(16)\n}\nactual fun longFromHex(hex: String): Long {\n- TODO(\"Not yet implemented\")\n+ return hex.toLong(16)\n}\n/**\n@@ -34,7 +34,7 @@ actual object SerializationUtil {\n}\nactual fun intFromHex(hex: String): Int {\n- TODO(\"Not yet implemented\")\n+ return hex.toInt()\n}\nactual fun nullAsEmptyString(str: String?): String {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
initial conversion number <-> hex
426,496
08.08.2020 20:47:42
-7,200
1af6452fb4f4084d49d0e221f8c6e4a0f61ebc24
Added tests for SerializationUtil
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "@@ -23,5 +23,5 @@ expect object SerializationUtil {\nfun intToHex(value: Int): String\nfun intFromHex(hex: String): Int\nfun nullAsEmptyString(str: String?): String\n- fun emptyStringAsNull(str: String?): String?\n+ fun emptyStringAsNull(str: String): String?\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_intHex_Test.kt", "diff": "+package org.modelix.model\n+\n+import org.modelix.model.persistent.SerializationUtil\n+import kotlin.test.Test\n+import kotlin.test.assertEquals\n+\n+class SerializationUtil_intHex_Test {\n+\n+ @Test\n+ fun intToHex_maxValue() {\n+ assertEquals(\"7fffffff\", SerializationUtil.intToHex(Int.MAX_VALUE))\n+ }\n+\n+ @Test\n+ fun intFromHex_maxValue() {\n+ assertEquals(Int.MAX_VALUE, SerializationUtil.intFromHex(\"7fffffff\"))\n+ }\n+\n+ @Test\n+ fun intToHex_minValue() {\n+ assertEquals(\"80000000\", SerializationUtil.intToHex(Int.MIN_VALUE))\n+ }\n+\n+ @Test\n+ fun intFromHex_minValue() {\n+ assertEquals(Int.MIN_VALUE, SerializationUtil.intFromHex(\"80000000\"))\n+ }\n+\n+ @Test\n+ fun intToHex_minus1() {\n+ assertEquals(\"ffffffff\", SerializationUtil.intToHex(-1))\n+ }\n+\n+ @Test\n+ fun intFromHex_minus1() {\n+ assertEquals(-1, SerializationUtil.intFromHex(\"ffffffff\"))\n+ }\n+\n+ @Test\n+ fun intToHex_0() {\n+ assertEquals(\"0\", SerializationUtil.intToHex(0))\n+ }\n+\n+ @Test\n+ fun intFromHex_0() {\n+ assertEquals(0, SerializationUtil.intFromHex(\"0\"))\n+ }\n+\n+ @Test\n+ fun intToHex_1() {\n+ assertEquals(\"1\", SerializationUtil.intToHex(1))\n+ }\n+\n+ @Test\n+ fun intFromHex_1() {\n+ assertEquals(1, SerializationUtil.intFromHex(\"1\"))\n+ }\n+\n+ @Test\n+ fun intToHex_msb() {\n+ assertEquals(\"80000000\", SerializationUtil.intToHex(1 shl 31))\n+ }\n+\n+ @Test\n+ fun intFromHex_msb() {\n+ assertEquals(1 shl 31, SerializationUtil.intFromHex(\"80000000\"))\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_longHex_Test.kt", "diff": "+package org.modelix.model\n+\n+import org.modelix.model.persistent.SerializationUtil\n+import kotlin.test.Test\n+import kotlin.test.assertEquals\n+\n+class SerializationUtil_longHex_Test {\n+\n+ @Test\n+ fun longToHex_maxValue() {\n+ assertEquals(\"7fffffffffffffff\", SerializationUtil.longToHex(Long.MAX_VALUE))\n+ }\n+\n+ @Test\n+ fun longFromHex_maxValue() {\n+ assertEquals(Long.MAX_VALUE, SerializationUtil.longFromHex(\"7fffffffffffffff\"))\n+ }\n+\n+ @Test\n+ fun longToHex_minValue() {\n+ assertEquals(\"8000000000000000\", SerializationUtil.longToHex(Long.MIN_VALUE))\n+ }\n+\n+ @Test\n+ fun longFromHex_minValue() {\n+ assertEquals(Long.MIN_VALUE, SerializationUtil.longFromHex(\"8000000000000000\"))\n+ }\n+\n+ @Test\n+ fun longToHex_minus1() {\n+ assertEquals(\"ffffffffffffffff\", SerializationUtil.longToHex(-1L))\n+ }\n+\n+ @Test\n+ fun longFromHex_minus1() {\n+ assertEquals(-1L, SerializationUtil.longFromHex(\"ffffffffffffffff\"))\n+ }\n+\n+ @Test\n+ fun longToHex_0() {\n+ assertEquals(\"0\", SerializationUtil.longToHex(0))\n+ }\n+\n+ @Test\n+ fun longFromHex_0() {\n+ assertEquals(0, SerializationUtil.longFromHex(\"0\"))\n+ }\n+ @Test\n+ fun longToHex_1() {\n+ assertEquals(\"1\", SerializationUtil.longToHex(1))\n+ }\n+\n+ @Test\n+ fun longFromHex_1() {\n+ assertEquals(1, SerializationUtil.longFromHex(\"1\"))\n+ }\n+\n+ @Test\n+ fun longToHex_msb() {\n+ assertEquals(\"8000000000000000\", SerializationUtil.longToHex(1L shl 63))\n+ }\n+\n+ @Test\n+ fun longFromHex_msb() {\n+ assertEquals(1L shl 63, SerializationUtil.longFromHex(\"8000000000000000\"))\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_nullEmptyString.kt", "diff": "+package org.modelix.model\n+\n+import org.modelix.model.persistent.SerializationUtil\n+import kotlin.test.Test\n+import kotlin.test.assertEquals\n+import kotlin.test.assertFails\n+\n+class SerializationUtil_nullEmptyString {\n+ @Test\n+ fun nullAsEmptyString_null() {\n+ assertEquals(\"\", SerializationUtil.nullAsEmptyString(null))\n+ }\n+\n+ @Test\n+ fun nullAsEmptyString_emptyString() {\n+ assertFails { SerializationUtil.nullAsEmptyString(\"\") }\n+ }\n+\n+ @Test\n+ fun emptyStringAsNull_emptyString() {\n+ assertEquals(null, SerializationUtil.emptyStringAsNull(\"\"))\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "package org.modelix.model.persistent\n-import kotlin.js.Math\n-\nactual object SerializationUtil {\nactual fun escape(value: String?): String {\nTODO(\"Not yet implemented\")\n@@ -41,7 +39,7 @@ actual object SerializationUtil {\nTODO(\"Not yet implemented\")\n}\n- actual fun emptyStringAsNull(str: String?): String? {\n+ actual fun emptyStringAsNull(str: String): String? {\nTODO(\"Not yet implemented\")\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "@@ -61,7 +61,7 @@ actual object SerializationUtil {\nreturn str\n}\n- actual fun emptyStringAsNull(str: String?): String? {\n+ actual fun emptyStringAsNull(str: String): String? {\nreturn if (str == null || str.length == 0) null else str\n}\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Added tests for SerializationUtil
426,496
08.08.2020 21:04:01
-7,200
1027bf093c88a0cb9345356b1b0280df2fb24091
'Continuation indent' in IntelliJ changed to 4 to make ktlint happy
[ { "change_type": "ADD", "old_path": null, "new_path": ".idea/codeStyles/Project.xml", "diff": "+<component name=\"ProjectCodeStyleConfiguration\">\n+ <code_scheme name=\"Project\" version=\"173\">\n+ <JavaCodeStyleSettings>\n+ <option name=\"CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND\" value=\"100\" />\n+ <option name=\"NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND\" value=\"100\" />\n+ </JavaCodeStyleSettings>\n+ <codeStyleSettings language=\"kotlin\">\n+ <indentOptions>\n+ <option name=\"CONTINUATION_INDENT_SIZE\" value=\"4\" />\n+ </indentOptions>\n+ </codeStyleSettings>\n+ </code_scheme>\n+</component>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".idea/codeStyles/codeStyleConfig.xml", "diff": "+<component name=\"ProjectCodeStyleConfiguration\">\n+ <state>\n+ <option name=\"USE_PER_PROJECT_SETTINGS\" value=\"true\" />\n+ </state>\n+</component>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPHamtNode.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPHamtNode.kt", "diff": "@@ -24,6 +24,7 @@ abstract class CPHamtNode {\ncompanion object {\nval DESERIALIZER = { s: String -> deserialize(s) }\n+\n@JvmStatic\nfun deserialize(input: String): CPHamtNode {\nval parts = input.split(\"/\").dropLastWhile { it.isEmpty() }.toTypedArray()\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/PlatformSpecific.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/PlatformSpecific.kt", "diff": "@@ -37,5 +37,5 @@ actual fun <K, V> createLRUMap(size: Int): MutableMap<K, V> {\nexternal fun uuidv4(): String\nactual fun randomUUID(): String {\n- return uuidv4();\n+ return uuidv4()\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
'Continuation indent' in IntelliJ changed to 4 to make ktlint happy
426,496
08.08.2020 22:54:41
-7,200
674d0d4ef46e57fe1e68dcc664f0f5905064d7a7
Adjusted the MPS code to API changes in model-client
[ { "change_type": "MODIFY", "old_path": "mps/org.modelix.build/models/org.modelix.build.mps", "new_path": "mps/org.modelix.build/models/org.modelix.build.mps", "diff": "</node>\n</node>\n</node>\n- <node concept=\"1SiIV0\" id=\"JSgV4jSLXm\" role=\"3bR37C\">\n- <node concept=\"1BurEX\" id=\"JSgV4jSLXn\" role=\"1SiIV1\">\n- <node concept=\"398BVA\" id=\"JSgV4jSLXd\" role=\"1BurEY\">\n- <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n- <node concept=\"2Ry0Ak\" id=\"JSgV4jSLXe\" role=\"iGT6I\">\n- <property role=\"2Ry0Am\" value=\"org.modelix.model.client\" />\n- <node concept=\"2Ry0Ak\" id=\"JSgV4jSLXf\" role=\"2Ry0An\">\n- <property role=\"2Ry0Am\" value=\"lib\" />\n- <node concept=\"2Ry0Ak\" id=\"JSgV4jSLXg\" role=\"2Ry0An\">\n- <property role=\"2Ry0Am\" value=\"model-client-2020.1-SNAPSHOT.jar\" />\n- </node>\n- </node>\n- </node>\n- </node>\n- </node>\n- </node>\n<node concept=\"1SiIV0\" id=\"1yReInHWaw\" role=\"3bR37C\">\n<node concept=\"1BurEX\" id=\"1yReInHWax\" role=\"1SiIV1\">\n<node concept=\"398BVA\" id=\"1yReInHWan\" role=\"1BurEY\">\n<ref role=\"3bR37D\" to=\"ffeo:44LXwdzyvTi\" resolve=\"Annotations\" />\n</node>\n</node>\n+ <node concept=\"1SiIV0\" id=\"1ZljNrEvDPP\" role=\"3bR37C\">\n+ <node concept=\"1BurEX\" id=\"1ZljNrEvDPQ\" role=\"1SiIV1\">\n+ <node concept=\"398BVA\" id=\"1ZljNrEvDPG\" role=\"1BurEY\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDPH\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.model.client\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDPI\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"lib\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDPJ\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"kotlin-stdlib-jdk7-1.3.72.jar\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"1SiIV0\" id=\"1ZljNrEvDQ0\" role=\"3bR37C\">\n+ <node concept=\"1BurEX\" id=\"1ZljNrEvDQ1\" role=\"1SiIV1\">\n+ <node concept=\"398BVA\" id=\"1ZljNrEvDPR\" role=\"1BurEY\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDPS\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.model.client\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDPT\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"lib\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDPU\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"kotlin-stdlib-jdk8-1.3.72.jar\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"1SiIV0\" id=\"1ZljNrEvDQk\" role=\"3bR37C\">\n+ <node concept=\"1BurEX\" id=\"1ZljNrEvDQl\" role=\"1SiIV1\">\n+ <node concept=\"398BVA\" id=\"1ZljNrEvDQb\" role=\"1BurEY\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDQc\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.model.client\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDQd\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"lib\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDQe\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"model-client-js-2020.1-SNAPSHOT.jar\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"1SiIV0\" id=\"1ZljNrEvDQC\" role=\"3bR37C\">\n+ <node concept=\"1BurEX\" id=\"1ZljNrEvDQD\" role=\"1SiIV1\">\n+ <node concept=\"398BVA\" id=\"1ZljNrEvDQv\" role=\"1BurEY\">\n+ <ref role=\"398BVh\" node=\"3$7Kuaihl5X\" resolve=\"modelix.modules\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDQw\" role=\"iGT6I\">\n+ <property role=\"2Ry0Am\" value=\"org.modelix.model.client\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDQx\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"lib\" />\n+ <node concept=\"2Ry0Ak\" id=\"1ZljNrEvDQy\" role=\"2Ry0An\">\n+ <property role=\"2Ry0Am\" value=\"model-client-metadata-2020.1-SNAPSHOT.jar\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n</node>\n<node concept=\"1E1JtA\" id=\"7gF2HTviNPs\" role=\"2G$12L\">\n<property role=\"BnDLt\" value=\"true\" />\n<node concept=\"3LEDTy\" id=\"7BujJjYSJ9v\" role=\"3LEDUa\">\n<ref role=\"3LEDTV\" node=\"7gF2HTviNPn\" resolve=\"org.modelix.ui.sm\" />\n</node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRi\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L0h\" resolve=\"jetbrains.mps.baseLanguage.collections\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRj\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:14x5$qAUbkb\" resolve=\"jetbrains.mps.lang.access\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRk\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:4iIKqJTZ5Hs\" resolve=\"de.q60.mps.polymorphicfunctions\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRl\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZ0\" resolve=\"jetbrains.mps.baseLanguageInternal\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRm\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KYb\" resolve=\"jetbrains.mps.baseLanguage\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRn\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L2l\" resolve=\"jetbrains.mps.baseLanguage.logging\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRo\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L2F\" resolve=\"jetbrains.mps.baseLanguage.tuples\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRp\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L4j\" resolve=\"jetbrains.mps.lang.actions\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRq\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:4iIKqJTZ5HO\" resolve=\"de.q60.mps.shadowmodels.transformation\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRr\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:7c10t$7lQIA\" resolve=\"de.q60.mps.shadowmodels.gen.typesystem\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRs\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:2$QnGbtLXzL\" resolve=\"de.q60.mps.shadowmodels.gen.desugar\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRt\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZG\" resolve=\"jetbrains.mps.baseLanguage.closures\" />\n- </node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRu\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L9O\" resolve=\"jetbrains.mps.lang.smodel\" />\n+ <node concept=\"3LEDTy\" id=\"1ZljNrEvDS3\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6L9c\" resolve=\"jetbrains.mps.lang.quotation\" />\n</node>\n- <node concept=\"3LEDTy\" id=\"1yReInSBRv\" role=\"3LEDUa\">\n- <ref role=\"3LEDTV\" to=\"90a9:4iIKqJTZ5Hg\" resolve=\"de.q60.mps.shadowmodels.gen.afterPF\" />\n+ <node concept=\"3LEDTy\" id=\"1ZljNrEvDS4\" role=\"3LEDUa\">\n+ <ref role=\"3LEDTV\" to=\"ffeo:7Kfy9QB6KZc\" resolve=\"jetbrains.mps.baseLanguage.checkedDots\" />\n</node>\n</node>\n<node concept=\"1E1JtD\" id=\"7BujJjXYVmv\" role=\"2G$12L\">\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.model.client/org.modelix.model.client.msd", "new_path": "mps/org.modelix.model.client/org.modelix.model.client.msd", "diff": "<sourceRoot location=\"jersey-media-jaxb-2.31.jar\" />\n<sourceRoot location=\"jersey-media-sse-2.31.jar\" />\n<sourceRoot location=\"jersey-server-2.31.jar\" />\n- <sourceRoot location=\"model-client-2020.1-SNAPSHOT.jar\" />\n<sourceRoot location=\"model-client-jvm-2020.1-SNAPSHOT.jar\" />\n<sourceRoot location=\"kotlin-stdlib-jdk7-1.3.72.jar\" />\n<sourceRoot location=\"kotlin-stdlib-jdk8-1.3.72.jar\" />\n</facet>\n</facets>\n<stubModelEntries>\n- <stubModelEntry path=\"${module}/lib/annotations-13.0.jar\" />\n<stubModelEntry path=\"${module}/lib/aopalliance-repackaged-2.6.1.jar\" />\n<stubModelEntry path=\"${module}/lib/checker-qual-2.11.1.jar\" />\n<stubModelEntry path=\"${module}/lib/commons-collections4-4.4.jar\" />\n<stubModelEntry path=\"${module}/lib/kotlin-stdlib-jdk7-1.3.72.jar\" />\n<stubModelEntry path=\"${module}/lib/kotlin-stdlib-jdk8-1.3.72.jar\" />\n<stubModelEntry path=\"${module}/lib/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar\" />\n- <stubModelEntry path=\"${module}/lib/log4j-1.2.17.jar\" />\n- <stubModelEntry path=\"${module}/lib/model-client-2020.1-SNAPSHOT.jar\" />\n<stubModelEntry path=\"${module}/lib/model-client-js-2020.1-SNAPSHOT.jar\" />\n<stubModelEntry path=\"${module}/lib/model-client-jvm-2020.1-SNAPSHOT.jar\" />\n<stubModelEntry path=\"${module}/lib/model-client-metadata-2020.1-SNAPSHOT.jar\" />\n" }, { "change_type": "MODIFY", "old_path": "mps/org.modelix.ui.sm/models/org.modelix.ui.sm.transformations.mps", "new_path": "mps/org.modelix.ui.sm/models/org.modelix.ui.sm.transformations.mps", "diff": "<ref role=\"027oj\" to=\"70w2:AkkmJBUItt\" resolve=\"id\" />\n<node concept=\"3cpWs3\" id=\"7trMQm3aBIR\" role=\"027of\">\n<node concept=\"2YIFZM\" id=\"5npwda7V6po\" role=\"3uHU7w\">\n- <ref role=\"1Pybhc\" to=\"geos:~HashUtil\" resolve=\"HashUtil\" />\n- <ref role=\"37wK5l\" to=\"geos:~HashUtil.sha256(java.lang.String)\" resolve=\"sha256\" />\n+ <ref role=\"1Pybhc\" node=\"62_qJBxL8mp\" resolve=\"Util\" />\n+ <ref role=\"37wK5l\" node=\"5Q16xz4K4FF\" resolve=\"sha256\" />\n<node concept=\"2YIFZM\" id=\"5npwda7V5nt\" role=\"37wK5m\">\n<ref role=\"37wK5l\" to=\"qsto:5T6M7OO0vKo\" resolve=\"serialize\" />\n<ref role=\"1Pybhc\" to=\"qsto:5T6M7ON4Si7\" resolve=\"NodeReferenceSerializer\" />\n<property role=\"Xl_RC\" value=\"svgNodeEditor_\" />\n</node>\n<node concept=\"2YIFZM\" id=\"5npwda7V7fe\" role=\"3uHU7w\">\n- <ref role=\"1Pybhc\" to=\"geos:~HashUtil\" resolve=\"HashUtil\" />\n- <ref role=\"37wK5l\" to=\"geos:~HashUtil.sha256(java.lang.String)\" resolve=\"sha256\" />\n+ <ref role=\"1Pybhc\" node=\"62_qJBxL8mp\" resolve=\"Util\" />\n+ <ref role=\"37wK5l\" node=\"5Q16xz4K4FF\" resolve=\"sha256\" />\n<node concept=\"2YIFZM\" id=\"5npwda7V7ff\" role=\"37wK5m\">\n<ref role=\"1Pybhc\" to=\"qsto:5T6M7ON4Si7\" resolve=\"NodeReferenceSerializer\" />\n<ref role=\"37wK5l\" to=\"qsto:5T6M7OO0vKo\" resolve=\"serialize\" />\n</node>\n</node>\n<node concept=\"3clFbS\" id=\"AkkmJBUK1X\" role=\"3clF47\">\n- <node concept=\"3clFbF\" id=\"3c6J_2nDJs4\" role=\"3cqZAp\">\n- <node concept=\"2YIFZM\" id=\"3c6J_2nDJYE\" role=\"3clFbG\">\n- <ref role=\"1Pybhc\" to=\"geos:~HashUtil\" resolve=\"HashUtil\" />\n- <ref role=\"37wK5l\" to=\"geos:~HashUtil.sha256(java.lang.String)\" resolve=\"sha256\" />\n- <node concept=\"2YIFZM\" id=\"3c6J_2nDJZz\" role=\"37wK5m\">\n- <ref role=\"37wK5l\" to=\"qsto:5T6M7OO0vKo\" resolve=\"serialize\" />\n+ <node concept=\"3clFbF\" id=\"5Q16xz4JFpC\" role=\"3cqZAp\">\n+ <node concept=\"1rXfSq\" id=\"5Q16xz4K6fL\" role=\"3clFbG\">\n+ <ref role=\"37wK5l\" node=\"5Q16xz4K4FF\" resolve=\"sha256\" />\n+ <node concept=\"2YIFZM\" id=\"5Q16xz4JFJ2\" role=\"37wK5m\">\n<ref role=\"1Pybhc\" to=\"qsto:5T6M7ON4Si7\" resolve=\"NodeReferenceSerializer\" />\n- <node concept=\"37vLTw\" id=\"3c6J_2nDJZ$\" role=\"37wK5m\">\n+ <ref role=\"37wK5l\" to=\"qsto:5T6M7OO0vKo\" resolve=\"serialize\" />\n+ <node concept=\"37vLTw\" id=\"5Q16xz4JFJ3\" role=\"37wK5m\">\n<ref role=\"3cqZAo\" node=\"AkkmJBUKrH\" resolve=\"node\" />\n</node>\n</node>\n<node concept=\"17QB3L\" id=\"AkkmJBUKwm\" role=\"3clF45\" />\n<node concept=\"3Tm1VV\" id=\"AkkmJBUK1W\" role=\"1B3o_S\" />\n</node>\n+ <node concept=\"2tJIrI\" id=\"5Q16xz4JVD$\" role=\"jymVt\" />\n+ <node concept=\"2YIFZL\" id=\"5Q16xz4K4FF\" role=\"jymVt\">\n+ <property role=\"TrG5h\" value=\"sha256\" />\n+ <node concept=\"3clFbS\" id=\"5Q16xz4JWPi\" role=\"3clF47\">\n+ <node concept=\"3clFbF\" id=\"5Q16xz4K3uL\" role=\"3cqZAp\">\n+ <node concept=\"2OqwBi\" id=\"5Q16xz4K3uN\" role=\"3clFbG\">\n+ <node concept=\"10M0yZ\" id=\"5Q16xz4K3uO\" role=\"2Oq$k0\">\n+ <ref role=\"1PxDUh\" to=\"geos:~HashUtil\" resolve=\"HashUtil\" />\n+ <ref role=\"3cqZAo\" to=\"geos:~HashUtil.INSTANCE\" resolve=\"INSTANCE\" />\n+ </node>\n+ <node concept=\"liA8E\" id=\"5Q16xz4K3uP\" role=\"2OqNvi\">\n+ <ref role=\"37wK5l\" to=\"geos:~HashUtil.sha256(java.lang.String)\" resolve=\"sha256\" />\n+ <node concept=\"37vLTw\" id=\"5Q16xz4K4bx\" role=\"37wK5m\">\n+ <ref role=\"3cqZAo\" node=\"5Q16xz4K12p\" resolve=\"input\" />\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ </node>\n+ <node concept=\"37vLTG\" id=\"5Q16xz4K12p\" role=\"3clF46\">\n+ <property role=\"TrG5h\" value=\"input\" />\n+ <node concept=\"17QB3L\" id=\"5Q16xz4K2yZ\" role=\"1tU5fm\" />\n+ </node>\n+ <node concept=\"17QB3L\" id=\"5Q16xz4K0b3\" role=\"3clF45\" />\n+ <node concept=\"3Tm1VV\" id=\"5Q16xz4JWPh\" role=\"1B3o_S\" />\n+ </node>\n<node concept=\"2tJIrI\" id=\"1HMbik_C7lp\" role=\"jymVt\" />\n<node concept=\"2YIFZL\" id=\"1HMbik_ChJa\" role=\"jymVt\">\n<property role=\"TrG5h\" value=\"findConceptEditor\" />\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Adjusted the MPS code to API changes in model-client
426,496
08.08.2020 23:01:16
-7,200
4081a083726f54637f689404891397546767dd08
Move MPS specific build configuration to a subproject
[ { "change_type": "MODIFY", "old_path": "build.gradle", "new_path": "build.gradle", "diff": "-import de.itemis.mps.gradle.BuildLanguages\n-import de.itemis.mps.gradle.RunAntScript\n-import de.itemis.mps.gradle.GenerateLibrariesXml\n-import de.itemis.mps.gradle.TestLanguages\n+\nbuildscript {\next.kotlinVersion = '1.3.72'\n@@ -20,17 +17,10 @@ buildscript {\n}\nplugins {\n- id \"java\"\n- id \"org.jetbrains.kotlin.multiplatform\" version \"${kotlinVersion}\"\n- id \"org.jlleitschuh.gradle.ktlint\" version \"9.3.0\"\n- id \"com.diffplug.gradle.spotless\" version \"4.5.1\"\n- id \"com.jfrog.bintray\" version \"1.8.5\"\n-}\n-\n-\n-\n-configurations {\n- ktlint\n+ id \"org.jetbrains.kotlin.multiplatform\" version \"${kotlinVersion}\" apply false\n+ id \"org.jlleitschuh.gradle.ktlint\" version \"9.3.0\" apply false\n+ id \"com.diffplug.gradle.spotless\" version \"4.5.1\" apply false\n+ id \"com.jfrog.bintray\" version \"1.8.5\" apply false\n}\nallprojects {\n@@ -46,111 +36,5 @@ allprojects {\n}\ndescription = \"Cloud storage and web UI for MPS\"\n-sourceCompatibility = 11\n-targetCompatibility = 11\n-\ndefaultTasks 'assemble'\n-File scriptFile(String relativePath) {\n- new File(\"$rootDir/build/$relativePath\")\n-}\n-\n-//define directories\n-ext.artifactsDir = new File(rootDir, 'artifacts')\n-ext.libsDir = new File(rootDir, 'libs')\n-ext.mpsDir = new File(artifactsDir, 'mps')\n-\n-configurations {\n- ant_lib\n- mps\n- mpsArtifacts\n- libs\n-}\n-\n-ext.mpsVersion = '2020.1.1'\n-\n-dependencies {\n- ant_lib \"org.apache.ant:ant-junit:1.10.1\"\n- mps \"com.jetbrains:mps:$mpsVersion\"\n- mpsArtifacts \"de.itemis.mps:extensions:2020.1+\"\n- libs \"de.itemis.mps.build.example:javalib:1.0+\"\n- libs \"org.jdom:jdom:2.0.2\"\n- project (':ui-client')\n- project (':model-server')\n-}\n-\n-task generateLibrariesXml(type: GenerateLibrariesXml) {\n- description \"Will read project libraries from projectlibraries.properties and generate libraries.xml in .mps directory. Libraries are loaded in mps during start.\"\n- defaults rootProject.file('projectlibraries.properties')\n- destination file('code/.mps/libraries.xml')\n- overrides rootProject.file('projectlibraries.overrides.properties')\n-}\n-\n-task resolveLibs(type: Copy) {\n- doFirst {\n- delete libsDirectory\n- }\n- from {\n- configurations.libs.resolve()\n- }\n- into libsDirectory\n-}\n-\n-\n-task resolveMps(type: Copy) {\n- from {\n- configurations.mps.resolve().collect { zipTree(it) }\n- }\n- into mpsDir\n-}\n-\n-\n-task resolveMpsArtifacts(type: Copy) {\n- from {\n- configurations.mpsArtifacts.resolve().collect { zipTree(it) }\n- }\n- into artifactsDir\n-}\n-\n-task setup {\n- // We resolve MPS not for the users to use it but for the distribution packaging script to be able to refer to it.\n- dependsOn resolveMpsArtifacts\n- dependsOn generateLibrariesXml\n- description 'Set up MPS project libraries. Libraries are read in from projectlibraries.properties file.'\n-}\n-\n-ext.defaultAntScriptArgs = [\n- '-Dproject.home=' + file(rootDir).getAbsolutePath(),\n- '-Dmps.home=' + mpsDir.getAbsolutePath(),\n- '-Dartifacts.root=' + new File(rootDir, 'artifacts')\n-]\n-ext.buildScriptClasspath = project.configurations.ant_lib.fileCollection({ true })\n-\n-task generateMpsBuildScript(type: BuildLanguages, dependsOn: [resolveMps, resolveMpsArtifacts]) {\n- scriptArgs = defaultAntScriptArgs\n- scriptClasspath = buildScriptClasspath\n- script new File(\"$rootDir/build-scripts.xml\")\n-}\n-\n-task buildMpsModules(\n- type: BuildLanguages,\n- dependsOn: [\n- generateMpsBuildScript,\n- resolveMps,\n- resolveMpsArtifacts,\n- ':ui-client:packageNpmApp',\n- ':model-client:copyModelClientToMps'\n- ]) {\n- scriptArgs = defaultAntScriptArgs\n- description = \"Build all MPS language\"\n- scriptClasspath = buildScriptClasspath\n- script new File(\"$rootDir/build/org.modelix/build.xml\")\n-}\n-\n-assemble.dependsOn(buildMpsModules)\n-\n-task runMpsTests(type: TestLanguages, dependsOn: buildMpsModules) {\n- scriptArgs = defaultAntScriptArgs\n- scriptClasspath = buildScriptClasspath\n- script new File(\"$rootDir/build/test.org.modelix/build-tests.xml\")\n-}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/build.gradle", "new_path": "model-client/build.gradle", "diff": "plugins {\n- id 'java'\nid 'maven-publish'\nid 'org.jetbrains.kotlin.multiplatform'\nid \"com.diffplug.gradle.spotless\"\nid \"org.jlleitschuh.gradle.ktlint\"\n}\n+configurations {\n+ ktlint\n+}\n+\ntasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {\nkotlinOptions {\njvmTarget = \"11\"\n@@ -19,7 +22,6 @@ ktlint {\ncheck.dependsOn ktlintCheck\n-\nkotlin {\njvm()\njs {\n" }, { "change_type": "MODIFY", "old_path": "mps/build.gradle", "new_path": "mps/build.gradle", "diff": "+import de.itemis.mps.gradle.BuildLanguages\n+import de.itemis.mps.gradle.RunAntScript\n+import de.itemis.mps.gradle.GenerateLibrariesXml\n+import de.itemis.mps.gradle.TestLanguages\n+\n+plugins {\n+ id \"java\"\n+}\n+\n+configurations {\n+ ant_lib\n+ mps\n+ mpsArtifacts\n+ libs\n+}\n+\n+File scriptFile(String relativePath) {\n+ new File(\"$rootDir/build/$relativePath\")\n+}\n+\n+ext.artifactsDir = new File(rootDir, 'artifacts')\n+ext.libsDir = new File(rootDir, 'libs')\n+ext.mpsDir = new File(artifactsDir, 'mps')\n+\n+ext.mpsVersion = '2020.1.1'\n+\n+dependencies {\n+ ant_lib \"org.apache.ant:ant-junit:1.10.1\"\n+ mps \"com.jetbrains:mps:$mpsVersion\"\n+ mpsArtifacts \"de.itemis.mps:extensions:2020.1+\"\n+ libs \"de.itemis.mps.build.example:javalib:1.0+\"\n+ libs \"org.jdom:jdom:2.0.2\"\n+ project (':ui-client')\n+ project (':model-server')\n+}\n+\n+task generateLibrariesXml(type: GenerateLibrariesXml) {\n+ description \"Will read project libraries from projectlibraries.properties and generate libraries.xml in .mps directory. Libraries are loaded in mps during start.\"\n+ defaults rootProject.file('projectlibraries.properties')\n+ destination file('code/.mps/libraries.xml')\n+ overrides rootProject.file('projectlibraries.overrides.properties')\n+}\n+\n+task resolveLibs(type: Copy) {\n+ doFirst {\n+ delete libsDirectory\n+ }\n+ from {\n+ configurations.libs.resolve()\n+ }\n+ into libsDirectory\n+}\n+\n+task resolveMps(type: Copy) {\n+ from {\n+ configurations.mps.resolve().collect { zipTree(it) }\n+ }\n+ into mpsDir\n+}\n+\n+task resolveMpsArtifacts(type: Copy) {\n+ from {\n+ configurations.mpsArtifacts.resolve().collect { zipTree(it) }\n+ }\n+ into artifactsDir\n+}\n+\n+task setup {\n+ // We resolve MPS not for the users to use it but for the distribution packaging script to be able to refer to it.\n+ dependsOn resolveMpsArtifacts\n+ dependsOn generateLibrariesXml\n+ description 'Set up MPS project libraries. Libraries are read in from projectlibraries.properties file.'\n+}\n+\n+ext.defaultAntScriptArgs = [\n+ '-Dproject.home=' + file(rootDir).getAbsolutePath(),\n+ '-Dmps.home=' + mpsDir.getAbsolutePath(),\n+ '-Dartifacts.root=' + new File(rootDir, 'artifacts')\n+]\n+ext.buildScriptClasspath = project.configurations.ant_lib.fileCollection({ true })\n+\n+task generateMpsBuildScript(type: BuildLanguages, dependsOn: [resolveMps, resolveMpsArtifacts]) {\n+ scriptArgs = defaultAntScriptArgs\n+ scriptClasspath = buildScriptClasspath\n+ script new File(\"$rootDir/build-scripts.xml\")\n+}\n+\n+task buildMpsModules(\n+ type: BuildLanguages,\n+ dependsOn: [\n+ generateMpsBuildScript,\n+ resolveMps,\n+ resolveMpsArtifacts,\n+ ':ui-client:packageNpmApp',\n+ ':model-client:copyModelClientToMps'\n+ ]) {\n+ scriptArgs = defaultAntScriptArgs\n+ description = \"Build all MPS language\"\n+ scriptClasspath = buildScriptClasspath\n+ script new File(\"$rootDir/build/org.modelix/build.xml\")\n+}\n+\n+assemble.dependsOn(buildMpsModules)\n+\n+task runMpsTests(type: TestLanguages, dependsOn: buildMpsModules) {\n+ scriptArgs = defaultAntScriptArgs\n+ scriptClasspath = buildScriptClasspath\n+ script new File(\"$rootDir/build/test.org.modelix/build-tests.xml\")\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Move MPS specific build configuration to a subproject
426,496
08.08.2020 23:12:15
-7,200
aa53cb9b3c44233c0c215cc49a9591299f264403
Remove modules configured in IntelliJ from git They are derived from the gradle configuration. IntelliJ keeps renaming the files every time the gradle script changes, which is annoying.
[ { "change_type": "MODIFY", "old_path": ".gitignore", "new_path": ".gitignore", "diff": "-workspace.xml\n-classes_gen\n-source_gen\n-source_gen.caches\n-mps/build/tmp\n+mps/.mps/workspace.xml\n+\n.gradle\nartifacts\nbuild\n-mps/org.modelix.ui.server/lib/ui-client-*.jar\n-kubernetes/secrets\n+mps/build\n+\ntest_gen\ntest_gen.caches\n+classes_gen\n+source_gen\n+source_gen.caches\n+\n+kubernetes/secrets\nssl/cert\n+mps/org.modelix.ui.server/lib/ui-client-*.jar\nmps/org.modelix.model.client/lib\n+\n+# modules are configured by gradle\n+.idea/modules\n+modules.xml\n" }, { "change_type": "DELETE", "old_path": ".idea/modules/model-client/modelix.model-client.commonMain~1.iml", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<module version=\"4\">\n- <component name=\"FacetManager\">\n- <facet type=\"kotlin-language\" name=\"Kotlin\">\n- <configuration version=\"3\" platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native []\" useProjectSettings=\"false\" isTestModule=\"false\" externalProjectId=\":model-client\">\n- <newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n- <compilerSettings />\n- <compilerArguments>\n- <option name=\"languageVersion\" value=\"1.3\" />\n- <option name=\"apiVersion\" value=\"1.3\" />\n- <option name=\"pluginOptions\">\n- <array />\n- </option>\n- <option name=\"pluginClasspaths\">\n- <array>\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n- </array>\n- </option>\n- <option name=\"multiPlatform\" value=\"true\" />\n- </compilerArguments>\n- </configuration>\n- </facet>\n- </component>\n-</module>\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": ".idea/modules/model-client/modelix.model-client.commonTest~1.iml", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<module version=\"4\">\n- <component name=\"FacetManager\">\n- <facet type=\"kotlin-language\" name=\"Kotlin\">\n- <configuration version=\"3\" platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native []\" useProjectSettings=\"false\" isTestModule=\"true\" externalProjectId=\":model-client\">\n- <newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n- <externalSystemTestTasks>\n- <externalSystemTestTask>jsBrowserTest|:model-client:jsTest|js</externalSystemTestTask>\n- <externalSystemTestTask>jsNodeTest|:model-client:jsTest|js</externalSystemTestTask>\n- <externalSystemTestTask>jvmTest|:model-client:jvmTest|jvm</externalSystemTestTask>\n- </externalSystemTestTasks>\n- <compilerSettings />\n- <compilerArguments>\n- <option name=\"languageVersion\" value=\"1.3\" />\n- <option name=\"apiVersion\" value=\"1.3\" />\n- <option name=\"pluginOptions\">\n- <array />\n- </option>\n- <option name=\"pluginClasspaths\">\n- <array>\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n- </array>\n- </option>\n- <option name=\"multiPlatform\" value=\"true\" />\n- </compilerArguments>\n- </configuration>\n- </facet>\n- </component>\n-</module>\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": ".idea/modules/model-client/modelix.model-client.jsMain~1.iml", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<module version=\"4\">\n- <component name=\"FacetManager\">\n- <facet type=\"kotlin-language\" name=\"Kotlin\">\n- <configuration version=\"3\" platform=\"JavaScript \" allPlatforms=\"JS []\" useProjectSettings=\"false\" isTestModule=\"false\" externalProjectId=\":model-client\">\n- <dependsOnModuleNames>:model-client:commonMain</dependsOnModuleNames>\n- <sourceSets>\n- <sourceSet>modelix.model-client.commonMain~1</sourceSet>\n- </sourceSets>\n- <newMppModelJpsModuleKind>COMPILATION_AND_SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n- <compilerSettings />\n- <compilerArguments>\n- <option name=\"outputFile\" value=\"$MODULE_DIR$/../../../build/js/packages/modelix-model-client/kotlin/modelix-model-client.js\" />\n- <option name=\"noStdlib\" value=\"true\" />\n- <option name=\"sourceMap\" value=\"true\" />\n- <option name=\"metaInfo\" value=\"true\" />\n- <option name=\"target\" value=\"v5\" />\n- <option name=\"moduleKind\" value=\"umd\" />\n- <option name=\"main\" value=\"call\" />\n- <option name=\"languageVersion\" value=\"1.3\" />\n- <option name=\"apiVersion\" value=\"1.3\" />\n- <option name=\"pluginOptions\">\n- <array />\n- </option>\n- <option name=\"pluginClasspaths\">\n- <array>\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n- </array>\n- </option>\n- <option name=\"multiPlatform\" value=\"true\" />\n- <option name=\"errors\">\n- <ArgumentParseErrors />\n- </option>\n- </compilerArguments>\n- </configuration>\n- </facet>\n- </component>\n-</module>\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": ".idea/modules/model-client/modelix.model-client.jsTest~1.iml", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<module version=\"4\">\n- <component name=\"FacetManager\">\n- <facet type=\"kotlin-language\" name=\"Kotlin\">\n- <configuration version=\"3\" platform=\"JavaScript \" allPlatforms=\"JS []\" useProjectSettings=\"false\" isTestModule=\"true\" externalProjectId=\":model-client\">\n- <dependsOnModuleNames>:model-client:commonTest</dependsOnModuleNames>\n- <sourceSets>\n- <sourceSet>modelix.model-client.jsMain~1</sourceSet>\n- <sourceSet>modelix.model-client.commonMain~1</sourceSet>\n- <sourceSet>modelix.model-client.commonTest~1</sourceSet>\n- </sourceSets>\n- <newMppModelJpsModuleKind>COMPILATION_AND_SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n- <externalSystemTestTasks>\n- <externalSystemTestTask>jsBrowserTest|:model-client:jsTest|js</externalSystemTestTask>\n- <externalSystemTestTask>jsNodeTest|:model-client:jsTest|js</externalSystemTestTask>\n- </externalSystemTestTasks>\n- <compilerSettings />\n- <compilerArguments>\n- <option name=\"outputFile\" value=\"$MODULE_DIR$/../../../build/js/packages/modelix-model-client-test/kotlin/modelix-model-client-test.js\" />\n- <option name=\"noStdlib\" value=\"true\" />\n- <option name=\"sourceMap\" value=\"true\" />\n- <option name=\"metaInfo\" value=\"true\" />\n- <option name=\"target\" value=\"v5\" />\n- <option name=\"moduleKind\" value=\"umd\" />\n- <option name=\"main\" value=\"call\" />\n- <option name=\"languageVersion\" value=\"1.3\" />\n- <option name=\"apiVersion\" value=\"1.3\" />\n- <option name=\"pluginOptions\">\n- <array />\n- </option>\n- <option name=\"pluginClasspaths\">\n- <array>\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n- </array>\n- </option>\n- <option name=\"multiPlatform\" value=\"true\" />\n- <option name=\"errors\">\n- <ArgumentParseErrors />\n- </option>\n- </compilerArguments>\n- </configuration>\n- </facet>\n- </component>\n-</module>\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": ".idea/modules/model-client/modelix.model-client.jvmMain~1.iml", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<module version=\"4\">\n- <component name=\"FacetManager\">\n- <facet type=\"kotlin-language\" name=\"Kotlin\">\n- <configuration version=\"3\" platform=\"JVM 11\" allPlatforms=\"JVM [11]\" useProjectSettings=\"false\" isTestModule=\"false\" externalProjectId=\":model-client\">\n- <dependsOnModuleNames>:model-client:commonMain</dependsOnModuleNames>\n- <sourceSets>\n- <sourceSet>modelix.model-client.commonMain~1</sourceSet>\n- </sourceSets>\n- <newMppModelJpsModuleKind>COMPILATION_AND_SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n- <compilerSettings>\n- <option name=\"additionalArguments\" value=\"-Xallow-no-source-files\" />\n- </compilerSettings>\n- <compilerArguments>\n- <option name=\"destination\" value=\"$MODULE_DIR$/../../../model-client/build/classes/kotlin/jvm/main\" />\n- <option name=\"classpath\" value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.72/916d54b9eb6442b615e6f1488978f551c0674720/kotlin-stdlib-jdk8-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.72/3adfc2f4ea4243e01204be8081fe63bde6b12815/kotlin-stdlib-jdk7-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/io.vavr/vavr/0.10.3/d2feb2bba9bfbfd043c4a25b0a14d568d18a61e3/vavr-0.10.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.11/68e9a6adf7cf8eb7e9d31bbc554c7c75eeaac568/commons-lang3-3.11.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/29.0-jre/801142b4c3d0f0770dd29abea50906cacfddd447/guava-29.0-jre.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.17/5af35056b4d257e4b64b9e8069c0746e8b08629f/log4j-1.2.17.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.media/jersey-media-sse/2.31/92b27cc1db7c8245641ded8c852352c296fe4552/jersey-media-sse-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-server/2.31/c9d42ddd4f8342381889cf1e0df15c1777aaffd6/jersey-server-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-client/2.31/fc9d5bc22f679085f9e5754429bdcff46a6844fa/jersey-client-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.inject/jersey-hk2/2.31/bbc4b2a9192beceeaa50bf8a6ebaf6953fc9d4d/jersey-hk2-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/javax.xml.bind/jaxb-api/2.3.1/8531ad5ac454cc2deb9d4d32c40c4d7451939b5d/jaxb-api-2.3.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.7/3f2bd4ba11c4162733c13cc90ca7c7ea09967102/commons-io-2.7.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.json/json/20200518/41a767de4bde8f01d53856b905c49b2db8862f13/json-20200518.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/net.sf.trove4j/trove4j/3.0.3/42ccaf4761f0dfdfa805c9e340d99a755907e2dd/trove4j-3.0.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-collections4/4.4/62ebe7544cb7164d87e0637a2a6a2bdc981395e8/commons-collections4-4.4.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/io.vavr/vavr-match/0.10.3/e0c0e10adee0204f71aa6d83a7c2547a5c8c9573/vavr-match-0.10.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.guava/failureaccess/1.0.1/1dcf1de382a0bf95a3d8b0849546c88bac1292c9/failureaccess-1.0.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/b421526c5f297295adef1c886e5246c39d4ac629/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.2/25ea2e8b0c338a877313bd4672d3fe056ea78f0d/jsr305-3.0.2.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.checkerframework/checker-qual/2.11.1/8c43bf8f99b841d23aadda6044329dad9b63c185/checker-qual-2.11.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.errorprone/error_prone_annotations/2.3.4/dac170e4594de319655ffb62f41cbd6dbb5e601e/error_prone_annotations-2.3.4.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.j2objc/j2objc-annotations/1.3/ba035118bc8bac37d7eff77700720999acd9986d/j2objc-annotations-1.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.media/jersey-media-jaxb/2.31/33a9245a4796a1cce9d8ac9decb219b35825e6c2/jersey-media-jaxb-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-common/2.31/b918c028c3c8c8b92a1ebb764571c369a85de04b/jersey-common-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/jakarta.ws.rs/jakarta.ws.rs-api/2.1.6/1dcb770bce80a490dff49729b99c7a60e9ecb122/jakarta.ws.rs-api-2.1.6.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-locator/2.6.1/9dedf9d2022e38ec0743ed44c1ac94ad6149acdd/hk2-locator-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-api/2.6.1/114bd7afb4a1bd9993527f52a08a252b5d2acac5/hk2-api-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-utils/2.6.1/396513aa96c1d5a10aa4f75c4dcbf259a698d62d/hk2-utils-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2.external/jakarta.inject/2.6.1/8096ebf722902e75fbd4f532a751e514f02e1eb7/jakarta.inject-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.javassist/javassist/3.25.0-GA/442dc1f9fd520130bd18da938622f4f9b2e5fba3/javassist-3.25.0-GA.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/javax.activation/javax.activation-api/1.2.0/85262acf3ca9816f9537ca47d5adeabaead7cb16/javax.activation-api-1.2.0.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/jakarta.annotation/jakarta.annotation-api/1.3.5/59eb84ee0d616332ff44aba065f3888cf002cd2d/jakarta.annotation-api-1.3.5.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/osgi-resource-locator/1.0.3/de3b21279df7e755e38275137539be5e2c80dd58/osgi-resource-locator-1.0.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2.external/aopalliance-repackaged/2.6.1/b2eb0a83bcbb44cc5d25f8b18f23be116313a638/aopalliance-repackaged-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/jakarta.validation/jakarta.validation-api/2.0.2/5eacc6522521f7eacb081f95cee1e231648461e7/jakarta.validation-api-2.0.2.jar\" />\n- <option name=\"noStdlib\" value=\"true\" />\n- <option name=\"noReflect\" value=\"true\" />\n- <option name=\"moduleName\" value=\"model-client\" />\n- <option name=\"jvmTarget\" value=\"11\" />\n- <option name=\"languageVersion\" value=\"1.3\" />\n- <option name=\"apiVersion\" value=\"1.3\" />\n- <option name=\"pluginOptions\">\n- <array />\n- </option>\n- <option name=\"pluginClasspaths\">\n- <array>\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n- </array>\n- </option>\n- <option name=\"multiPlatform\" value=\"true\" />\n- <option name=\"errors\">\n- <ArgumentParseErrors />\n- </option>\n- </compilerArguments>\n- </configuration>\n- </facet>\n- </component>\n-</module>\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": ".idea/modules/model-client/modelix.model-client.jvmTest~1.iml", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<module version=\"4\">\n- <component name=\"FacetManager\">\n- <facet type=\"kotlin-language\" name=\"Kotlin\">\n- <configuration version=\"3\" platform=\"JVM 11\" allPlatforms=\"JVM [11]\" useProjectSettings=\"false\" isTestModule=\"true\" externalProjectId=\":model-client\">\n- <dependsOnModuleNames>:model-client:commonTest</dependsOnModuleNames>\n- <sourceSets>\n- <sourceSet>modelix.model-client.commonMain~1</sourceSet>\n- <sourceSet>modelix.model-client.jvmMain~1</sourceSet>\n- <sourceSet>modelix.model-client.commonTest~1</sourceSet>\n- </sourceSets>\n- <newMppModelJpsModuleKind>COMPILATION_AND_SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n- <externalSystemTestTasks>jvmTest|:model-client:jvmTest|jvm</externalSystemTestTasks>\n- <compilerSettings>\n- <option name=\"additionalArguments\" value=\"-Xallow-no-source-files\" />\n- </compilerSettings>\n- <compilerArguments>\n- <option name=\"destination\" value=\"$MODULE_DIR$/../../../model-client/build/classes/kotlin/jvm/test\" />\n- <option name=\"classpath\" value=\"$MODULE_DIR$/../../../model-client/build/classes/kotlin/jvm/main:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.72/916d54b9eb6442b615e6f1488978f551c0674720/kotlin-stdlib-jdk8-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.72/3adfc2f4ea4243e01204be8081fe63bde6b12815/kotlin-stdlib-jdk7-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/io.vavr/vavr/0.10.3/d2feb2bba9bfbfd043c4a25b0a14d568d18a61e3/vavr-0.10.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.11/68e9a6adf7cf8eb7e9d31bbc554c7c75eeaac568/commons-lang3-3.11.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/29.0-jre/801142b4c3d0f0770dd29abea50906cacfddd447/guava-29.0-jre.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.17/5af35056b4d257e4b64b9e8069c0746e8b08629f/log4j-1.2.17.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.media/jersey-media-sse/2.31/92b27cc1db7c8245641ded8c852352c296fe4552/jersey-media-sse-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-server/2.31/c9d42ddd4f8342381889cf1e0df15c1777aaffd6/jersey-server-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-client/2.31/fc9d5bc22f679085f9e5754429bdcff46a6844fa/jersey-client-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.inject/jersey-hk2/2.31/bbc4b2a9192beceeaa50bf8a6ebaf6953fc9d4d/jersey-hk2-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/javax.xml.bind/jaxb-api/2.3.1/8531ad5ac454cc2deb9d4d32c40c4d7451939b5d/jaxb-api-2.3.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.7/3f2bd4ba11c4162733c13cc90ca7c7ea09967102/commons-io-2.7.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.json/json/20200518/41a767de4bde8f01d53856b905c49b2db8862f13/json-20200518.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/net.sf.trove4j/trove4j/3.0.3/42ccaf4761f0dfdfa805c9e340d99a755907e2dd/trove4j-3.0.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-collections4/4.4/62ebe7544cb7164d87e0637a2a6a2bdc981395e8/commons-collections4-4.4.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/io.vavr/vavr-match/0.10.3/e0c0e10adee0204f71aa6d83a7c2547a5c8c9573/vavr-match-0.10.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.guava/failureaccess/1.0.1/1dcf1de382a0bf95a3d8b0849546c88bac1292c9/failureaccess-1.0.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/b421526c5f297295adef1c886e5246c39d4ac629/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.2/25ea2e8b0c338a877313bd4672d3fe056ea78f0d/jsr305-3.0.2.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.checkerframework/checker-qual/2.11.1/8c43bf8f99b841d23aadda6044329dad9b63c185/checker-qual-2.11.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.errorprone/error_prone_annotations/2.3.4/dac170e4594de319655ffb62f41cbd6dbb5e601e/error_prone_annotations-2.3.4.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/com.google.j2objc/j2objc-annotations/1.3/ba035118bc8bac37d7eff77700720999acd9986d/j2objc-annotations-1.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.media/jersey-media-jaxb/2.31/33a9245a4796a1cce9d8ac9decb219b35825e6c2/jersey-media-jaxb-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-common/2.31/b918c028c3c8c8b92a1ebb764571c369a85de04b/jersey-common-2.31.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/jakarta.ws.rs/jakarta.ws.rs-api/2.1.6/1dcb770bce80a490dff49729b99c7a60e9ecb122/jakarta.ws.rs-api-2.1.6.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-locator/2.6.1/9dedf9d2022e38ec0743ed44c1ac94ad6149acdd/hk2-locator-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-api/2.6.1/114bd7afb4a1bd9993527f52a08a252b5d2acac5/hk2-api-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-utils/2.6.1/396513aa96c1d5a10aa4f75c4dcbf259a698d62d/hk2-utils-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2.external/jakarta.inject/2.6.1/8096ebf722902e75fbd4f532a751e514f02e1eb7/jakarta.inject-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.javassist/javassist/3.25.0-GA/442dc1f9fd520130bd18da938622f4f9b2e5fba3/javassist-3.25.0-GA.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/javax.activation/javax.activation-api/1.2.0/85262acf3ca9816f9537ca47d5adeabaead7cb16/javax.activation-api-1.2.0.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/jakarta.annotation/jakarta.annotation-api/1.3.5/59eb84ee0d616332ff44aba065f3888cf002cd2d/jakarta.annotation-api-1.3.5.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/osgi-resource-locator/1.0.3/de3b21279df7e755e38275137539be5e2c80dd58/osgi-resource-locator-1.0.3.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2.external/aopalliance-repackaged/2.6.1/b2eb0a83bcbb44cc5d25f8b18f23be116313a638/aopalliance-repackaged-2.6.1.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/jakarta.validation/jakarta.validation-api/2.0.2/5eacc6522521f7eacb081f95cee1e231648461e7/jakarta.validation-api-2.0.2.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test-junit/1.3.72/133db9f7a420bda99e8c8ed8ee129cdaa94d6b2c/kotlin-test-junit-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test/1.3.72/52db57b3bc7d3a1381978e93e061159e2114d60c/kotlin-test-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test-common/1.3.72/92aa1317f68727e77867727c2bd2a2f4460116b2/kotlin-test-common-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test-annotations-common/1.3.72/43af036072bee8c338852e253dab220389fd9ed8/kotlin-test-annotations-common-1.3.72.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar:/Users/slisson/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar\" />\n- <option name=\"noStdlib\" value=\"true\" />\n- <option name=\"noReflect\" value=\"true\" />\n- <option name=\"moduleName\" value=\"model-client\" />\n- <option name=\"jvmTarget\" value=\"11\" />\n- <option name=\"friendPaths\">\n- <array>\n- <option value=\"$MODULE_DIR$/../../../model-client/build/classes/kotlin/jvm/main\" />\n- </array>\n- </option>\n- <option name=\"languageVersion\" value=\"1.3\" />\n- <option name=\"apiVersion\" value=\"1.3\" />\n- <option name=\"pluginOptions\">\n- <array />\n- </option>\n- <option name=\"pluginClasspaths\">\n- <array>\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n- <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n- </array>\n- </option>\n- <option name=\"multiPlatform\" value=\"true\" />\n- <option name=\"errors\">\n- <ArgumentParseErrors />\n- </option>\n- </compilerArguments>\n- </configuration>\n- </facet>\n- </component>\n-</module>\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": ".idea/modules/modelix.commonMain.iml", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<module version=\"4\">\n- <component name=\"FacetManager\">\n- <facet type=\"kotlin-language\" name=\"Kotlin\">\n- <configuration version=\"3\" platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native []\" useProjectSettings=\"false\" isTestModule=\"false\" externalProjectId=\"modelix\">\n- <newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n- <compilerSettings />\n- <compilerArguments>\n- <option name=\"languageVersion\" value=\"1.3\" />\n- <option name=\"apiVersion\" value=\"1.3\" />\n- <option name=\"pluginOptions\">\n- <array />\n- </option>\n- <option name=\"pluginClasspaths\">\n- <array />\n- </option>\n- <option name=\"multiPlatform\" value=\"true\" />\n- </compilerArguments>\n- </configuration>\n- </facet>\n- </component>\n-</module>\n\\ No newline at end of file\n" }, { "change_type": "DELETE", "old_path": ".idea/modules/modelix.commonTest.iml", "new_path": null, "diff": "-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n-<module version=\"4\">\n- <component name=\"FacetManager\">\n- <facet type=\"kotlin-language\" name=\"Kotlin\">\n- <configuration version=\"3\" platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native []\" useProjectSettings=\"false\" isTestModule=\"true\" externalProjectId=\"modelix\">\n- <newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n- <compilerSettings />\n- <compilerArguments>\n- <option name=\"languageVersion\" value=\"1.3\" />\n- <option name=\"apiVersion\" value=\"1.3\" />\n- <option name=\"pluginOptions\">\n- <array />\n- </option>\n- <option name=\"pluginClasspaths\">\n- <array />\n- </option>\n- <option name=\"multiPlatform\" value=\"true\" />\n- </compilerArguments>\n- </configuration>\n- </facet>\n- </component>\n-</module>\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Remove modules configured in IntelliJ from git They are derived from the gradle configuration. IntelliJ keeps renaming the files every time the gradle script changes, which is annoying.
426,504
09.08.2020 08:17:16
-7,200
f654e5b93b610334469fb1891548b4ba907c35fd
add test_random_uuid
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "diff": "@@ -75,7 +75,7 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal> {\n}\nprotected fun getChild(childHash: String, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n- return bulkQuery.get(childHash, CPHamtNode.DESERIALIZER).map { childData -> create(childData, store) }\n+ return bulkQuery[childHash, CPHamtNode.DESERIALIZER].map { childData -> create(childData, store) }\n}\nprotected fun getChild(logicalIndex: Int): CLHamtNode<*>? {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/PlatformSpecific_Test.kt", "diff": "+package org.modelix.model\n+\n+import kotlin.test.Test\n+import kotlin.test.assertEquals\n+import kotlin.test.assertTrue\n+\n+fun Char.assertIsHexDigit(){\n+ assertTrue(\"Character expected to be hexadecimal digit but is '$this'\") {this in '0'..'9' || this in 'a'..'f' }\n+}\n+\n+class PlatformSpecific_Test {\n+ @Test\n+ fun test_random_uuid() {\n+ val res = randomUUID()\n+ // ex: 5499930c-bfe2-40c5-82d1-a3859a045081\n+ assertEquals(36, res.count())\n+ val separators = listOf(8, 13, 18, 23)\n+ for (i in 0 until res.count()) {\n+ if (i in separators) {\n+ assertEquals('-', res[i])\n+ } else {\n+ res[i].assertIsHexDigit()\n+ }\n+ }\n+\n+ }\n+}\n+\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add test_random_uuid
426,504
09.08.2020 10:44:48
-7,200
5719f31e7746baf28c853b3e6ab588cdf4f2cfad
introduce StringUtilsTest
[ { "change_type": "ADD", "old_path": null, "new_path": ".idea/modules/model-client/model-client_commonMain.iml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<module version=\"4\">\n+ <component name=\"FacetManager\">\n+ <facet type=\"kotlin-language\" name=\"Kotlin\">\n+ <configuration version=\"3\" platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native []\" useProjectSettings=\"false\" isTestModule=\"false\" externalProjectId=\":model-client\">\n+ <newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n+ <compilerSettings />\n+ <compilerArguments>\n+ <option name=\"languageVersion\" value=\"1.3\" />\n+ <option name=\"apiVersion\" value=\"1.3\" />\n+ <option name=\"pluginOptions\">\n+ <array />\n+ </option>\n+ <option name=\"pluginClasspaths\">\n+ <array>\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n+ </array>\n+ </option>\n+ <option name=\"multiPlatform\" value=\"true\" />\n+ </compilerArguments>\n+ </configuration>\n+ </facet>\n+ </component>\n+</module>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".idea/modules/model-client/model-client_commonTest.iml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<module version=\"4\">\n+ <component name=\"FacetManager\">\n+ <facet type=\"kotlin-language\" name=\"Kotlin\">\n+ <configuration version=\"3\" platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native []\" useProjectSettings=\"false\" isTestModule=\"true\" externalProjectId=\":model-client\">\n+ <newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n+ <externalSystemTestTasks>\n+ <externalSystemTestTask>jsNodeTest|:model-client:jsTest|js</externalSystemTestTask>\n+ <externalSystemTestTask>jvmTest|:model-client:jvmTest|jvm</externalSystemTestTask>\n+ </externalSystemTestTasks>\n+ <compilerSettings />\n+ <compilerArguments>\n+ <option name=\"languageVersion\" value=\"1.3\" />\n+ <option name=\"apiVersion\" value=\"1.3\" />\n+ <option name=\"pluginOptions\">\n+ <array />\n+ </option>\n+ <option name=\"pluginClasspaths\">\n+ <array>\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n+ </array>\n+ </option>\n+ <option name=\"multiPlatform\" value=\"true\" />\n+ </compilerArguments>\n+ </configuration>\n+ </facet>\n+ </component>\n+</module>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".idea/modules/model-client/model-client_jsMain.iml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<module version=\"4\">\n+ <component name=\"FacetManager\">\n+ <facet type=\"kotlin-language\" name=\"Kotlin\">\n+ <configuration version=\"3\" platform=\"JavaScript \" allPlatforms=\"JS []\" useProjectSettings=\"false\" isTestModule=\"false\" externalProjectId=\":model-client\">\n+ <dependsOnModuleNames>:model-client:commonMain</dependsOnModuleNames>\n+ <sourceSets>\n+ <sourceSet>model-client_commonMain</sourceSet>\n+ </sourceSets>\n+ <newMppModelJpsModuleKind>COMPILATION_AND_SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n+ <compilerSettings />\n+ <compilerArguments>\n+ <option name=\"outputFile\" value=\"$MODULE_DIR$/../../../build/js/packages/modelix-model-client/kotlin/modelix-model-client.js\" />\n+ <option name=\"noStdlib\" value=\"true\" />\n+ <option name=\"sourceMap\" value=\"true\" />\n+ <option name=\"metaInfo\" value=\"true\" />\n+ <option name=\"target\" value=\"v5\" />\n+ <option name=\"moduleKind\" value=\"umd\" />\n+ <option name=\"main\" value=\"call\" />\n+ <option name=\"languageVersion\" value=\"1.3\" />\n+ <option name=\"apiVersion\" value=\"1.3\" />\n+ <option name=\"pluginOptions\">\n+ <array />\n+ </option>\n+ <option name=\"pluginClasspaths\">\n+ <array>\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n+ </array>\n+ </option>\n+ <option name=\"multiPlatform\" value=\"true\" />\n+ <option name=\"errors\">\n+ <ArgumentParseErrors />\n+ </option>\n+ </compilerArguments>\n+ </configuration>\n+ </facet>\n+ </component>\n+</module>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".idea/modules/model-client/model-client_jsTest.iml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<module version=\"4\">\n+ <component name=\"FacetManager\">\n+ <facet type=\"kotlin-language\" name=\"Kotlin\">\n+ <configuration version=\"3\" platform=\"JavaScript \" allPlatforms=\"JS []\" useProjectSettings=\"false\" isTestModule=\"true\" externalProjectId=\":model-client\">\n+ <dependsOnModuleNames>:model-client:commonTest</dependsOnModuleNames>\n+ <sourceSets>\n+ <sourceSet>model-client_jsMain</sourceSet>\n+ <sourceSet>model-client_commonTest</sourceSet>\n+ <sourceSet>model-client_commonMain</sourceSet>\n+ </sourceSets>\n+ <newMppModelJpsModuleKind>COMPILATION_AND_SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n+ <externalSystemTestTasks>jsNodeTest|:model-client:jsTest|js</externalSystemTestTasks>\n+ <compilerSettings />\n+ <compilerArguments>\n+ <option name=\"outputFile\" value=\"$MODULE_DIR$/../../../build/js/packages/modelix-model-client-test/kotlin/modelix-model-client-test.js\" />\n+ <option name=\"noStdlib\" value=\"true\" />\n+ <option name=\"sourceMap\" value=\"true\" />\n+ <option name=\"metaInfo\" value=\"true\" />\n+ <option name=\"target\" value=\"v5\" />\n+ <option name=\"moduleKind\" value=\"umd\" />\n+ <option name=\"main\" value=\"call\" />\n+ <option name=\"languageVersion\" value=\"1.3\" />\n+ <option name=\"apiVersion\" value=\"1.3\" />\n+ <option name=\"pluginOptions\">\n+ <array />\n+ </option>\n+ <option name=\"pluginClasspaths\">\n+ <array>\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n+ </array>\n+ </option>\n+ <option name=\"multiPlatform\" value=\"true\" />\n+ <option name=\"errors\">\n+ <ArgumentParseErrors />\n+ </option>\n+ </compilerArguments>\n+ </configuration>\n+ </facet>\n+ </component>\n+</module>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".idea/modules/model-client/model-client_jvmMain.iml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<module version=\"4\">\n+ <component name=\"FacetManager\">\n+ <facet type=\"kotlin-language\" name=\"Kotlin\">\n+ <configuration version=\"3\" platform=\"JVM 11\" allPlatforms=\"JVM [11]\" useProjectSettings=\"false\" isTestModule=\"false\" externalProjectId=\":model-client\">\n+ <dependsOnModuleNames>:model-client:commonMain</dependsOnModuleNames>\n+ <sourceSets>\n+ <sourceSet>model-client_commonMain</sourceSet>\n+ </sourceSets>\n+ <newMppModelJpsModuleKind>COMPILATION_AND_SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n+ <compilerSettings>\n+ <option name=\"additionalArguments\" value=\"-Xallow-no-source-files\" />\n+ </compilerSettings>\n+ <compilerArguments>\n+ <option name=\"destination\" value=\"$MODULE_DIR$/../../../model-client/build/classes/kotlin/jvm/main\" />\n+ <option name=\"classpath\" value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.72/916d54b9eb6442b615e6f1488978f551c0674720/kotlin-stdlib-jdk8-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.72/3adfc2f4ea4243e01204be8081fe63bde6b12815/kotlin-stdlib-jdk7-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/io.vavr/vavr/0.10.3/d2feb2bba9bfbfd043c4a25b0a14d568d18a61e3/vavr-0.10.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.11/68e9a6adf7cf8eb7e9d31bbc554c7c75eeaac568/commons-lang3-3.11.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/29.0-jre/801142b4c3d0f0770dd29abea50906cacfddd447/guava-29.0-jre.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.17/5af35056b4d257e4b64b9e8069c0746e8b08629f/log4j-1.2.17.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.media/jersey-media-sse/2.31/92b27cc1db7c8245641ded8c852352c296fe4552/jersey-media-sse-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-server/2.31/c9d42ddd4f8342381889cf1e0df15c1777aaffd6/jersey-server-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-client/2.31/fc9d5bc22f679085f9e5754429bdcff46a6844fa/jersey-client-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.inject/jersey-hk2/2.31/bbc4b2a9192beceeaa50bf8a6ebaf6953fc9d4d/jersey-hk2-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/javax.xml.bind/jaxb-api/2.3.1/8531ad5ac454cc2deb9d4d32c40c4d7451939b5d/jaxb-api-2.3.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.7/3f2bd4ba11c4162733c13cc90ca7c7ea09967102/commons-io-2.7.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.json/json/20200518/41a767de4bde8f01d53856b905c49b2db8862f13/json-20200518.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/net.sf.trove4j/trove4j/3.0.3/42ccaf4761f0dfdfa805c9e340d99a755907e2dd/trove4j-3.0.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-collections4/4.4/62ebe7544cb7164d87e0637a2a6a2bdc981395e8/commons-collections4-4.4.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/io.vavr/vavr-match/0.10.3/e0c0e10adee0204f71aa6d83a7c2547a5c8c9573/vavr-match-0.10.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.guava/failureaccess/1.0.1/1dcf1de382a0bf95a3d8b0849546c88bac1292c9/failureaccess-1.0.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/b421526c5f297295adef1c886e5246c39d4ac629/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.2/25ea2e8b0c338a877313bd4672d3fe056ea78f0d/jsr305-3.0.2.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.checkerframework/checker-qual/2.11.1/8c43bf8f99b841d23aadda6044329dad9b63c185/checker-qual-2.11.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.errorprone/error_prone_annotations/2.3.4/dac170e4594de319655ffb62f41cbd6dbb5e601e/error_prone_annotations-2.3.4.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.j2objc/j2objc-annotations/1.3/ba035118bc8bac37d7eff77700720999acd9986d/j2objc-annotations-1.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.media/jersey-media-jaxb/2.31/33a9245a4796a1cce9d8ac9decb219b35825e6c2/jersey-media-jaxb-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-common/2.31/b918c028c3c8c8b92a1ebb764571c369a85de04b/jersey-common-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/jakarta.ws.rs/jakarta.ws.rs-api/2.1.6/1dcb770bce80a490dff49729b99c7a60e9ecb122/jakarta.ws.rs-api-2.1.6.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-locator/2.6.1/9dedf9d2022e38ec0743ed44c1ac94ad6149acdd/hk2-locator-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-api/2.6.1/114bd7afb4a1bd9993527f52a08a252b5d2acac5/hk2-api-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-utils/2.6.1/396513aa96c1d5a10aa4f75c4dcbf259a698d62d/hk2-utils-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2.external/jakarta.inject/2.6.1/8096ebf722902e75fbd4f532a751e514f02e1eb7/jakarta.inject-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.javassist/javassist/3.25.0-GA/442dc1f9fd520130bd18da938622f4f9b2e5fba3/javassist-3.25.0-GA.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/javax.activation/javax.activation-api/1.2.0/85262acf3ca9816f9537ca47d5adeabaead7cb16/javax.activation-api-1.2.0.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/jakarta.annotation/jakarta.annotation-api/1.3.5/59eb84ee0d616332ff44aba065f3888cf002cd2d/jakarta.annotation-api-1.3.5.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/osgi-resource-locator/1.0.3/de3b21279df7e755e38275137539be5e2c80dd58/osgi-resource-locator-1.0.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2.external/aopalliance-repackaged/2.6.1/b2eb0a83bcbb44cc5d25f8b18f23be116313a638/aopalliance-repackaged-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/jakarta.validation/jakarta.validation-api/2.0.2/5eacc6522521f7eacb081f95cee1e231648461e7/jakarta.validation-api-2.0.2.jar\" />\n+ <option name=\"noStdlib\" value=\"true\" />\n+ <option name=\"noReflect\" value=\"true\" />\n+ <option name=\"moduleName\" value=\"model-client\" />\n+ <option name=\"jvmTarget\" value=\"11\" />\n+ <option name=\"languageVersion\" value=\"1.3\" />\n+ <option name=\"apiVersion\" value=\"1.3\" />\n+ <option name=\"pluginOptions\">\n+ <array />\n+ </option>\n+ <option name=\"pluginClasspaths\">\n+ <array>\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n+ </array>\n+ </option>\n+ <option name=\"multiPlatform\" value=\"true\" />\n+ <option name=\"errors\">\n+ <ArgumentParseErrors />\n+ </option>\n+ </compilerArguments>\n+ </configuration>\n+ </facet>\n+ </component>\n+</module>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".idea/modules/model-client/model-client_jvmTest.iml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<module version=\"4\">\n+ <component name=\"FacetManager\">\n+ <facet type=\"kotlin-language\" name=\"Kotlin\">\n+ <configuration version=\"3\" platform=\"JVM 11\" allPlatforms=\"JVM [11]\" useProjectSettings=\"false\" isTestModule=\"true\" externalProjectId=\":model-client\">\n+ <dependsOnModuleNames>:model-client:commonTest</dependsOnModuleNames>\n+ <sourceSets>\n+ <sourceSet>model-client_jvmMain</sourceSet>\n+ <sourceSet>model-client_commonTest</sourceSet>\n+ <sourceSet>model-client_commonMain</sourceSet>\n+ </sourceSets>\n+ <newMppModelJpsModuleKind>COMPILATION_AND_SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n+ <externalSystemTestTasks>jvmTest|:model-client:jvmTest|jvm</externalSystemTestTasks>\n+ <compilerSettings>\n+ <option name=\"additionalArguments\" value=\"-Xallow-no-source-files\" />\n+ </compilerSettings>\n+ <compilerArguments>\n+ <option name=\"destination\" value=\"$MODULE_DIR$/../../../model-client/build/classes/kotlin/jvm/test\" />\n+ <option name=\"classpath\" value=\"$MODULE_DIR$/../../../model-client/build/classes/kotlin/jvm/main:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk8/1.3.72/916d54b9eb6442b615e6f1488978f551c0674720/kotlin-stdlib-jdk8-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.3.72/3adfc2f4ea4243e01204be8081fe63bde6b12815/kotlin-stdlib-jdk7-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/io.vavr/vavr/0.10.3/d2feb2bba9bfbfd043c4a25b0a14d568d18a61e3/vavr-0.10.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-lang3/3.11/68e9a6adf7cf8eb7e9d31bbc554c7c75eeaac568/commons-lang3-3.11.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.guava/guava/29.0-jre/801142b4c3d0f0770dd29abea50906cacfddd447/guava-29.0-jre.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/log4j/log4j/1.2.17/5af35056b4d257e4b64b9e8069c0746e8b08629f/log4j-1.2.17.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.media/jersey-media-sse/2.31/92b27cc1db7c8245641ded8c852352c296fe4552/jersey-media-sse-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-server/2.31/c9d42ddd4f8342381889cf1e0df15c1777aaffd6/jersey-server-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-client/2.31/fc9d5bc22f679085f9e5754429bdcff46a6844fa/jersey-client-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.inject/jersey-hk2/2.31/bbc4b2a9192beceeaa50bf8a6ebaf6953fc9d4d/jersey-hk2-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/javax.xml.bind/jaxb-api/2.3.1/8531ad5ac454cc2deb9d4d32c40c4d7451939b5d/jaxb-api-2.3.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/commons-io/commons-io/2.7/3f2bd4ba11c4162733c13cc90ca7c7ea09967102/commons-io-2.7.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.json/json/20200518/41a767de4bde8f01d53856b905c49b2db8862f13/json-20200518.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/net.sf.trove4j/trove4j/3.0.3/42ccaf4761f0dfdfa805c9e340d99a755907e2dd/trove4j-3.0.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-collections4/4.4/62ebe7544cb7164d87e0637a2a6a2bdc981395e8/commons-collections4-4.4.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/io.vavr/vavr-match/0.10.3/e0c0e10adee0204f71aa6d83a7c2547a5c8c9573/vavr-match-0.10.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.guava/failureaccess/1.0.1/1dcf1de382a0bf95a3d8b0849546c88bac1292c9/failureaccess-1.0.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/b421526c5f297295adef1c886e5246c39d4ac629/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.code.findbugs/jsr305/3.0.2/25ea2e8b0c338a877313bd4672d3fe056ea78f0d/jsr305-3.0.2.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.checkerframework/checker-qual/2.11.1/8c43bf8f99b841d23aadda6044329dad9b63c185/checker-qual-2.11.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.errorprone/error_prone_annotations/2.3.4/dac170e4594de319655ffb62f41cbd6dbb5e601e/error_prone_annotations-2.3.4.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/com.google.j2objc/j2objc-annotations/1.3/ba035118bc8bac37d7eff77700720999acd9986d/j2objc-annotations-1.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.media/jersey-media-jaxb/2.31/33a9245a4796a1cce9d8ac9decb219b35825e6c2/jersey-media-jaxb-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.jersey.core/jersey-common/2.31/b918c028c3c8c8b92a1ebb764571c369a85de04b/jersey-common-2.31.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/jakarta.ws.rs/jakarta.ws.rs-api/2.1.6/1dcb770bce80a490dff49729b99c7a60e9ecb122/jakarta.ws.rs-api-2.1.6.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-locator/2.6.1/9dedf9d2022e38ec0743ed44c1ac94ad6149acdd/hk2-locator-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-api/2.6.1/114bd7afb4a1bd9993527f52a08a252b5d2acac5/hk2-api-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/hk2-utils/2.6.1/396513aa96c1d5a10aa4f75c4dcbf259a698d62d/hk2-utils-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2.external/jakarta.inject/2.6.1/8096ebf722902e75fbd4f532a751e514f02e1eb7/jakarta.inject-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.javassist/javassist/3.25.0-GA/442dc1f9fd520130bd18da938622f4f9b2e5fba3/javassist-3.25.0-GA.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/javax.activation/javax.activation-api/1.2.0/85262acf3ca9816f9537ca47d5adeabaead7cb16/javax.activation-api-1.2.0.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/jakarta.annotation/jakarta.annotation-api/1.3.5/59eb84ee0d616332ff44aba065f3888cf002cd2d/jakarta.annotation-api-1.3.5.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2/osgi-resource-locator/1.0.3/de3b21279df7e755e38275137539be5e2c80dd58/osgi-resource-locator-1.0.3.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.glassfish.hk2.external/aopalliance-repackaged/2.6.1/b2eb0a83bcbb44cc5d25f8b18f23be116313a638/aopalliance-repackaged-2.6.1.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/jakarta.validation/jakarta.validation-api/2.0.2/5eacc6522521f7eacb081f95cee1e231648461e7/jakarta.validation-api-2.0.2.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test-junit/1.3.72/133db9f7a420bda99e8c8ed8ee129cdaa94d6b2c/kotlin-test-junit-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test/1.3.72/52db57b3bc7d3a1381978e93e061159e2114d60c/kotlin-test-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test-common/1.3.72/92aa1317f68727e77867727c2bd2a2f4460116b2/kotlin-test-common-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-test-annotations-common/1.3.72/43af036072bee8c338852e253dab220389fd9ed8/kotlin-test-annotations-common-1.3.72.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973d150c0dc1fefe998f834810d68f278ea58ec/junit-4.12.jar:/Users/federico/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a25dc3219429f0e5d060061f71acb49bf010a0/hamcrest-core-1.3.jar\" />\n+ <option name=\"noStdlib\" value=\"true\" />\n+ <option name=\"noReflect\" value=\"true\" />\n+ <option name=\"moduleName\" value=\"model-client\" />\n+ <option name=\"jvmTarget\" value=\"11\" />\n+ <option name=\"friendPaths\">\n+ <array>\n+ <option value=\"$MODULE_DIR$/../../../model-client/build/classes/kotlin/jvm/main\" />\n+ </array>\n+ </option>\n+ <option name=\"languageVersion\" value=\"1.3\" />\n+ <option name=\"apiVersion\" value=\"1.3\" />\n+ <option name=\"pluginOptions\">\n+ <array />\n+ </option>\n+ <option name=\"pluginClasspaths\">\n+ <array>\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-script-runtime/1.3.72/657d8d34d91e1964b4439378c09933e840bfe8d5/kotlin-script-runtime-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-common/1.3.72/e09990437040879d692655d66f58a64318681ffe/kotlin-scripting-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-scripting-jvm/1.3.72/7dde2c909e6f1b80245c7ca100d32a8646b5666d/kotlin-scripting-jvm-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.3.72/6ca8bee3d88957eaaaef077c41c908c9940492d8/kotlin-stdlib-common-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.3.72/8032138f12c0180bc4e51fe139d4c52b46db6109/kotlin-stdlib-1.3.72.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core/1.2.1/3839faf625f4197acaeceeb6da000f011a2acb49/kotlinx-coroutines-core-1.2.1.jar\" />\n+ <option value=\"$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar\" />\n+ </array>\n+ </option>\n+ <option name=\"multiPlatform\" value=\"true\" />\n+ <option name=\"errors\">\n+ <ArgumentParseErrors />\n+ </option>\n+ </compilerArguments>\n+ </configuration>\n+ </facet>\n+ </component>\n+</module>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".idea/modules/modelix_commonMain.iml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<module version=\"4\">\n+ <component name=\"FacetManager\">\n+ <facet type=\"kotlin-language\" name=\"Kotlin\">\n+ <configuration version=\"3\" platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native []\" useProjectSettings=\"false\" isTestModule=\"false\" externalProjectId=\"modelix\">\n+ <newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n+ <compilerSettings />\n+ <compilerArguments>\n+ <option name=\"languageVersion\" value=\"1.3\" />\n+ <option name=\"apiVersion\" value=\"1.3\" />\n+ <option name=\"pluginOptions\">\n+ <array />\n+ </option>\n+ <option name=\"pluginClasspaths\">\n+ <array />\n+ </option>\n+ <option name=\"multiPlatform\" value=\"true\" />\n+ </compilerArguments>\n+ </configuration>\n+ </facet>\n+ </component>\n+</module>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".idea/modules/modelix_commonTest.iml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<module version=\"4\">\n+ <component name=\"FacetManager\">\n+ <facet type=\"kotlin-language\" name=\"Kotlin\">\n+ <configuration version=\"3\" platform=\"Common (experimental) \" allPlatforms=\"JS []/JVM [1.6]/Native []\" useProjectSettings=\"false\" isTestModule=\"true\" externalProjectId=\"modelix\">\n+ <newMppModelJpsModuleKind>SOURCE_SET_HOLDER</newMppModelJpsModuleKind>\n+ <compilerSettings />\n+ <compilerArguments>\n+ <option name=\"languageVersion\" value=\"1.3\" />\n+ <option name=\"apiVersion\" value=\"1.3\" />\n+ <option name=\"pluginOptions\">\n+ <array />\n+ </option>\n+ <option name=\"pluginClasspaths\">\n+ <array />\n+ </option>\n+ <option name=\"multiPlatform\" value=\"true\" />\n+ </compilerArguments>\n+ </configuration>\n+ </facet>\n+ </component>\n+</module>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "diff": "package org.modelix.model.persistent\nexpect object HashUtil {\n+ fun sha256asByteArray(input: ByteArray?): ByteArray\nfun sha256(input: ByteArray?): String\nfun sha256(input: String): String\nfun isSha256(value: String?): Boolean\n@@ -23,3 +24,5 @@ expect object HashUtil {\nfun base64encode(input: String): String\nfun base64decode(input: String): String\n}\n+\n+expect fun stringToUTF8ByteArray(input: String) : ByteArray\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/HashUtilsTest.kt", "diff": "+package org.modelix.model\n+\n+import org.modelix.model.persistent.HashUtil\n+import kotlin.test.Test\n+\n+class HashUtilsTest {\n+\n+ @Test\n+ fun simple() {\n+ //HashUtil.sha256asByteArray()\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/StringUtilsTest.kt", "diff": "+package org.modelix.model\n+\n+import org.modelix.model.persistent.stringToUTF8ByteArray\n+import kotlin.test.Test\n+import kotlin.test.assertEquals\n+\n+class StringUtilsTest {\n+\n+ @Test\n+ @kotlin.ExperimentalStdlibApi\n+ fun stringToByteArrayForEmptyString() {\n+ val res = stringToUTF8ByteArray(\"\");\n+ assertEquals(0, res.count())\n+ }\n+\n+ @Test\n+ @kotlin.ExperimentalStdlibApi\n+ fun stringToByteArrayForShortString() {\n+ val res = stringToUTF8ByteArray(\"a\");\n+ assertEquals(1, res.count())\n+ assertEquals(97, res[0]);\n+ }\n+\n+ @Test\n+ @kotlin.ExperimentalStdlibApi\n+ fun stringToByteArrayForMediumString() {\n+ val res : ByteArray = stringToUTF8ByteArray(\"hello from Kotlin\");\n+ assertEquals(17, res.count())\n+ val expected : ByteArray = byteArrayOf(104, 101, 108, 108, 111, 32, 102, 114, 111, 109, 32, 75, 111, 116, 108, 105, 110)\n+ // assertEquals seems to have issues comparing ByteArray\n+ assertEquals(expected.toList(), res.toList(), \"actual ${res.contentToString()}\");\n+ }\n+}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "diff": "@@ -33,4 +33,13 @@ actual object HashUtil {\nactual fun base64decode(input: String): String {\nreturn window.atob(input)\n}\n+\n+ actual fun sha256asByteArray(input: ByteArray?): ByteArray {\n+ TODO(\"Not yet implemented\")\n+ }\n+}\n+\n+@ExperimentalStdlibApi\n+actual fun stringToUTF8ByteArray(input: String) : ByteArray {\n+ return input.encodeToByteArray()\n}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "diff": "@@ -24,17 +24,22 @@ import java.util.regex.Pattern\nactual object HashUtil {\nprivate val HASH_PATTERN = Pattern.compile(\"[a-zA-Z0-9\\\\-_]{43}\")\nprivate val UTF8 = StandardCharsets.UTF_8\n- actual fun sha256(input: ByteArray?): String {\n+ actual fun sha256asByteArray(input: ByteArray?): ByteArray {\nreturn try {\nval digest = MessageDigest.getInstance(\"SHA-256\")\ndigest.update(input)\n- val sha256Bytes = digest.digest()\n- Base64.getUrlEncoder().withoutPadding().encodeToString(sha256Bytes)\n+ return digest.digest()\n} catch (ex: NoSuchAlgorithmException) {\nthrow RuntimeException(ex)\n}\n}\n+ actual fun sha256(input: ByteArray?): String {\n+ val sha256Bytes = sha256asByteArray(input)\n+ println(\"digest $sha256Bytes\")\n+ return Base64.getUrlEncoder().withoutPadding().encodeToString(sha256Bytes)\n+ }\n+\nactual fun sha256(input: String): String {\nreturn sha256(input.toByteArray(UTF8))\n}\n@@ -84,4 +89,9 @@ actual object HashUtil {\nactual fun base64decode(input: String): String {\nreturn String(Base64.getUrlDecoder().decode(input.toByteArray(UTF8)), UTF8)\n}\n+\n+}\n+\n+actual fun stringToUTF8ByteArray(input: String) : ByteArray {\n+ return input.toByteArray(StandardCharsets.UTF_8)\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
introduce StringUtilsTest
426,504
09.08.2020 11:05:25
-7,200
0a5bd29809f114e2d78348435814b69c50d321fd
fix HashUtils for js
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/HashUtilsTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/HashUtilsTest.kt", "diff": "@@ -2,11 +2,31 @@ package org.modelix.model\nimport org.modelix.model.persistent.HashUtil\nimport kotlin.test.Test\n+import kotlin.test.assertEquals\nclass HashUtilsTest {\n@Test\n- fun simple() {\n- //HashUtil.sha256asByteArray()\n+ fun testSha256asByteArrayEmpty() {\n+ val res = HashUtil.sha256asByteArray(byteArrayOf())\n+ println(res.contentToString())\n+ val expected = byteArrayOf(-29, -80, -60, 66, -104, -4, 28, 20, -102, -5, -12, -56, -103, 111, -71, 36, 39, -82, 65, -28, 100, -101, -109, 76, -92, -107, -103, 27, 120, 82, -72, 85)\n+ assertEquals(expected.toList(), res.toList())\n+ }\n+\n+ @Test\n+ fun testSha256asByteArraySimpleAllLowAndPositive() {\n+ val res = HashUtil.sha256asByteArray(byteArrayOf(1, 2, 40, 89))\n+ println(res.contentToString())\n+ val expected = byteArrayOf(-18, 75, 82, -32, -61, -85, 15, -49, -23, 60, 65, -113, -97, 122, -108, -68, -117, -128, 80, -18, -22, 39, -107, 14, 105, 99, -14, 115, 89, 46, 67, 19)\n+ assertEquals(expected.toList(), res.toList())\n+ }\n+\n+ @Test\n+ fun testSha256asByteArraySimple() {\n+ val res = HashUtil.sha256asByteArray(byteArrayOf(1, 2, -40, 89))\n+ println(res.contentToString())\n+ val expected = byteArrayOf(94, 40, 23, 48, -40, -11, 56, 18, 59, 104, 37, -82, 114, 9, 115, -44, 47, -70, -67, -102, -58, -75, -40, -66, -18, 83, 50, -95, 94, -87, 97, -63)\n+ assertEquals(expected.toList(), res.toList())\n}\n}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "diff": "@@ -6,6 +6,17 @@ import kotlin.browser.window\n@JsModule(\"js-sha256\")\nexternal fun sha256(s: String): String\n+@JsNonModule\n+@JsModule(\"js-sha256\")\n+external fun sha256(s: ByteArray): String\n+\n+@JsNonModule\n+@JsModule(\"js-sha256\")\n+external object sha256 {\n+ fun array(s: IntArray) : IntArray\n+}\n+\n+\n// Just to avoid having this shadowed in HashUtil...\nfun wrapperSha256(s: String) = sha256(s)\n@@ -35,7 +46,9 @@ actual object HashUtil {\n}\nactual fun sha256asByteArray(input: ByteArray?): ByteArray {\n- TODO(\"Not yet implemented\")\n+ require(input != null)\n+ val preparedInput = input.map { if (it < 0) (it + 256).toInt() else it.toInt() }.toIntArray()\n+ return sha256.array(preparedInput).map { if (it >= 128) (it - 256).toByte() else it.toByte() }.toByteArray()\n}\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
fix HashUtils for js
426,504
09.08.2020 11:19:47
-7,200
7bfb937c8cd559f3d35e033783dbc7efd95b8efc
fix HashUtils on JS
[ { "change_type": "MODIFY", "old_path": "model-client/build.gradle", "new_path": "model-client/build.gradle", "diff": "@@ -67,6 +67,7 @@ kotlin {\nimplementation kotlin('stdlib-js')\nimplementation(npm(\"uuid\", \"^8.3.0\"))\nimplementation(npm(\"js-sha256\", \"^0.9.0\"))\n+ implementation(npm(\"js-base64\", \"^3.4.5\"))\n}\n}\njsTest {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "diff": "@@ -22,6 +22,7 @@ expect object HashUtil {\nfun isSha256(value: String?): Boolean\nfun extractSha256(input: String?): Iterable<String>\nfun base64encode(input: String): String\n+ fun base64encode(input: ByteArray): String\nfun base64decode(input: String): String\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/HashUtilsTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/HashUtilsTest.kt", "diff": "@@ -9,7 +9,6 @@ class HashUtilsTest {\n@Test\nfun testSha256asByteArrayEmpty() {\nval res = HashUtil.sha256asByteArray(byteArrayOf())\n- println(res.contentToString())\nval expected = byteArrayOf(-29, -80, -60, 66, -104, -4, 28, 20, -102, -5, -12, -56, -103, 111, -71, 36, 39, -82, 65, -28, 100, -101, -109, 76, -92, -107, -103, 27, 120, 82, -72, 85)\nassertEquals(expected.toList(), res.toList())\n}\n@@ -17,7 +16,6 @@ class HashUtilsTest {\n@Test\nfun testSha256asByteArraySimpleAllLowAndPositive() {\nval res = HashUtil.sha256asByteArray(byteArrayOf(1, 2, 40, 89))\n- println(res.contentToString())\nval expected = byteArrayOf(-18, 75, 82, -32, -61, -85, 15, -49, -23, 60, 65, -113, -97, 122, -108, -68, -117, -128, 80, -18, -22, 39, -107, 14, 105, 99, -14, 115, 89, 46, 67, 19)\nassertEquals(expected.toList(), res.toList())\n}\n@@ -25,8 +23,31 @@ class HashUtilsTest {\n@Test\nfun testSha256asByteArraySimple() {\nval res = HashUtil.sha256asByteArray(byteArrayOf(1, 2, -40, 89))\n- println(res.contentToString())\nval expected = byteArrayOf(94, 40, 23, 48, -40, -11, 56, 18, 59, 104, 37, -82, 114, 9, 115, -44, 47, -70, -67, -102, -58, -75, -40, -66, -18, 83, 50, -95, 94, -87, 97, -63)\nassertEquals(expected.toList(), res.toList())\n}\n+\n+ @Test\n+ fun testSha256Empty() {\n+ val res = HashUtil.sha256(byteArrayOf())\n+ assertEquals(\"47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU\", res)\n+ }\n+\n+ @Test\n+ fun testBase64encodeByteArrayEmpty() {\n+ val res = HashUtil.base64encode(ByteArray(0))\n+ assertEquals(\"\", res)\n+ }\n+\n+ @Test\n+ fun testBase64encodeByteArraySimplePositive() {\n+ val res = HashUtil.base64encode(byteArrayOf(1, 10, 87))\n+ assertEquals(\"AQpX\", res)\n+ }\n+\n+ @Test\n+ fun testBase64encodeByteArrayMedium() {\n+ val res = HashUtil.base64encode(byteArrayOf(-125, 127, 20, 88, 12, 1, 0))\n+ assertEquals(\"g38UWAwBAA\", res)\n+ }\n}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "diff": "@@ -20,9 +20,16 @@ external object sha256 {\n// Just to avoid having this shadowed in HashUtil...\nfun wrapperSha256(s: String) = sha256(s)\n+@JsModule(\"js-base64\")\n+@JsNonModule\n+external object Base64 {\n+ fun fromUint8Array(input: ByteArray, uriSafe: Boolean) : String\n+}\n+\nactual object HashUtil {\nactual fun sha256(input: ByteArray?): String {\n- TODO(\"Not yet implemented\")\n+ val sha256Bytes = sha256asByteArray(input)\n+ return base64encode(sha256Bytes)\n}\nactual fun sha256(input: String): String {\n@@ -50,6 +57,10 @@ actual object HashUtil {\nval preparedInput = input.map { if (it < 0) (it + 256).toInt() else it.toInt() }.toIntArray()\nreturn sha256.array(preparedInput).map { if (it >= 128) (it - 256).toByte() else it.toByte() }.toByteArray()\n}\n+\n+ actual fun base64encode(input: ByteArray): String {\n+ return Base64.fromUint8Array(input, true)\n+ }\n}\n@ExperimentalStdlibApi\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "diff": "@@ -86,6 +86,10 @@ actual object HashUtil {\nreturn Base64.getUrlEncoder().withoutPadding().encodeToString(input.toByteArray(UTF8))\n}\n+ actual fun base64encode(input: ByteArray): String {\n+ return Base64.getUrlEncoder().withoutPadding().encodeToString(input)\n+ }\n+\nactual fun base64decode(input: String): String {\nreturn String(Base64.getUrlDecoder().decode(input.toByteArray(UTF8)), UTF8)\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
fix HashUtils on JS
426,504
09.08.2020 11:27:27
-7,200
8f52e7073e792c01e5ba8fce5cae167011c62e69
fix uuid for js
[ { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/PlatformSpecific.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/PlatformSpecific.kt", "diff": "@@ -34,8 +34,10 @@ actual fun <K, V> createLRUMap(size: Int): MutableMap<K, V> {\n@JsModule(\"uuid\")\n@JsNonModule\n-external fun uuidv4(): String\n+external object uuid {\n+ fun v4(): String\n+}\nactual fun randomUUID(): String {\n- return uuidv4()\n+ return uuid.v4()\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/HashUtil.kt", "diff": "@@ -45,10 +45,12 @@ actual object HashUtil {\n}\nactual fun base64encode(input: String): String {\n+ // QUESTION: can we do that on NodeJS?\nreturn window.btoa(input)\n}\nactual fun base64decode(input: String): String {\n+ // QUESTION: can we do that on NodeJS?\nreturn window.atob(input)\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
fix uuid for js
426,504
09.08.2020 11:40:55
-7,200
c0af85535530a296429048e276543f44c6c0bb2b
fix path to gradle
[ { "change_type": "MODIFY", "old_path": ".github/workflows/modelclient.yml", "new_path": ".github/workflows/modelclient.yml", "diff": "@@ -14,7 +14,7 @@ jobs:\nwith:\njava-version: 11\n- name: Run tests for model client\n- run: cd model-client && ./gradlew compileKotlinJs compileKotlinJvm\n+ run: cd model-client && ../gradlew compileKotlinJs compileKotlinJvm\njvmTest:\n@@ -27,7 +27,7 @@ jobs:\nwith:\njava-version: 11\n- name: Run tests for model client\n- run: cd model-client && ./gradlew jvmTest\n+ run: cd model-client && ../gradlew jvmTest\njsTest:\n@@ -40,7 +40,7 @@ jobs:\nwith:\njava-version: 11\n- name: Run tests for model client\n- run: cd model-client && ./gradlew jsTest\n+ run: cd model-client && ../gradlew jsTest\nlint:\n@@ -53,4 +53,4 @@ jobs:\nwith:\njava-version: 11\n- name: Run tests for model client\n- run: cd model-client && ./gradlew ktlintCheck\n\\ No newline at end of file\n+ run: cd model-client && ../gradlew ktlintCheck\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
fix path to gradle
426,496
09.08.2020 11:38:23
-7,200
08434b9205088433c67c4dc03b0d29b8d2c54479
Tree_Test now also tests deserialization
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPNode.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPNode.kt", "diff": "@@ -191,13 +191,13 @@ class CPNode protected constructor(id1: Long, val concept: String?, parentId1: L\n@JvmStatic\nfun deserialize(input: String): CPNode {\nreturn try {\n- val parts = input.split(\"/\").dropLastWhile { it.isEmpty() }.toTypedArray()\n+ val parts = input.split(\"/\")\nval properties = parts[5].split(\",\")\n.filter { cs: String? -> !cs.isNullOrEmpty() }\n- .map { it: String -> it.split(\"=\").dropLastWhile { it.isEmpty() }.toTypedArray() }\n+ .map { it: String -> it.split(\"=\") }\nval references = parts[6].split(\",\")\n.filter { cs: String? -> !cs.isNullOrEmpty() }\n- .map { it: String -> it.split(\"=\").dropLastWhile { it.isEmpty() }.toTypedArray() }\n+ .map { it: String -> it.split(\"=\") }\nCPNode(\nlongFromHex(parts[0]),\nunescape(parts[1]),\n@@ -207,12 +207,10 @@ class CPNode protected constructor(id1: Long, val concept: String?, parentId1: L\n.filter { cs: String? -> !cs.isNullOrEmpty() }\n.map { obj: String -> SerializationUtil.longFromHex(obj) }\n.toLongArray(),\n- properties.map { it: Array<String> -> unescape(it[0])!! }.toTypedArray(),\n- properties.map { it: Array<String> -> unescape(it[1])!! }.toTypedArray(),\n- references.map { it: Array<String> -> unescape(it[0])!! }.toTypedArray(),\n- references\n- .map { it: Array<String> -> fromString(unescape(it[1])!!) }\n- .toTypedArray()\n+ properties.map { unescape(it[0])!! }.toTypedArray(),\n+ properties.map { unescape(it[1])!! }.toTypedArray(),\n+ references.map { unescape(it[0])!! }.toTypedArray(),\n+ references.map { fromString(unescape(it[1])!!) }.toTypedArray()\n)\n} catch (ex: Exception) {\nthrow RuntimeException(\"Failed to deserialize $input\", ex)\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/Tree_Test.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/Tree_Test.kt", "diff": "@@ -42,6 +42,7 @@ class Tree_Test {\nval expectedRoles: MutableMap<Long, String> = HashMap()\nval expectedDeletes: MutableSet<Long> = HashSet()\nfor (i in 0..9999) {\n+ if (i % 1000 == 0) storeCache.clearCache()\nwhen (rand.nextInt(5)) {\n0 -> // Delete node\n{\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Tree_Test now also tests deserialization
426,496
09.08.2020 12:46:55
-7,200
38f82ec07daab7abf53682a729b79e8efe366b09
Add coverage (jacoco) configuration to the model-client
[ { "change_type": "MODIFY", "old_path": "model-client/build.gradle", "new_path": "model-client/build.gradle", "diff": "@@ -4,6 +4,8 @@ plugins {\nid 'org.jetbrains.kotlin.multiplatform'\nid \"com.diffplug.gradle.spotless\"\nid \"org.jlleitschuh.gradle.ktlint\"\n+ id \"java-library\"\n+ id 'jacoco'\n}\nconfigurations {\n@@ -80,6 +82,19 @@ kotlin {\n}\n}\n+tasks.jacocoTestReport {\n+\n+ classDirectories.setFrom(\"${buildDir}/classes/kotlin/jvm/\")\n+ sourceDirectories.setFrom(files(\"src/commonMain/kotlin\", \"src/jvmMain/kotlin\"))\n+\n+ executionData.setFrom(files(\"${buildDir}/jacoco/jvmTest.exec\"))\n+\n+ reports {\n+ xml.enabled true\n+ html.enabled true\n+ }\n+}\n+\nspotless {\nkotlin {\nlicenseHeader '/*\\n' +\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Add coverage (jacoco) configuration to the model-client
426,504
09.08.2020 13:26:57
-7,200
ec5393d22ece00c3509ba90aed1ccc0a3f23327e
adding additional checks on hashes
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "diff": "@@ -71,10 +71,13 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal> {\nreturn bulkQuery.constant(null) as IBulkQuery.Value<CLHamtNode<*>?>\n}\nval physicalIndex = logicalToPhysicalIndex(data_.bitmap, logicalIndex)\n- return getChild(data_.children[physicalIndex], bulkQuery)\n+ val childHash = data_.children[physicalIndex]\n+ require(childHash.length == 64) { \"Invalid child hash found for logicalIndex=$logicalIndex -> physicalIndex=$physicalIndex\" }\n+ return getChild(childHash, bulkQuery)\n}\nprotected fun getChild(childHash: String, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n+ require(childHash.length == 64) { \"hash has not expected format: '$childHash'\" }\nreturn bulkQuery[childHash, CPHamtNode.DESERIALIZER].map { childData -> create(childData, store) }\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/NonBulkQuery.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/NonBulkQuery.kt", "diff": "@@ -26,6 +26,7 @@ class NonBulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery\n}\noverride fun <T> get(hash: String, deserializer: (String) -> T): IBulkQuery.Value<T?> {\n+ require(hash.length == 64) { \"hash has not expected format: '$hash'\" }\nreturn constant(store[hash, deserializer] ?: throw RuntimeException(\"store expected to have entry for hash=$hash, deserializer=$deserializer\"))\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
adding additional checks on hashes
426,504
09.08.2020 13:30:35
-7,200
a119f482c0cc97f5487654411c9792ca114e8c41
catch access out of bounds in CLHamtInternal
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "diff": "@@ -71,6 +71,7 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal> {\nreturn bulkQuery.constant(null) as IBulkQuery.Value<CLHamtNode<*>?>\n}\nval physicalIndex = logicalToPhysicalIndex(data_.bitmap, logicalIndex)\n+ require(physicalIndex < data_.children.size) { \"Invalid physical index ($physicalIndex). N. children: ${data_.children.size}. Logical index: $logicalIndex\" }\nval childHash = data_.children[physicalIndex]\nrequire(childHash.length == 64) { \"Invalid child hash found for logicalIndex=$logicalIndex -> physicalIndex=$physicalIndex\" }\nreturn getChild(childHash, bulkQuery)\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
catch access out of bounds in CLHamtInternal
426,504
09.08.2020 13:36:25
-7,200
d30a83932cc8ca52ab67da105f0d31e31063e4a0
removing wrong check on hashes
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "diff": "@@ -73,12 +73,10 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal> {\nval physicalIndex = logicalToPhysicalIndex(data_.bitmap, logicalIndex)\nrequire(physicalIndex < data_.children.size) { \"Invalid physical index ($physicalIndex). N. children: ${data_.children.size}. Logical index: $logicalIndex\" }\nval childHash = data_.children[physicalIndex]\n- require(childHash.length == 64) { \"Invalid child hash found for logicalIndex=$logicalIndex -> physicalIndex=$physicalIndex\" }\nreturn getChild(childHash, bulkQuery)\n}\nprotected fun getChild(childHash: String, bulkQuery: IBulkQuery): IBulkQuery.Value<CLHamtNode<*>?> {\n- require(childHash.length == 64) { \"hash has not expected format: '$childHash'\" }\nreturn bulkQuery[childHash, CPHamtNode.DESERIALIZER].map { childData -> create(childData, store) }\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/NonBulkQuery.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/NonBulkQuery.kt", "diff": "@@ -26,7 +26,6 @@ class NonBulkQuery(private val store: IDeserializingKeyValueStore) : IBulkQuery\n}\noverride fun <T> get(hash: String, deserializer: (String) -> T): IBulkQuery.Value<T?> {\n- require(hash.length == 64) { \"hash has not expected format: '$hash'\" }\nreturn constant(store[hash, deserializer] ?: throw RuntimeException(\"store expected to have entry for hash=$hash, deserializer=$deserializer\"))\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
removing wrong check on hashes
426,504
09.08.2020 13:56:48
-7,200
f7e175dd955fe77bdef2bb6fd4235917bc26ec52
adding test_random_case_causing_outofbounds_on_js
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/Hamt_Test.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/Hamt_Test.kt", "diff": "@@ -58,4 +58,22 @@ class Hamt_Test {\n}\n}\n}\n+\n+ @Test\n+ fun test_random_case_causing_outofbounds_on_js() {\n+ val store = MapBaseStore()\n+ val storeCache = ObjectStoreCache(store)\n+ var hamt: CLHamtNode<*>? = CLHamtInternal(storeCache)\n+\n+ hamt = hamt!!.put(965L, \"-6579471327666419615\")\n+ hamt = hamt!!.put(949L, \"4912341421267007347\")\n+ hamt = hamt!!.put(260L, \"4166750678024106842\")\n+ hamt = hamt!!.put(794L, \"5492533034562136353\")\n+ hamt = hamt!!.put(104L, \"-6505928823483070382\")\n+ hamt = hamt!!.put(47L, \"3122507882718949737\")\n+ hamt = hamt!!.put(693L, \"-2086105010854963537\")\n+ storeCache.clearCache()\n+ assertEquals(\"-2086105010854963537\", hamt!![693L])\n+ }\n+\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
adding test_random_case_causing_outofbounds_on_js
426,496
09.08.2020 14:26:41
-7,200
ffdcdc30bd1eac3494be272c027d9ea2efbd1e1e
Tests for OTBranch
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "@@ -27,7 +27,7 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\noverride fun apply(transaction: IWriteTransaction): IAppliedOperation {\nval concept = transaction.getConcept(childId)\ntransaction.deleteNode(childId)\n- return Applied(concept!!)\n+ return Applied(concept)\n}\noverride fun transform(previous: IOperation): IOperation {\n@@ -99,7 +99,7 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\nreturn \"DeleteNodeOp ${SerializationUtil.longToHex(childId)}, ${SerializationUtil.longToHex(parentId)}.$role[$index]\"\n}\n- inner class Applied(private val concept: IConcept) : AbstractOperation.Applied(), IAppliedOperation {\n+ inner class Applied(private val concept: IConcept?) : AbstractOperation.Applied(), IAppliedOperation {\noverride val originalOp: IOperation\nget() = this@DeleteNodeOp\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/OTBranch.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/OTBranch.kt", "diff": "@@ -83,12 +83,12 @@ class OTBranch(private val branch: IBranch, private val idGenerator: IIdGenerato\nbranch.runWrite(runnable)\n}\n- fun wrap(t: ITransaction?): ITransaction {\n- return if (t is IWriteTransaction) wrap(t as IWriteTransaction?) else t!!\n+ fun wrap(t: ITransaction): ITransaction {\n+ return if (t is IWriteTransaction) wrap(t) else t\n}\n- fun wrap(t: IWriteTransaction?): IWriteTransaction {\n- return OTWriteTransaction(t!!, this, idGenerator)\n+ fun wrap(t: IWriteTransaction): IWriteTransaction {\n+ return OTWriteTransaction(t, this, idGenerator)\n}\nprotected fun checkNotEDT() {}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "diff": "@@ -27,7 +27,7 @@ import org.modelix.model.logDebug\nclass OTWriteTransaction(private val transaction: IWriteTransaction, private val otBranch: OTBranch, protected var idGenerator: IIdGenerator) : IWriteTransaction {\nprotected fun apply(op: IOperation) {\n- logDebug({ \"apply: $op\" }, OTWriteTransaction::class)\n+ //logDebug({ \"apply: $op\" }, OTWriteTransaction::class)\nval appliedOp = op.apply(transaction)\notBranch.operationApplied(appliedOp)\n}\n@@ -40,30 +40,30 @@ class OTWriteTransaction(private val transaction: IWriteTransaction, private val\nif (newIndex == -1) {\nnewIndex = getChildren(newParentId, newRole).count()\n}\n- apply(MoveNodeOp(childId, oldparent, oldRole!!, oldIndex, newParentId, newRole!!, newIndex))\n+ apply(MoveNodeOp(childId, oldparent, oldRole, oldIndex, newParentId, newRole, newIndex))\n}\noverride fun setProperty(nodeId: Long, role: String, value: String?) {\n- apply(SetPropertyOp(nodeId, role!!, value!!))\n+ apply(SetPropertyOp(nodeId, role, value))\n}\noverride fun setReferenceTarget(sourceId: Long, role: String, target: INodeReference?) {\n- apply(SetReferenceOp(sourceId, role!!, target!!))\n+ apply(SetReferenceOp(sourceId, role, target))\n}\noverride fun addNewChild(parentId: Long, role: String?, index: Int, childId: Long, concept: IConcept?) {\nvar index = index\nif (index == -1) {\n- index = getChildren(parentId, role)!!.count().toInt()\n+ index = getChildren(parentId, role).count().toInt()\n}\n- apply(AddNewChildOp(parentId, role!!, index, childId, concept!!))\n+ apply(AddNewChildOp(parentId, role, index, childId, concept))\n}\noverride fun deleteNode(nodeId: Long) {\nval parent = getParent(nodeId)\nval role = getRole(nodeId)\nval index = getChildren(parent, role).indexOf(nodeId)\n- apply(DeleteNodeOp(parent, role!!, index, nodeId))\n+ apply(DeleteNodeOp(parent, role, index, nodeId))\n}\noverride fun addNewChild(parentId: Long, role: String?, index: Int, concept: IConcept?): Long {\n@@ -113,7 +113,7 @@ class OTWriteTransaction(private val transaction: IWriteTransaction, private val\nthrow UnsupportedOperationException()\n}\n- protected fun wrap(node: INode?): INode {\n- return if (node is PNodeAdapter) PNodeAdapter(node.nodeId, otBranch) else node!!\n+ protected fun wrap(node: INode): INode {\n+ return if (node is PNodeAdapter) PNodeAdapter(node.nodeId, otBranch) else node\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/SetReferenceOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/SetReferenceOp.kt", "diff": "@@ -23,7 +23,7 @@ class SetReferenceOp(val sourceId: Long, val role: String, val target: INodeRefe\noverride fun apply(transaction: IWriteTransaction): IAppliedOperation {\nval oldValue = transaction.getReferenceTarget(sourceId, role)\ntransaction.setReferenceTarget(sourceId, role, target)\n- return Applied(oldValue!!)\n+ return Applied(oldValue)\n}\noverride fun transform(previous: IOperation): IOperation {\n@@ -50,7 +50,7 @@ class SetReferenceOp(val sourceId: Long, val role: String, val target: INodeRefe\nreturn \"SetReferenceOp ${SerializationUtil.longToHex(sourceId)}.$role = $target\"\n}\n- inner class Applied(private val oldValue: INodeReference) : AbstractOperation.Applied(), IAppliedOperation {\n+ inner class Applied(private val oldValue: INodeReference?) : AbstractOperation.Applied(), IAppliedOperation {\noverride val originalOp: IOperation\nget() = this@SetReferenceOp\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/OperationsTest.kt", "diff": "+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.modelix.model\n+\n+import org.modelix.model.api.PBranch\n+import org.modelix.model.operations.OTBranch\n+import kotlin.test.Test\n+\n+class OperationsTest : TreeTestBase() {\n+ @Test\n+ fun test_random() {\n+ val branch1 = OTBranch(PBranch(initialTree, idGenerator), idGenerator)\n+ val branch2 = OTBranch(PBranch(initialTree, idGenerator), idGenerator)\n+\n+ for (i in 0..999) {\n+ if (i % 100 == 0) storeCache.clearCache()\n+\n+ applyRandomChange(branch1)\n+\n+ val (ops, _) = branch1.operationsAndTree\n+ branch2.runWrite { ops.forEach { it.originalOp.apply(branch2.writeTransaction) } }\n+\n+ assertBranch(branch1)\n+ assertBranch(branch2)\n+ }\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/TreeTestBase.kt", "diff": "+/*\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied. See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+\n+package org.modelix.model\n+\n+import org.modelix.model.api.IBranch\n+import org.modelix.model.api.ITree\n+import org.modelix.model.api.PBranch\n+import org.modelix.model.api.PNodeReference\n+import org.modelix.model.client.IdGenerator\n+import org.modelix.model.lazy.CLTree\n+import org.modelix.model.lazy.ObjectStoreCache\n+import org.modelix.model.persistent.MapBaseStore\n+import kotlin.random.Random\n+import kotlin.test.BeforeTest\n+import kotlin.test.assertEquals\n+import kotlin.test.assertFalse\n+\n+open class TreeTestBase {\n+ protected val DEBUG = false\n+ protected var expectedChildren: MutableMap<Pair<Long, String?>, MutableList<Long?>>? = null\n+ protected val roles: List<String> = listOf(\"role1\", \"role2\", \"role3\")\n+ protected var rand: Random = Random(83569)\n+ protected var store: MapBaseStore = MapBaseStore()\n+ protected var storeCache: ObjectStoreCache = ObjectStoreCache(store)\n+ protected var idGenerator: IdGenerator = IdGenerator(3)\n+ protected var initialTree: CLTree = CLTree(storeCache)\n+ protected var expectedParents: MutableMap<Long, Long> = HashMap()\n+ protected var expectedRoles: MutableMap<Long, String> = HashMap()\n+ protected var expectedDeletes: MutableSet<Long> = HashSet()\n+\n+ @BeforeTest\n+ fun setUp() {\n+ expectedChildren = HashMap()\n+ rand = Random(83569)\n+ store = MapBaseStore()\n+ storeCache = ObjectStoreCache(store)\n+ idGenerator = IdGenerator(3)\n+ initialTree = CLTree(storeCache)\n+ expectedParents = HashMap()\n+ expectedRoles = HashMap()\n+ expectedDeletes = HashSet()\n+ }\n+\n+ fun applyRandomChange(tree: ITree): ITree {\n+ val branch = PBranch(tree, idGenerator)\n+ applyRandomChange(branch)\n+ return branch.computeRead { branch.transaction.tree }\n+ }\n+\n+ fun applyRandomChange(branch: IBranch) {\n+ branch.runWrite {\n+ val t = branch.writeTransaction\n+ when (rand.nextInt(5)) {\n+ 0 -> // Delete node\n+ {\n+ val nodeToDelete = TreeTestUtil(t.tree, rand).randomLeafNode\n+ if (nodeToDelete != 0L && nodeToDelete != ITree.ROOT_ID) {\n+ if (DEBUG) {\n+ println(\"Delete $nodeToDelete\")\n+ }\n+ t.deleteNode(nodeToDelete)\n+ removeChild(expectedParents[nodeToDelete]!!, expectedRoles[nodeToDelete], nodeToDelete)\n+ expectedParents[nodeToDelete] = 0L\n+ expectedRoles.remove(nodeToDelete)\n+ expectedDeletes.add(nodeToDelete)\n+ }\n+ }\n+ 1 -> // New node\n+ {\n+ val parent = TreeTestUtil(t.tree, rand).randomNodeWithRoot\n+ if (parent != 0L) {\n+ val childId = idGenerator.generate()\n+ val role = roles[rand.nextInt(roles.size)]\n+ val index = if (rand.nextBoolean()) rand.nextInt(t.getChildren(parent, role).count().toInt() + 1) else -1\n+ if (DEBUG) {\n+ println(\"AddNew $childId to $parent.$role[$index]\")\n+ }\n+ t.addNewChild(parent, role, index, childId, null)\n+ expectedParents[childId] = parent\n+ expectedRoles[childId] = role\n+ insertChild(parent, role, index, childId)\n+ }\n+ }\n+ 2 -> // Set property\n+ {\n+ val nodeId = TreeTestUtil(t.tree, rand).randomNodeWithoutRoot\n+ if (nodeId != 0L) {\n+ val role = roles[rand.nextInt(roles.size)]\n+ val value = rand.nextLong().toString()\n+ if (DEBUG) {\n+ println(\"SetProperty $nodeId.$role = $value\")\n+ }\n+ t.setProperty(nodeId, role, value)\n+ }\n+ }\n+ 3 -> // Set reference\n+ {\n+ val sourceId = TreeTestUtil(t.tree, rand).randomNodeWithoutRoot\n+ val targetId = TreeTestUtil(t.tree, rand).randomNodeWithoutRoot\n+ if (sourceId != 0L && targetId != 0L) {\n+ val role = roles[rand.nextInt(roles.size)]\n+ if (DEBUG) {\n+ println(\"SetReference $sourceId.$role = $targetId\")\n+ }\n+ t.setReferenceTarget(sourceId, role, PNodeReference(targetId))\n+ }\n+ }\n+ 4 -> // Move node\n+ {\n+ val util = TreeTestUtil(t.tree, rand)\n+ val childId = util.randomNodeWithoutRoot\n+ val parent = util.getRandomNode(\n+ util\n+ .allNodes\n+ .filter { it: Long -> util.getAncestors(it, true).none { it2: Long -> it2 == childId } }\n+ )\n+ if (childId != 0L && parent != 0L) {\n+ val role = roles[rand.nextInt(roles.size)]\n+ var index = if (rand.nextBoolean()) rand.nextInt(t.getChildren(parent, role)!!.count().toInt() + 1) else -1\n+ if (DEBUG) {\n+ println(\"MoveNode $childId to $parent.$role[$index]\")\n+ }\n+ t.moveChild(parent, role, index, childId)\n+ val oldParent = expectedParents[childId]!!\n+ val oldRole = expectedRoles[childId]\n+ if (oldParent == parent && oldRole == role) {\n+ val oldIndex = expectedChildren!![Pair(oldParent, oldRole)]!!.indexOf(childId)\n+ if (oldIndex < index) {\n+ index--\n+ }\n+ }\n+ removeChild(oldParent, oldRole, childId)\n+ expectedParents[childId] = parent\n+ expectedRoles[childId] = role\n+ insertChild(parent, role, index, childId)\n+ }\n+ }\n+ }\n+ }\n+ }\n+\n+ fun assertBranch(branch: IBranch) {\n+ assertTree(branch.computeRead { branch.transaction.tree })\n+ }\n+\n+ fun assertTree(tree: ITree) {\n+ for ((key, expectedParent) in expectedParents) {\n+ if (expectedParent == 0L) {\n+ assertFalse(tree.containsNode(key))\n+ } else {\n+ val actualParent = tree.getParent(key)\n+ assertEquals(expectedParent, actualParent)\n+ }\n+ }\n+ for ((key, value) in expectedChildren!!) {\n+ if (expectedDeletes.contains(key.first)) {\n+ continue\n+ }\n+ val expected = value.toList()\n+ val actual = tree.getChildren(key.first, key.second).toList()\n+ assertEquals(expected, actual)\n+ }\n+ for ((key, value) in expectedRoles) {\n+ assertEquals(value, tree.getRole(key))\n+ }\n+ for (node in expectedDeletes) {\n+ assertFalse(tree.containsNode(node))\n+ }\n+ }\n+\n+ fun insertChild(parent: Long, role: String?, index: Int, child: Long) {\n+ val list = expectedChildren!!.getOrPut(Pair(parent, role), { ArrayList() })\n+ if (index == -1) {\n+ list.add(child)\n+ } else {\n+ list.add(index, child)\n+ }\n+ }\n+\n+ fun removeChild(parent: Long, role: String?, child: Long) {\n+ val list = expectedChildren!!.getOrPut(Pair(parent, role), { ArrayList() })\n+ list.remove(child)\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/Tree_Test.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/Tree_Test.kt", "diff": "package org.modelix.model\nimport org.modelix.model.api.ITree\n-import org.modelix.model.api.PNodeReference\n-import org.modelix.model.lazy.CLTree\n-import org.modelix.model.lazy.ObjectStoreCache\n-import org.modelix.model.persistent.MapBaseStore\n-import kotlin.random.Random\n-import kotlin.test.BeforeTest\nimport kotlin.test.Test\n-import kotlin.test.assertEquals\n-import kotlin.test.assertFalse\n-\n-class Tree_Test {\n- private val DEBUG = false\n- private var expectedChildren: MutableMap<Pair<Long, String?>, MutableList<Long?>>? = null\n+class Tree_Test : TreeTestBase() {\n@Test\nfun test_random() {\n- val roles = listOf(\"role1\", \"role2\", \"role3\")\n- val rand = Random(1906823)\n- var idSequence = 1000000L\n- val store = MapBaseStore()\n- val storeCache = ObjectStoreCache(store)\n- var tree: ITree? = CLTree(storeCache)\n- val expectedParents: MutableMap<Long, Long> = HashMap()\n- val expectedRoles: MutableMap<Long, String> = HashMap()\n- val expectedDeletes: MutableSet<Long> = HashSet()\n+ var tree: ITree = initialTree\n+\nfor (i in 0..9999) {\nif (i % 1000 == 0) storeCache.clearCache()\n- when (rand.nextInt(5)) {\n- 0 -> // Delete node\n- {\n- val nodeToDelete = TreeTestUtil(tree!!, rand).randomLeafNode\n- if (nodeToDelete != 0L && nodeToDelete != ITree.ROOT_ID) {\n- if (DEBUG) {\n- println(\"Delete $nodeToDelete\")\n- }\n- tree = tree.deleteNode(nodeToDelete)\n- removeChild(expectedParents[nodeToDelete]!!, expectedRoles[nodeToDelete], nodeToDelete)\n- expectedParents[nodeToDelete] = 0L\n- expectedRoles.remove(nodeToDelete)\n- expectedDeletes.add(nodeToDelete)\n- }\n- }\n- 1 -> // New node\n- {\n- val parent = TreeTestUtil(tree!!, rand).randomNodeWithRoot\n- if (parent != 0L) {\n- val childId = ++idSequence\n- val role = roles[rand.nextInt(roles.size)]\n- val index = if (rand.nextBoolean()) rand.nextInt(tree.getChildren(parent, role)!!.count().toInt() + 1) else -1\n- if (DEBUG) {\n- println(\"AddNew $childId to $parent.$role[$index]\")\n- }\n- tree = tree.addNewChild(parent, role, index, childId, null)\n- expectedParents[childId] = parent\n- expectedRoles[childId] = role\n- insertChild(parent, role, index, childId)\n- }\n- }\n- 2 -> // Set property\n- {\n- val nodeId = TreeTestUtil(tree!!, rand).randomNodeWithoutRoot\n- if (nodeId != 0L) {\n- val role = roles[rand.nextInt(roles.size)]\n- val value = rand.nextLong().toString()\n- if (DEBUG) {\n- println(\"SetProperty $nodeId.$role = $value\")\n- }\n- tree = tree.setProperty(nodeId, role, value)\n- }\n- }\n- 3 -> // Set reference\n- {\n- val sourceId = TreeTestUtil(tree!!, rand).randomNodeWithoutRoot\n- val targetId = TreeTestUtil(tree, rand).randomNodeWithoutRoot\n- if (sourceId != 0L && targetId != 0L) {\n- val role = roles[rand.nextInt(roles.size)]\n- if (DEBUG) {\n- println(\"SetReference $sourceId.$role = $targetId\")\n- }\n- tree = tree.setReferenceTarget(sourceId, role, PNodeReference(targetId))\n- }\n- }\n- 4 -> // Move node\n- {\n- val util = TreeTestUtil(tree!!, rand)\n- val childId = util.randomNodeWithoutRoot\n- val parent = util.getRandomNode(\n- util\n- .allNodes\n- .filter { it: Long -> util.getAncestors(it, true).none { it2: Long -> it2 == childId } }\n- )\n- if (childId != 0L && parent != 0L) {\n- val role = roles[rand.nextInt(roles.size)]\n- var index = if (rand.nextBoolean()) rand.nextInt(tree.getChildren(parent, role)!!.count().toInt() + 1) else -1\n- if (DEBUG) {\n- println(\"MoveNode $childId to $parent.$role[$index]\")\n- }\n- tree = tree.moveChild(parent, role, index, childId)\n- val oldParent = expectedParents[childId]!!\n- val oldRole = expectedRoles[childId]\n- if (oldParent == parent && oldRole == role) {\n- val oldIndex = expectedChildren!![Pair(oldParent, oldRole)]!!.indexOf(childId)\n- if (oldIndex < index) {\n- index--\n- }\n- }\n- removeChild(oldParent, oldRole, childId)\n- expectedParents[childId] = parent\n- expectedRoles[childId] = role\n- insertChild(parent, role, index, childId)\n+ tree = applyRandomChange(tree)\n+ assertTree(tree)\n}\n}\n}\n- for ((key, expectedParent) in expectedParents) {\n- if (expectedParent == 0L) {\n- assertFalse(tree!!.containsNode(key))\n- } else {\n- val actualParent = tree!!.getParent(key)\n- assertEquals(expectedParent, actualParent)\n- }\n- }\n- for ((key, value) in expectedChildren!!) {\n- if (expectedDeletes.contains(key.first)) {\n- continue\n- }\n- val expected = value.toList()\n- val actual = tree!!.getChildren(key.first, key.second).toList()\n- assertEquals(expected, actual)\n- }\n- for ((key, value) in expectedRoles) {\n- assertEquals(value, tree!!.getRole(key))\n- }\n- for (node in expectedDeletes) {\n- assertFalse(tree!!.containsNode(node))\n- }\n- }\n- }\n-\n- @BeforeTest\n- fun setUp() {\n- expectedChildren = HashMap()\n- }\n-\n- fun insertChild(parent: Long, role: String?, index: Int, child: Long) {\n- val list = expectedChildren!!.getOrPut(Pair(parent, role), { ArrayList() })\n- if (index == -1) {\n- list.add(child)\n- } else {\n- list.add(index, child)\n- }\n- }\n-\n- fun removeChild(parent: Long, role: String?, child: Long) {\n- val list = expectedChildren!!.getOrPut(Pair(parent, role), { ArrayList() })\n- list.remove(child)\n- }\n-}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Tests for OTBranch
426,504
09.08.2020 14:39:46
-7,200
fed620c9d7a5d8769b4ee309582c40b0a9bc0d15
working on SerializationUtil.intHex
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLHamtInternal.kt", "diff": "@@ -57,10 +57,12 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal> {\noverride fun get(key: Long, shift: Int, bulkQuery: IBulkQuery): IBulkQuery.Value<String?> {\nval childIndex = (key ushr shift and LEVEL_MASK.toLong()).toInt()\n+ println(\"childIndex $childIndex data_.bitmap ${data_.bitmap}\")\nreturn getChild(childIndex, bulkQuery).mapBulk { child: CLHamtNode<*>? ->\nif (child == null) {\nbulkQuery!!.constant<String?>(null)\n} else {\n+ println(\"getting child $key ${shift + BITS_PER_LEVEL}\")\nchild[key, shift + BITS_PER_LEVEL, bulkQuery]\n}\n}\n@@ -70,7 +72,9 @@ class CLHamtInternal : CLHamtNode<CPHamtInternal> {\nif (isBitNotSet(data_.bitmap, logicalIndex)) {\nreturn bulkQuery.constant(null) as IBulkQuery.Value<CLHamtNode<*>?>\n}\n+ println(\"bitmap ${data_.bitmap} logicalIndex $logicalIndex\")\nval physicalIndex = logicalToPhysicalIndex(data_.bitmap, logicalIndex)\n+ println(\" physicalIndex=$physicalIndex\")\nrequire(physicalIndex < data_.children.size) { \"Invalid physical index ($physicalIndex). N. children: ${data_.children.size}. Logical index: $logicalIndex\" }\nval childHash = data_.children[physicalIndex]\nreturn getChild(childHash, bulkQuery)\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPHamtNode.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPHamtNode.kt", "diff": "@@ -36,7 +36,7 @@ abstract class CPHamtNode {\nCPHamtInternal(\nintFromHex(parts[1]),\nparts[2].split(\",\")\n- .filter { it: String? -> it != null && it.length > 0 }\n+ .filter { it: String? -> it != null && it.isNotEmpty() }\n.toTypedArray()\n)\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/Hamt_Test.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/Hamt_Test.kt", "diff": "@@ -18,6 +18,7 @@ package org.modelix.model\nimport org.modelix.model.lazy.CLHamtInternal\nimport org.modelix.model.lazy.CLHamtNode\nimport org.modelix.model.lazy.ObjectStoreCache\n+import org.modelix.model.persistent.CPHamtInternal\nimport org.modelix.model.persistent.MapBaseStore\nimport kotlin.random.Random\nimport kotlin.test.Test\n@@ -66,13 +67,24 @@ class Hamt_Test {\nvar hamt: CLHamtNode<*>? = CLHamtInternal(storeCache)\nhamt = hamt!!.put(965L, \"-6579471327666419615\")\n+// assertEquals(\"-6579471327666419615\", hamt!![965L])\n+// assertEquals(32, (hamt!!.getData() as CPHamtInternal).bitmap)\n+// assertEquals(1, (hamt!!.getData() as CPHamtInternal).children.count())\n+// assertEquals(listOf(\"p24l1N0LUzZjE_MIT6VZDCPM0bKGGsYHWBFy83BK0cU\"), (hamt!!.getData() as CPHamtInternal).children.toList())\nhamt = hamt!!.put(949L, \"4912341421267007347\")\n+ assertEquals(\"4912341421267007347\", hamt!![949L])\nhamt = hamt!!.put(260L, \"4166750678024106842\")\n+ assertEquals(\"4166750678024106842\", hamt!![260L])\nhamt = hamt!!.put(794L, \"5492533034562136353\")\nhamt = hamt!!.put(104L, \"-6505928823483070382\")\nhamt = hamt!!.put(47L, \"3122507882718949737\")\nhamt = hamt!!.put(693L, \"-2086105010854963537\")\nstoreCache.clearCache()\n+ assertEquals(69239088, (hamt!!.getData() as CPHamtInternal).bitmap)\n+ assertEquals(6, (hamt!!.getData() as CPHamtInternal).children.count())\n+// assertEquals(listOf(\"BLSU-2zGUnB_ZK-OgAh3kVEhS4YU3R_jA3_VdAllIQg\", \"p24l1N0LUzZjE_MIT6VZDCPM0bKGGsYHWBFy83BK0cU\", \"7cQpepwm1iTLDFWEZ7PMZLe8aQGHR9CZATg65H3DM-w\",\n+// \"Xwc0zD4A68wkHL4lJWWw7n9fMUzbypunVbvoflBIHHc\", \"A_WD9BK_TWGYP049z946Ojdu-9XaXLGszwhOiGa0GQM\", \"Ds14kkEICz6xo7WsN4m-CkV4Lk85l5BtiR70NT7xujw\"), (hamt!!.getData() as CPHamtInternal).children.toList())\n+ //assertEquals(4, logicalToPhysicalIndex(69239088, 21))\nassertEquals(\"-2086105010854963537\", hamt!![693L])\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/PlatformSpecific_Test.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/PlatformSpecific_Test.kt", "diff": "@@ -23,4 +23,13 @@ class PlatformSpecific_Test {\n}\n}\n}\n+\n+ @Test\n+ fun testBitCount() {\n+ fun logicalToPhysicalIndex(bitmap: Int, logicalIndex: Int): Int {\n+ return bitCount(bitmap and (1 shl logicalIndex) - 1)\n+ }\n+ assertEquals(4, logicalToPhysicalIndex(69239088, 21))\n+ assertEquals(7, logicalToPhysicalIndex(20200000, 21))\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_intHex_Test.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_intHex_Test.kt", "diff": "@@ -65,4 +65,10 @@ class SerializationUtil_intHex_Test {\nfun intFromHex_msb() {\nassertEquals(1 shl 31, SerializationUtil.intFromHex(\"80000000\"))\n}\n+\n+ // This value seems connected to an issue\n+ @Test\n+ fun intToHex965() {\n+ assertEquals(\"3c5\", SerializationUtil.intToHex(965))\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "package org.modelix.model.persistent\n+import kotlin.math.pow\n+\nactual object SerializationUtil {\nactual fun escape(value: String?): String {\nTODO(\"Not yet implemented\")\n@@ -26,13 +28,13 @@ actual object SerializationUtil {\n*/\nactual fun intToHex(value: Int): String {\nif (value < 0) {\n- TODO(\"Not yet implemented\")\n+ return intToHex(value + 2.0.pow(32).toInt() + 0x80000001.toInt())\n}\nreturn value.toString(16)\n}\nactual fun intFromHex(hex: String): Int {\n- return hex.toInt()\n+ return hex.toLong(16).toInt()\n}\nactual fun nullAsEmptyString(str: String?): String {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
working on SerializationUtil.intHex
426,504
09.08.2020 15:06:12
-7,200
670fe28a0de9b9c2ee569244afb167c32168ef06
fixing serialization of ints and longs to/from hex
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_intHex_Test.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_intHex_Test.kt", "diff": "@@ -36,6 +36,11 @@ class SerializationUtil_intHex_Test {\nassertEquals(-1, SerializationUtil.intFromHex(\"ffffffff\"))\n}\n+ @Test\n+ fun intFromHex_minus3() {\n+ assertEquals(-3, SerializationUtil.intFromHex(\"fffffffd\"))\n+ }\n+\n@Test\nfun intToHex_0() {\nassertEquals(\"0\", SerializationUtil.intToHex(0))\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_longHex_Test.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_longHex_Test.kt", "diff": "@@ -31,6 +31,11 @@ class SerializationUtil_longHex_Test {\nassertEquals(\"ffffffffffffffff\", SerializationUtil.longToHex(-1L))\n}\n+ @Test\n+ fun longToHex_minus3() {\n+ assertEquals(\"fffffffffffffffd\", SerializationUtil.longToHex(-3L))\n+ }\n+\n@Test\nfun longFromHex_minus1() {\nassertEquals(-1L, SerializationUtil.longFromHex(\"ffffffffffffffff\"))\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "@@ -12,11 +12,14 @@ actual object SerializationUtil {\n}\nactual fun longToHex(value: Long): String {\n+ if (value < 0) {\n+ return value.toULong().toString(16)\n+ }\nreturn value.toString(16)\n}\nactual fun longFromHex(hex: String): Long {\n- return hex.toLong(16)\n+ return hex.toULong(16).toLong()\n}\n/**\n@@ -28,7 +31,7 @@ actual object SerializationUtil {\n*/\nactual fun intToHex(value: Int): String {\nif (value < 0) {\n- return intToHex(value + 2.0.pow(32).toInt() + 0x80000001.toInt())\n+ return value.toUInt().toString(16)\n}\nreturn value.toString(16)\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
fixing serialization of ints and longs to/from hex
426,504
09.08.2020 18:28:16
-7,200
87ca97143ace5284c63d897798d7cbbff94ecdb1
implement js encode/decode
[ { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "package org.modelix.model.persistent\n+external fun decodeURIComponent(encodedURI: String): String\n+external fun encodeURIComponent(input: String): String\n+\nactual object SerializationUtil {\n+\n+ private val NULL_ENCODING = \"%00\"\n+ private val SPECIAL_ENCODING = hashMapOf(\n+ '!' to \"%21\",\n+ '\\'' to \"%27\",\n+ '(' to \"%28\",\n+ ')' to \"%29\",\n+ '~' to \"%7E\"\n+ )\n+\nactual fun escape(value: String?): String {\n- TODO(\"Not yet implemented\")\n+ if (value == null) {\n+ return NULL_ENCODING\n+ }\n+ return encodeURIComponent(value).map { SPECIAL_ENCODING[it] ?: it.toString() }.joinToString(separator = \"\")\n}\nactual fun unescape(value: String?): String? {\n- TODO(\"Not yet implemented\")\n+ if (value == NULL_ENCODING) {\n+ return null;\n+ }\n+ return decodeURIComponent(value!!)\n}\nactual fun longToHex(value: Long): String {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
implement js encode/decode
426,504
09.08.2020 18:31:45
-7,200
415f6b454b6fc2b3adce1ef11340f15c2c318085
move emptyStringAsNull and nullAsEmptyString to commonMain
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPVersion.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/CPVersion.kt", "diff": "@@ -19,11 +19,9 @@ import org.modelix.model.logWarning\nimport org.modelix.model.operations.IOperation\nimport org.modelix.model.persistent.HashUtil.isSha256\nimport org.modelix.model.persistent.HashUtil.sha256\n-import org.modelix.model.persistent.SerializationUtil.emptyStringAsNull\nimport org.modelix.model.persistent.SerializationUtil.escape\nimport org.modelix.model.persistent.SerializationUtil.longFromHex\nimport org.modelix.model.persistent.SerializationUtil.longToHex\n-import org.modelix.model.persistent.SerializationUtil.nullAsEmptyString\nimport org.modelix.model.persistent.SerializationUtil.unescape\nclass CPVersion(id: Long, time: String?, author: String?, treeHash: String?, previousVersion: String?, operations: Array<IOperation>?, operationsHash: String?, numberOfOperations: Int) {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "package org.modelix.model.persistent\n+fun nullAsEmptyString(str: String?): String {\n+ if (str == null) {\n+ return \"\"\n+ }\n+ if (str.isEmpty()) {\n+ throw RuntimeException(\"Empty string not allowed\")\n+ }\n+ return str\n+}\n+\n+fun emptyStringAsNull(str: String): String? {\n+ return if (str == null || str.isEmpty()) null else str\n+}\n+\nexpect object SerializationUtil {\nfun escape(value: String?): String\nfun unescape(value: String?): String?\n@@ -22,6 +36,4 @@ expect object SerializationUtil {\nfun longFromHex(hex: String): Long\nfun intToHex(value: Int): String\nfun intFromHex(hex: String): Int\n- fun nullAsEmptyString(str: String?): String\n- fun emptyStringAsNull(str: String): String?\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_nullEmptyString.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/SerializationUtil_nullEmptyString.kt", "diff": "package org.modelix.model\nimport org.modelix.model.persistent.SerializationUtil\n+import org.modelix.model.persistent.emptyStringAsNull\n+import org.modelix.model.persistent.nullAsEmptyString\nimport kotlin.test.Test\nimport kotlin.test.assertEquals\nimport kotlin.test.assertFails\nclass SerializationUtil_nullEmptyString {\n+\n@Test\nfun nullAsEmptyString_null() {\n- assertEquals(\"\", SerializationUtil.nullAsEmptyString(null))\n+ assertEquals(\"\", nullAsEmptyString(null))\n}\n@Test\nfun nullAsEmptyString_emptyString() {\n- assertFails { SerializationUtil.nullAsEmptyString(\"\") }\n+ assertFails { nullAsEmptyString(\"\") }\n}\n@Test\nfun emptyStringAsNull_emptyString() {\n- assertEquals(null, SerializationUtil.emptyStringAsNull(\"\"))\n+ assertEquals(null, emptyStringAsNull(\"\"))\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jsMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "@@ -57,11 +57,4 @@ actual object SerializationUtil {\nreturn hex.toLong(16).toInt()\n}\n- actual fun nullAsEmptyString(str: String?): String {\n- TODO(\"Not yet implemented\")\n- }\n-\n- actual fun emptyStringAsNull(str: String): String? {\n- TODO(\"Not yet implemented\")\n- }\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/persistent/SerializationUtil.kt", "diff": "@@ -51,17 +51,4 @@ actual object SerializationUtil {\nreturn Integer.parseUnsignedInt(hex, 16)\n}\n- actual fun nullAsEmptyString(str: String?): String {\n- if (str == null) {\n- return \"\"\n- }\n- if (str.isEmpty()) {\n- throw RuntimeException(\"Empty string not allowed\")\n- }\n- return str\n- }\n-\n- actual fun emptyStringAsNull(str: String): String? {\n- return if (str == null || str.length == 0) null else str\n- }\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
move emptyStringAsNull and nullAsEmptyString to commonMain
426,496
10.08.2020 17:14:53
-7,200
b26dbc87e2d8431011ae068b108296341fad0072
Conflict resolution tests (2)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -24,6 +24,7 @@ import org.modelix.model.lazy.CLVersion\nimport org.modelix.model.lazy.IDeserializingKeyValueStore\nimport org.modelix.model.operations.IAppliedOperation\nimport org.modelix.model.operations.IOperation\n+import org.modelix.model.operations.IndexAdjustments\nimport org.modelix.model.persistent.CPVersion\nimport kotlin.math.max\n@@ -77,7 +78,8 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nval leftAppliedOps: MutableList<IAppliedOperation> = ArrayList()\nval rightAppliedOps: MutableList<IAppliedOperation> = ArrayList()\nval appliedVersionIds: MutableSet<Long> = HashSet()\n- while (!leftHistory.isEmpty() || !rightHistory.isEmpty()) {\n+ val indexAdjustments = IndexAdjustments()\n+ while (leftHistory.isNotEmpty() || rightHistory.isNotEmpty()) {\nval useLeft = when {\nrightHistory.isEmpty() -> true\nleftHistory.isEmpty() -> false\n@@ -93,7 +95,8 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n.toList()\nvar operationsToApply: List<IOperation> = versionToApply.operations.toList()\nfor (oppositeAppliedOp in oppositeAppliedOps) {\n- operationsToApply = operationsToApply.map { transformOperation(it, oppositeAppliedOp) }.toList()\n+ oppositeAppliedOp.loadAdjustment(indexAdjustments)\n+ operationsToApply = operationsToApply.map { transformOperation(it, oppositeAppliedOp, indexAdjustments) }.toList()\n}\nfor (op in operationsToApply) {\nval appliedOp = op.apply(t)\n@@ -120,9 +123,9 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nreturn mergedVersion!!\n}\n- protected fun transformOperation(opToTransform: IOperation, previousOp: IOperation): IOperation {\n- var result = opToTransform\n- result = result.transform(previousOp)\n+ protected fun transformOperation(opToTransform: IOperation, previousOp: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n+ var result = opToTransform.withAdjustedIndex(indexAdjustments)\n+ result = result.transform(previousOp, indexAdjustments)\nif (opToTransform.toString() != result.toString()) {\nlogDebug({ \"transformed: $opToTransform --> $result ## $previousOp\" }, VersionMerger::class)\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt", "diff": "@@ -343,10 +343,10 @@ class CLTree : ITree {\nvisitor.propertyChanged(newNode.id, role)\n}\n}\n- val oldChildren: Map<String?, MutableList<CLNode>> = HashMap()\n- val newChildren: Map<String?, MutableList<CLNode>> = HashMap()\n- oldNode.getChildren(BulkQuery(store)).execute().forEach { oldChildren.getOrElse(it.roleInParent, { ArrayList() }).add(it) }\n- newNode.getChildren(BulkQuery(store)).execute().forEach { newChildren.getOrElse(it.roleInParent, { ArrayList() }).add(it) }\n+ val oldChildren: MutableMap<String?, MutableList<CLNode>> = HashMap()\n+ val newChildren: MutableMap<String?, MutableList<CLNode>> = HashMap()\n+ oldNode.getChildren(BulkQuery(store)).execute().forEach { oldChildren.getOrPut(it.roleInParent, { ArrayList() }).add(it) }\n+ newNode.getChildren(BulkQuery(store)).execute().forEach { newChildren.getOrPut(it.roleInParent, { ArrayList() }).add(it) }\nval roles: MutableSet<String?> = HashSet()\nroles.addAll(oldChildren.keys)\nroles.addAll(newChildren.keys)\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AbstractOperation.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AbstractOperation.kt", "diff": "@@ -21,4 +21,12 @@ abstract class AbstractOperation : IOperation {\nreturn \"applied:\" + [email protected]()\n}\n}\n+\n+ override fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n+\n+ }\n+\n+ override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n+ return this\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "@@ -20,7 +20,7 @@ import org.modelix.model.api.ITree\nimport org.modelix.model.api.IWriteTransaction\nimport org.modelix.model.persistent.SerializationUtil\n-class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val childId: Long, val concept: IConcept?) : AbstractOperation(), IModifiesChildrenOp {\n+class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val childId: Long, val concept: IConcept?) : AbstractOperation() {\nfun withIndex(newIndex: Int): AddNewChildOp {\nreturn if (newIndex == index) this else AddNewChildOp(parentId, role, newIndex, childId, concept)\n}\n@@ -30,27 +30,17 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\nreturn Applied()\n}\n- override fun transform(previous: IOperation): IOperation {\n+ override fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nreturn when (previous) {\n- is AddNewChildOp -> {\n- if (previous.parentId == parentId && previous.role == role) {\n- if (previous.index <= index) {\n- AddNewChildOp(parentId, role, index + 1, childId, concept)\n- } else {\n- this\n- }\n- } else {\n- this\n- }\n- }\n+ is AddNewChildOp -> this\nis DeleteNodeOp -> {\nif (previous.childId == this.parentId) {\nAddNewChildOp(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0, this.childId, this.concept)\n} else {\n- withIndex(previous.adjustIndex(parentId, role, index))\n+ this\n}\n}\n- is MoveNodeOp -> withIndex(previous.adjustIndex(parentId, role, index))\n+ is MoveNodeOp -> this\nis SetPropertyOp -> this\nis SetReferenceOp -> this\nis NoOp -> this\n@@ -58,12 +48,12 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\n}\n}\n- override fun adjustIndex(otherParentId: Long, otherRole: String?, otherIndex: Int): Int {\n- var adjustedIndex = otherIndex\n- if (otherParentId == parentId && otherRole == role && index <= otherIndex) {\n- adjustedIndex++\n+ override fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n+ indexAdjustments.nodeAdded(parentId, role, index)\n}\n- return adjustedIndex\n+\n+ override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n+ return withIndex(indexAdjustments.getAdjustedIndex(parentId, role, index))\n}\noverride fun toString(): String {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "@@ -19,7 +19,7 @@ import org.modelix.model.api.IConcept\nimport org.modelix.model.api.IWriteTransaction\nimport org.modelix.model.persistent.SerializationUtil\n-class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val childId: Long) : AbstractOperation(), IModifiesChildrenOp {\n+class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val childId: Long) : AbstractOperation() {\nfun withIndex(newIndex: Int): DeleteNodeOp {\nreturn if (newIndex == index) this else DeleteNodeOp(parentId, role, newIndex, childId)\n}\n@@ -38,45 +38,24 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\nreturn Applied(concept)\n}\n- override fun transform(previous: IOperation): IOperation {\n+ override fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nreturn when (previous) {\nis DeleteNodeOp -> {\n- if (parentId == previous.parentId && role == previous.role) {\n- if (previous.index < index) {\n- DeleteNodeOp(parentId, role, index - 1, childId)\n- } else if (previous.index == index) {\n- if (previous.childId != childId) {\n- throw RuntimeException(\"Both operations delete \" + parentId + \".\" + role + \"[\" + index + \"] but with different expected IDs \" + childId + \" and \" + previous.childId)\n- }\n+ if (parentId == previous.parentId && role == previous.role && previous.index == index) {\n+ if (previous.childId == childId) {\n+ // revert the adjustment of the other DeleteOp\n+ indexAdjustments.nodeAdded(parentId, role, index+1)\nNoOp()\n- } else {\n- this\n- }\n- } else {\n- this\n- }\n- }\n- is AddNewChildOp -> {\n- if (parentId == previous.parentId && role == previous.role) {\n- if (previous.index <= index) {\n- DeleteNodeOp(parentId, role, index + 1, childId)\n- } else {\n- this\n- }\n- } else {\n- this\n- }\n+ } else this\n+ } else this\n}\n+ is AddNewChildOp -> this\nis MoveNodeOp -> {\nif (previous.childId == childId) {\nif (previous.sourceParentId != parentId || previous.sourceRole != role || previous.sourceIndex != index) {\nthrow RuntimeException(\"node \" + childId + \" expected to be at \" + parentId + \".\" + role + \"[\" + index + \"]\" + \" but was \" + previous.sourceParentId + \".\" + previous.sourceRole + \"[\" + previous.sourceIndex + \"]\")\n}\nDeleteNodeOp(previous.targetParentId, previous.targetRole, previous.targetIndex, childId)\n- } else if (parentId == previous.targetParentId && role == previous.targetRole) {\n- withIndex(previous.adjustIndex(parentId, role, index))\n- } else if (parentId == previous.sourceParentId && role == previous.sourceRole) {\n- withIndex(previous.adjustIndex(parentId, role, index))\n} else {\nthis\n}\n@@ -88,12 +67,12 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\n}\n}\n- override fun adjustIndex(otherParentId: Long, otherRole: String?, otherIndex: Int): Int {\n- var adjustedIndex = otherIndex\n- if (otherParentId == parentId && otherRole == role && index < otherIndex) {\n- adjustedIndex--\n+ override fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n+ indexAdjustments.nodeRemoved(parentId, role, index)\n}\n- return adjustedIndex\n+\n+ override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n+ return withIndex(indexAdjustments.getAdjustedIndex(parentId, role, index))\n}\noverride fun toString(): String {\n" }, { "change_type": "DELETE", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IModifiesChildrenOp.kt", "new_path": null, "diff": "-/*\n- * Licensed under the Apache License, Version 2.0 (the \"License\");\n- * you may not use this file except in compliance with the License.\n- * You may obtain a copy of the License at\n- *\n- * http://www.apache.org/licenses/LICENSE-2.0\n- *\n- * Unless required by applicable law or agreed to in writing,\n- * software distributed under the License is distributed on an\n- * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n- * KIND, either express or implied. See the License for the\n- * specific language governing permissions and limitations\n- * under the License.\n- */\n-\n-package org.modelix.model.operations\n-\n-interface IModifiesChildrenOp {\n- fun adjustIndex(parentId: Long, role: String?, index: Int): Int\n-}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IOperation.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IOperation.kt", "diff": "@@ -27,5 +27,9 @@ interface IOperation {\n* 'this' needs to be replaced with an operation that applies the same intended change\n* on a model that was modified by 'previous' in the mean time.\n*/\n- fun transform(previous: IOperation): IOperation\n+ fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation\n+\n+ fun loadAdjustment(indexAdjustments: IndexAdjustments)\n+\n+ fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "diff": "+package org.modelix.model.operations\n+\n+\n+class IndexAdjustments {\n+ private val adjustments: MutableMap<Role, MutableList<Adjustment>> = HashMap()\n+\n+ fun nodeRemoved(parent: Long, role: String?, index: Int) {\n+ val ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Adjustment(0, Int.MAX_VALUE, 0)) })\n+ apply(ranges, Adjustment(index + 1, Int.MAX_VALUE, -1))\n+ }\n+\n+ fun nodeAdded(parent: Long, role: String?, index: Int) {\n+ val ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Adjustment(0, Int.MAX_VALUE, 0)) })\n+ apply(ranges, Adjustment(index, Int.MAX_VALUE, 1))\n+ }\n+\n+ fun getAdjustedIndex(parentId: Long, role: String?, index: Int): Int {\n+ return index + (adjustments[Role(parentId, role)]?.find { it.contains(index) }?.adjustment ?: 0)\n+ }\n+\n+ private fun apply(ranges: MutableList<Adjustment>, newAdjustment: Adjustment) {\n+ var i = 0;\n+ while (i < ranges.size) {\n+ if (ranges[i].contains(newAdjustment.from) && ranges[i].from != newAdjustment.from) {\n+ ranges.add(i + 1, Adjustment(newAdjustment.from, ranges[i].to, ranges[i].adjustment))\n+ ranges[i] = Adjustment(ranges[i].from, newAdjustment.from - 1, ranges[i].adjustment)\n+ }\n+ if (ranges[i].contains(newAdjustment.to) && ranges[i].to != newAdjustment.to) {\n+ ranges.add(i + 1, Adjustment(newAdjustment.to + 1, ranges[i].to, ranges[i].adjustment))\n+ ranges[i] = Adjustment(ranges[i].from, newAdjustment.to, ranges[i].adjustment)\n+ }\n+ i++\n+ }\n+ for (i in ranges.indices) {\n+ if (ranges[i].intersects(newAdjustment)) {\n+ require(newAdjustment.contains(ranges[i]))\n+ ranges[i] = Adjustment(ranges[i].from, ranges[i].to,\n+ ranges[i].adjustment + newAdjustment.adjustment)\n+ }\n+ }\n+ mergeRanges(ranges)\n+ }\n+\n+ private fun mergeRanges(ranges: MutableList<Adjustment>) {\n+ var i = 0;\n+ while (i < ranges.size - 1) {\n+ if (ranges[i].adjustment == ranges[i + 1].adjustment) {\n+ require(ranges[i].to + 1 == ranges[i + 1].from)\n+ ranges[i] = Adjustment(ranges[i].from, ranges[i + 1].to, ranges[i].adjustment)\n+ ranges.removeAt(i + 1)\n+ } else {\n+ i++\n+ }\n+ }\n+ }\n+}\n+\n+private class Adjustment(val from: Int, val to: Int, val adjustment: Int) {\n+ fun intersects(other: Adjustment) = contains(other.from) || contains(other.to) || other.contains(from) || other.contains(to)\n+ fun contains(index: Int) = index in from..to\n+ fun contains(other: Adjustment) = other.from in from..to && other.to in from..to\n+}\n+private data class Role(val nodeId: Long, val role: String?) {}\n+\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "package org.modelix.model.operations\n-import org.modelix.model.api.ITree\nimport org.modelix.model.api.IWriteTransaction\n-import org.modelix.model.persistent.SerializationUtil\n-class MoveNodeOp(val childId: Long, val sourceParentId: Long, val sourceRole: String?, val sourceIndex: Int, val targetParentId: Long, val targetRole: String?, val targetIndex: Int) : AbstractOperation(), IModifiesChildrenOp {\n+class MoveNodeOp(\n+ val childId: Long,\n+ val sourceParentId: Long,\n+ val sourceRole: String?,\n+ val sourceIndex: Int,\n+ val targetParentId: Long,\n+ val targetRole: String?,\n+ val targetIndex: Int\n+) : AbstractOperation() {\nfun withIndex(newSourceIndex: Int, newTargetIndex: Int): MoveNodeOp {\n- return if (newSourceIndex == sourceIndex && newTargetIndex == targetIndex) this else MoveNodeOp(childId, sourceParentId, sourceRole, newSourceIndex, targetParentId, targetRole, newTargetIndex)\n+ return if (newSourceIndex == sourceIndex && newTargetIndex == targetIndex) {\n+ this\n+ } else {\n+ MoveNodeOp(childId, sourceParentId, sourceRole, newSourceIndex,\n+ targetParentId, targetRole, newTargetIndex)\n+ }\n}\noverride fun apply(transaction: IWriteTransaction): IAppliedOperation {\n@@ -29,23 +40,21 @@ class MoveNodeOp(val childId: Long, val sourceParentId: Long, val sourceRole: St\nreturn Applied()\n}\n- override fun transform(previous: IOperation): IOperation {\n+ override fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nreturn when (previous) {\n- is AddNewChildOp -> {\n- val o = previous\n- withIndex(o.adjustIndex(sourceParentId, sourceRole, sourceIndex), o.adjustIndex(targetParentId, targetRole, targetIndex))\n- }\n+ is AddNewChildOp -> this\nis DeleteNodeOp -> {\nif (previous.parentId == sourceParentId && previous.role == sourceRole && previous.index == sourceIndex) {\nif (previous.childId != childId) {\n- throw RuntimeException(sourceParentId.toString() + \".\" + sourceRole + \"[\" + sourceIndex + \"] expected to be \" + childId + \", but was \" + previous.childId)\n+ throw RuntimeException(\"$sourceParentId.$sourceRole[$sourceIndex] expected to be ${childId.toString(16)}, but was ${previous.childId.toString(16)}\")\n}\n+ indexAdjustments.nodeRemoved(targetParentId, targetRole, targetIndex)\nNoOp()\n} else {\n- withIndex(previous.adjustIndex(sourceParentId, sourceRole, sourceIndex), previous.adjustIndex(targetParentId, targetRole, targetIndex))\n+ this\n}\n}\n- is MoveNodeOp -> withIndex(previous.adjustIndex(sourceParentId, sourceRole, sourceIndex), previous.adjustIndex(targetParentId, targetRole, targetIndex))\n+ is MoveNodeOp -> this\nis SetPropertyOp -> this\nis SetReferenceOp -> this\nis NoOp -> this\n@@ -55,19 +64,20 @@ class MoveNodeOp(val childId: Long, val sourceParentId: Long, val sourceRole: St\n}\n}\n- override fun adjustIndex(otherParentId: Long, otherRole: String?, otherIndex: Int): Int {\n- var adjustedIndex = otherIndex\n- if (otherParentId == sourceParentId && otherRole == sourceRole && sourceIndex < otherIndex) {\n- adjustedIndex--\n+ override fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n+ indexAdjustments.nodeRemoved(sourceParentId, sourceRole, sourceIndex)\n+ indexAdjustments.nodeAdded(targetParentId, targetRole, targetIndex)\n}\n- if (otherParentId == targetParentId && otherRole == targetRole && targetIndex <= otherIndex) {\n- adjustedIndex++\n- }\n- return adjustedIndex\n+\n+ override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n+ return withIndex(\n+ indexAdjustments.getAdjustedIndex(sourceParentId, sourceRole, sourceIndex),\n+ indexAdjustments.getAdjustedIndex(targetParentId, targetRole, targetIndex)\n+ )\n}\noverride fun toString(): String {\n- return \"MoveNodeOp ${SerializationUtil.longToHex(childId)}, ${SerializationUtil.longToHex(sourceParentId)}.$sourceRole[$sourceIndex]->${SerializationUtil.longToHex(targetParentId)}.$targetRole[$targetIndex]\"\n+ return \"MoveNodeOp ${childId.toString(16)}, ${sourceParentId.toString(16)}.$sourceRole[$sourceIndex]->${targetParentId.toString(16)}.$targetRole[$targetIndex]\"\n}\ninner class Applied : AbstractOperation.Applied(), IAppliedOperation {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/NoOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/NoOp.kt", "diff": "@@ -22,7 +22,7 @@ class NoOp : AbstractOperation(), IAppliedOperation {\nreturn this\n}\n- override fun transform(previous: IOperation): IOperation {\n+ override fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nreturn this\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/SetPropertyOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/SetPropertyOp.kt", "diff": "@@ -25,7 +25,7 @@ class SetPropertyOp(val nodeId: Long, val role: String, val value: String?) : Ab\nreturn Applied(oldValue)\n}\n- override fun transform(previous: IOperation): IOperation {\n+ override fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nreturn when (previous) {\nis SetPropertyOp -> this\nis SetReferenceOp -> this\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/SetReferenceOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/SetReferenceOp.kt", "diff": "@@ -26,7 +26,7 @@ class SetReferenceOp(val sourceId: Long, val role: String, val target: INodeRefe\nreturn Applied(oldValue)\n}\n- override fun transform(previous: IOperation): IOperation {\n+ override fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nreturn when (previous) {\nis SetPropertyOp -> this\nis SetReferenceOp -> this\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -8,6 +8,7 @@ import org.modelix.model.lazy.CLTree\nimport org.modelix.model.lazy.CLVersion\nimport org.modelix.model.operations.IAppliedOperation\nimport org.modelix.model.operations.OTBranch\n+import kotlin.math.max\nimport kotlin.test.Test\nimport kotlin.test.fail\n@@ -37,6 +38,7 @@ class ConflictResolutionTest : TreeTestBase() {\nval mergedVersions = ArrayList(versions)\nfor (i in 0..maxIndex) for (i2 in 0..maxIndex) {\n+ if (i == i2) continue\nlogDebug({ \"Merge branch $i2 into $i\" }, ConflictResolutionTest::class)\nmergedVersions[i] = merger.mergeChange(mergedVersions[i], mergedVersions[i2])\n}\n@@ -86,6 +88,59 @@ class ConflictResolutionTest : TreeTestBase() {\nval mergedVersions = ArrayList(versions)\nfor (i in 0..maxIndex) for (i2 in 0..maxIndex) {\n+ if (i == i2) continue\n+ logDebug({ \"Merge branch $i2 into $i\" }, ConflictResolutionTest::class)\n+ mergedVersions[i] = merger.mergeChange(mergedVersions[i], mergedVersions[i2])\n+ }\n+\n+ for (i in 1..maxIndex) {\n+ assertSameTree(mergedVersions[0].tree, mergedVersions[i].tree)\n+ }\n+ }\n+\n+ @Test\n+ fun knownIssue02() {\n+ val merger = VersionMerger(storeCache, idGenerator)\n+ val baseBranch = OTBranch(PBranch(initialTree, idGenerator), idGenerator)\n+\n+ baseBranch.runWrite {\n+ val t = baseBranch.writeTransaction\n+ t.addNewChild(ITree.ROOT_ID, \"role2\", 0, 0x3, null)\n+ }\n+\n+ val baseVersion = createVersion(baseBranch.operationsAndTree, null)\n+\n+ val maxIndex = 1\n+ val branches = (0..maxIndex).map { OTBranch(PBranch(baseVersion.tree, idGenerator), idGenerator) }.toList()\n+ branches[0].runWrite {\n+ val t = branches[0].writeTransaction\n+ t.deleteNode(0x3)\n+ //t.addNewChild(ITree.ROOT_ID, \"role2\", 0, 0xe, null)\n+ //t.moveChild(ITree.ROOT_ID, \"role2\", 1, 0xe)\n+ //t.deleteNode(0xe)\n+ }\n+ branches[1].runWrite {\n+ val t = branches[1].writeTransaction\n+ t.deleteNode(0x3)\n+\n+ //t.addNewChild(ITree.ROOT_ID, \"role3\", 1, 0x13, null)\n+ //t.moveChild(ITree.ROOT_ID, \"role2\", 0, 0x13)\n+ t.addNewChild(ITree.ROOT_ID, \"role2\", 0, 0x13, null)\n+\n+ //t.addNewChild(ITree.ROOT_ID, \"role5\", 0, 0x17, null)\n+ //t.moveChild(ITree.ROOT_ID, \"role2\", 1, 0x17)\n+ //t.moveChild(ITree.ROOT_ID, \"role1\", 0, 0x17)\n+ //t.moveChild(ITree.ROOT_ID, \"role6\", 0, 0x17)\n+ t.deleteNode(0x13) // transforming this fails: Both operations delete 1.role2[0] but with different expected IDs ff00000013 and ff00000003\n+ }\n+ val versions = branches.map { branch ->\n+ createVersion(branch.operationsAndTree, baseVersion)\n+ }.toList()\n+\n+ val mergedVersions = ArrayList(versions)\n+\n+ for (i in 0..maxIndex) for (i2 in 0..maxIndex) {\n+ if (i == i2) continue\nlogDebug({ \"Merge branch $i2 into $i\" }, ConflictResolutionTest::class)\nmergedVersions[i] = merger.mergeChange(mergedVersions[i], mergedVersions[i2])\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (2)
426,496
10.08.2020 17:19:16
-7,200
db7bad0254722267861f74a7e97066d35ddf7b37
Conflict resolution tests (3)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -124,12 +124,11 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n}\nprotected fun transformOperation(opToTransform: IOperation, previousOp: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n- var result = opToTransform.withAdjustedIndex(indexAdjustments)\n- result = result.transform(previousOp, indexAdjustments)\n- if (opToTransform.toString() != result.toString()) {\n- logDebug({ \"transformed: $opToTransform --> $result ## $previousOp\" }, VersionMerger::class)\n+ val transformed = opToTransform.transform(previousOp, indexAdjustments)\n+ if (opToTransform.toString() != transformed.toString()) {\n+ logDebug({ \"transformed: $opToTransform --> $transformed ## $previousOp\" }, VersionMerger::class)\n}\n- return result\n+ return transformed\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "@@ -31,8 +31,9 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\n}\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n+ val adjusted = withAdjustedIndex(indexAdjustments)\nreturn when (previous) {\n- is AddNewChildOp -> this\n+ is AddNewChildOp -> adjusted\nis DeleteNodeOp -> {\nif (previous.childId == this.parentId) {\nAddNewChildOp(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0, this.childId, this.concept)\n@@ -40,10 +41,10 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\nthis\n}\n}\n- is MoveNodeOp -> this\n- is SetPropertyOp -> this\n- is SetReferenceOp -> this\n- is NoOp -> this\n+ is MoveNodeOp -> adjusted\n+ is SetPropertyOp -> adjusted\n+ is SetReferenceOp -> adjusted\n+ is NoOp -> adjusted\nelse -> throw RuntimeException(\"Unknown type: \" + previous::class.simpleName)\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "@@ -39,6 +39,7 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\n}\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n+ val adjusted = withAdjustedIndex(indexAdjustments)\nreturn when (previous) {\nis DeleteNodeOp -> {\nif (parentId == previous.parentId && role == previous.role && previous.index == index) {\n@@ -46,23 +47,21 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\n// revert the adjustment of the other DeleteOp\nindexAdjustments.nodeAdded(parentId, role, index+1)\nNoOp()\n- } else this\n- } else this\n+ } else adjusted\n+ } else adjusted\n}\n- is AddNewChildOp -> this\n+ is AddNewChildOp -> adjusted\nis MoveNodeOp -> {\nif (previous.childId == childId) {\nif (previous.sourceParentId != parentId || previous.sourceRole != role || previous.sourceIndex != index) {\nthrow RuntimeException(\"node \" + childId + \" expected to be at \" + parentId + \".\" + role + \"[\" + index + \"]\" + \" but was \" + previous.sourceParentId + \".\" + previous.sourceRole + \"[\" + previous.sourceIndex + \"]\")\n}\nDeleteNodeOp(previous.targetParentId, previous.targetRole, previous.targetIndex, childId)\n- } else {\n- this\n+ } else adjusted\n}\n- }\n- is SetPropertyOp -> this\n- is SetReferenceOp -> this\n- is NoOp -> this\n+ is SetPropertyOp -> adjusted\n+ is SetReferenceOp -> adjusted\n+ is NoOp -> adjusted\nelse -> throw RuntimeException(\"Unknown type: \" + previous::class.simpleName)\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -41,8 +41,9 @@ class MoveNodeOp(\n}\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n+ val adjusted = withAdjustedIndex(indexAdjustments)\nreturn when (previous) {\n- is AddNewChildOp -> this\n+ is AddNewChildOp -> adjusted\nis DeleteNodeOp -> {\nif (previous.parentId == sourceParentId && previous.role == sourceRole && previous.index == sourceIndex) {\nif (previous.childId != childId) {\n@@ -50,17 +51,13 @@ class MoveNodeOp(\n}\nindexAdjustments.nodeRemoved(targetParentId, targetRole, targetIndex)\nNoOp()\n- } else {\n- this\n- }\n- }\n- is MoveNodeOp -> this\n- is SetPropertyOp -> this\n- is SetReferenceOp -> this\n- is NoOp -> this\n- else -> {\n- throw RuntimeException(\"Unknown type: \" + previous::class.simpleName)\n+ } else adjusted\n}\n+ is MoveNodeOp -> adjusted\n+ is SetPropertyOp -> adjusted\n+ is SetReferenceOp -> adjusted\n+ is NoOp -> adjusted\n+ else -> throw RuntimeException(\"Unknown type: \" + previous::class.simpleName)\n}\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (3)
426,496
10.08.2020 23:35:00
-7,200
048005c93ac2fcb3ec935c6bbffbbe12cf2ac6c7
Conflict resolution tests (4)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "@@ -31,9 +31,9 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\n}\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n- val adjusted = withAdjustedIndex(indexAdjustments)\n+ val adjusted = { withAdjustedIndex(indexAdjustments) }\nreturn when (previous) {\n- is AddNewChildOp -> adjusted\n+ is AddNewChildOp -> adjusted()\nis DeleteNodeOp -> {\nif (previous.childId == this.parentId) {\nAddNewChildOp(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0, this.childId, this.concept)\n@@ -41,10 +41,10 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\nthis\n}\n}\n- is MoveNodeOp -> adjusted\n- is SetPropertyOp -> adjusted\n- is SetReferenceOp -> adjusted\n- is NoOp -> adjusted\n+ is MoveNodeOp -> adjusted()\n+ is SetPropertyOp -> adjusted()\n+ is SetReferenceOp -> adjusted()\n+ is NoOp -> adjusted()\nelse -> throw RuntimeException(\"Unknown type: \" + previous::class.simpleName)\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "@@ -39,29 +39,30 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\n}\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n- val adjusted = withAdjustedIndex(indexAdjustments)\n+ val adjusted = { withAdjustedIndex(indexAdjustments) }\nreturn when (previous) {\nis DeleteNodeOp -> {\nif (parentId == previous.parentId && role == previous.role && previous.index == index) {\nif (previous.childId == childId) {\n- // revert the adjustment of the other DeleteOp\n- indexAdjustments.nodeAdded(parentId, role, index+1)\n+ indexAdjustments.undoNodeRemoved(previous.parentId, previous.role, previous.index)\nNoOp()\n- } else adjusted\n- } else adjusted\n+ } else adjusted()\n+ } else adjusted()\n}\n- is AddNewChildOp -> adjusted\n+ is AddNewChildOp -> adjusted()\nis MoveNodeOp -> {\nif (previous.childId == childId) {\nif (previous.sourceParentId != parentId || previous.sourceRole != role || previous.sourceIndex != index) {\nthrow RuntimeException(\"node \" + childId + \" expected to be at \" + parentId + \".\" + role + \"[\" + index + \"]\" + \" but was \" + previous.sourceParentId + \".\" + previous.sourceRole + \"[\" + previous.sourceIndex + \"]\")\n}\n+ indexAdjustments.undoNodeRemoved(previous.sourceParentId, previous.sourceRole, previous.sourceIndex)\n+ indexAdjustments.undoNodeAdded(previous.targetParentId, previous.targetRole, previous.targetIndex)\nDeleteNodeOp(previous.targetParentId, previous.targetRole, previous.targetIndex, childId)\n- } else adjusted\n+ } else adjusted()\n}\n- is SetPropertyOp -> adjusted\n- is SetReferenceOp -> adjusted\n- is NoOp -> adjusted\n+ is SetPropertyOp -> adjusted()\n+ is SetReferenceOp -> adjusted()\n+ is NoOp -> adjusted()\nelse -> throw RuntimeException(\"Unknown type: \" + previous::class.simpleName)\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "diff": "@@ -2,51 +2,66 @@ package org.modelix.model.operations\nclass IndexAdjustments {\n- private val adjustments: MutableMap<Role, MutableList<Adjustment>> = HashMap()\n+ private val adjustments: MutableMap<Role, MutableList<Range>> = HashMap()\nfun nodeRemoved(parent: Long, role: String?, index: Int) {\n- val ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Adjustment(0, Int.MAX_VALUE, 0)) })\n- apply(ranges, Adjustment(index + 1, Int.MAX_VALUE, -1))\n+ val ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n+ apply(ranges, Range(index, index, Adjustment(0, true, false)))\n+ apply(ranges, Range(index + 1, Int.MAX_VALUE, Adjustment(-1)))\n+ }\n+\n+ fun undoNodeRemoved(parent: Long, role: String?, index: Int) {\n+ val ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n+ apply(ranges, Range(index, index, Adjustment(0, false, true)))\n+ apply(ranges, Range(index + 1, Int.MAX_VALUE, Adjustment(1)))\n}\nfun nodeAdded(parent: Long, role: String?, index: Int) {\n- val ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Adjustment(0, Int.MAX_VALUE, 0)) })\n- apply(ranges, Adjustment(index, Int.MAX_VALUE, 1))\n+ val ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n+ apply(ranges, Range(index, Int.MAX_VALUE, Adjustment(1)))\n+ }\n+\n+ fun undoNodeAdded(parent: Long, role: String?, index: Int) {\n+ val ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n+ apply(ranges, Range(index, Int.MAX_VALUE, Adjustment(-1)))\n}\nfun getAdjustedIndex(parentId: Long, role: String?, index: Int): Int {\n- return index + (adjustments[Role(parentId, role)]?.find { it.contains(index) }?.adjustment ?: 0)\n+ return adjustments[Role(parentId, role)]?.find { it.contains(index) }?.adjustment?.adjust(index) ?: 0\n}\n- private fun apply(ranges: MutableList<Adjustment>, newAdjustment: Adjustment) {\n+ private fun apply(ranges: MutableList<Range>, newAdjustment: Range) {\nvar i = 0;\nwhile (i < ranges.size) {\nif (ranges[i].contains(newAdjustment.from) && ranges[i].from != newAdjustment.from) {\n- ranges.add(i + 1, Adjustment(newAdjustment.from, ranges[i].to, ranges[i].adjustment))\n- ranges[i] = Adjustment(ranges[i].from, newAdjustment.from - 1, ranges[i].adjustment)\n+ ranges.add(i + 1, Range(newAdjustment.from, ranges[i].to, ranges[i].adjustment))\n+ ranges[i] = Range(ranges[i].from, newAdjustment.from - 1, ranges[i].adjustment)\n}\nif (ranges[i].contains(newAdjustment.to) && ranges[i].to != newAdjustment.to) {\n- ranges.add(i + 1, Adjustment(newAdjustment.to + 1, ranges[i].to, ranges[i].adjustment))\n- ranges[i] = Adjustment(ranges[i].from, newAdjustment.to, ranges[i].adjustment)\n+ ranges.add(i + 1, Range(newAdjustment.to + 1, ranges[i].to, ranges[i].adjustment))\n+ ranges[i] = Range(ranges[i].from, newAdjustment.to, ranges[i].adjustment)\n}\ni++\n}\nfor (i in ranges.indices) {\nif (ranges[i].intersects(newAdjustment)) {\nrequire(newAdjustment.contains(ranges[i]))\n- ranges[i] = Adjustment(ranges[i].from, ranges[i].to,\n- ranges[i].adjustment + newAdjustment.adjustment)\n+ ranges[i] = Range(\n+ ranges[i].from,\n+ ranges[i].to,\n+ ranges[i].adjustment.combine(newAdjustment.adjustment)\n+ )\n}\n}\nmergeRanges(ranges)\n}\n- private fun mergeRanges(ranges: MutableList<Adjustment>) {\n+ private fun mergeRanges(ranges: MutableList<Range>) {\nvar i = 0;\nwhile (i < ranges.size - 1) {\nif (ranges[i].adjustment == ranges[i + 1].adjustment) {\nrequire(ranges[i].to + 1 == ranges[i + 1].from)\n- ranges[i] = Adjustment(ranges[i].from, ranges[i + 1].to, ranges[i].adjustment)\n+ ranges[i] = Range(ranges[i].from, ranges[i + 1].to, ranges[i].adjustment)\nranges.removeAt(i + 1)\n} else {\ni++\n@@ -55,10 +70,23 @@ class IndexAdjustments {\n}\n}\n-private class Adjustment(val from: Int, val to: Int, val adjustment: Int) {\n- fun intersects(other: Adjustment) = contains(other.from) || contains(other.to) || other.contains(from) || other.contains(to)\n+private class Range(val from: Int, val to: Int, val adjustment: Adjustment) {\n+ fun intersects(other: Range) = contains(other.from) || contains(other.to) || other.contains(from) || other.contains(to)\nfun contains(index: Int) = index in from..to\n- fun contains(other: Adjustment) = other.from in from..to && other.to in from..to\n+ fun contains(other: Range) = other.from in from..to && other.to in from..to\n+}\n+private class Adjustment(val amount: Int, val deleted: Boolean = false, val undoDelete: Boolean = false) {\n+ fun combine(other: Adjustment): Adjustment {\n+ return Adjustment(\n+ amount + other.amount,\n+ (deleted || other.deleted) && !(undoDelete || other.undoDelete),\n+ false\n+ )\n+ }\n+ fun adjust(index: Int): Int {\n+ if (deleted) throw RuntimeException(\"Attempt to access a deleted location: $index\")\n+ return index + amount\n+ }\n}\nprivate data class Role(val nodeId: Long, val role: String?) {}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -41,9 +41,9 @@ class MoveNodeOp(\n}\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n- val adjusted = withAdjustedIndex(indexAdjustments)\n+ val adjusted = { withAdjustedIndex(indexAdjustments) }\nreturn when (previous) {\n- is AddNewChildOp -> adjusted\n+ is AddNewChildOp -> adjusted()\nis DeleteNodeOp -> {\nif (previous.parentId == sourceParentId && previous.role == sourceRole && previous.index == sourceIndex) {\nif (previous.childId != childId) {\n@@ -51,12 +51,12 @@ class MoveNodeOp(\n}\nindexAdjustments.nodeRemoved(targetParentId, targetRole, targetIndex)\nNoOp()\n- } else adjusted\n+ } else adjusted()\n}\n- is MoveNodeOp -> adjusted\n- is SetPropertyOp -> adjusted\n- is SetReferenceOp -> adjusted\n- is NoOp -> adjusted\n+ is MoveNodeOp -> adjusted()\n+ is SetPropertyOp -> adjusted()\n+ is SetReferenceOp -> adjusted()\n+ is NoOp -> adjusted()\nelse -> throw RuntimeException(\"Unknown type: \" + previous::class.simpleName)\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "package org.modelix.model\n-import org.modelix.model.api.INode\nimport org.modelix.model.api.ITree\nimport org.modelix.model.api.ITreeChangeVisitor\nimport org.modelix.model.api.PBranch\n@@ -8,7 +7,6 @@ import org.modelix.model.lazy.CLTree\nimport org.modelix.model.lazy.CLVersion\nimport org.modelix.model.operations.IAppliedOperation\nimport org.modelix.model.operations.OTBranch\n-import kotlin.math.max\nimport kotlin.test.Test\nimport kotlin.test.fail\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/IndexAdjustmentsTest.kt", "diff": "+package org.modelix.model\n+\n+import org.modelix.model.operations.IndexAdjustments\n+import kotlin.test.Test\n+import kotlin.test.assertEquals\n+import kotlin.test.assertFails\n+\n+class IndexAdjustmentsTest {\n+\n+ @Test\n+ fun test() {\n+ val p = 1L\n+ val r = \"role\"\n+ val ia = IndexAdjustments()\n+\n+ assertEquals(0, ia.getAdjustedIndex(p, r, 0))\n+ assertEquals(1, ia.getAdjustedIndex(p, r, 1))\n+ assertEquals(2, ia.getAdjustedIndex(p, r, 2))\n+ assertEquals(3, ia.getAdjustedIndex(p, r, 3))\n+ assertEquals(4, ia.getAdjustedIndex(p, r, 4))\n+ assertEquals(5, ia.getAdjustedIndex(p, r, 5))\n+\n+ ia.nodeAdded(p, r, 1)\n+ assertEquals(0, ia.getAdjustedIndex(p, r, 0))\n+ assertEquals(2, ia.getAdjustedIndex(p, r, 1))\n+ assertEquals(3, ia.getAdjustedIndex(p, r, 2))\n+ assertEquals(4, ia.getAdjustedIndex(p, r, 3))\n+ assertEquals(5, ia.getAdjustedIndex(p, r, 4))\n+ assertEquals(6, ia.getAdjustedIndex(p, r, 5))\n+\n+ ia.nodeAdded(p, r, 3)\n+ assertEquals(0, ia.getAdjustedIndex(p, r, 0))\n+ assertEquals(2, ia.getAdjustedIndex(p, r, 1))\n+ assertEquals(3, ia.getAdjustedIndex(p, r, 2))\n+ assertEquals(5, ia.getAdjustedIndex(p, r, 3))\n+ assertEquals(6, ia.getAdjustedIndex(p, r, 4))\n+ assertEquals(7, ia.getAdjustedIndex(p, r, 5))\n+\n+ ia.nodeRemoved(p, r, 2)\n+ assertEquals(0, ia.getAdjustedIndex(p, r, 0))\n+ assertEquals(2, ia.getAdjustedIndex(p, r, 1))\n+ assertFails { ia.getAdjustedIndex(p, r, 2) }\n+ assertEquals(4, ia.getAdjustedIndex(p, r, 3))\n+ assertEquals(5, ia.getAdjustedIndex(p, r, 4))\n+ assertEquals(6, ia.getAdjustedIndex(p, r, 5))\n+\n+ ia.nodeRemoved(p, r, 4)\n+ assertEquals(0, ia.getAdjustedIndex(p, r, 0))\n+ assertEquals(2, ia.getAdjustedIndex(p, r, 1))\n+ assertFails { ia.getAdjustedIndex(p, r, 2) }\n+ assertEquals(4, ia.getAdjustedIndex(p, r, 3))\n+ assertFails { ia.getAdjustedIndex(p, r, 4) }\n+ assertEquals(5, ia.getAdjustedIndex(p, r, 5))\n+\n+ ia.nodeAdded(p, r, 0)\n+ assertEquals(1, ia.getAdjustedIndex(p, r, 0))\n+ assertEquals(3, ia.getAdjustedIndex(p, r, 1))\n+ assertFails { ia.getAdjustedIndex(p, r, 2) }\n+ assertEquals(5, ia.getAdjustedIndex(p, r, 3))\n+ assertFails { ia.getAdjustedIndex(p, r, 4) }\n+ assertEquals(6, ia.getAdjustedIndex(p, r, 5))\n+\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (4)
426,496
11.08.2020 09:35:31
-7,200
400ac4bebafc5774b5e36b5c31a380be5854efe9
Conflict resolution tests (5)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -78,7 +78,6 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\nval leftAppliedOps: MutableList<IAppliedOperation> = ArrayList()\nval rightAppliedOps: MutableList<IAppliedOperation> = ArrayList()\nval appliedVersionIds: MutableSet<Long> = HashSet()\n- val indexAdjustments = IndexAdjustments()\nwhile (leftHistory.isNotEmpty() || rightHistory.isNotEmpty()) {\nval useLeft = when {\nrightHistory.isEmpty() -> true\n@@ -95,6 +94,7 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n.toList()\nvar operationsToApply: List<IOperation> = versionToApply.operations.toList()\nfor (oppositeAppliedOp in oppositeAppliedOps) {\n+ val indexAdjustments = IndexAdjustments()\noppositeAppliedOp.loadAdjustment(indexAdjustments)\noperationsToApply = operationsToApply.map { transformOperation(it, oppositeAppliedOp, indexAdjustments) }.toList()\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AbstractOperation.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AbstractOperation.kt", "diff": "@@ -23,7 +23,8 @@ abstract class AbstractOperation : IOperation {\n}\noverride fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n-\n+ }\n+ override fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n}\noverride fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "@@ -53,6 +53,10 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\nindexAdjustments.nodeAdded(parentId, role, index)\n}\n+ override fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n+ indexAdjustments.undoNodeAdded(parentId, role, index)\n+ }\n+\noverride fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\nreturn withIndex(indexAdjustments.getAdjustedIndex(parentId, role, index))\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "@@ -44,7 +44,7 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\nis DeleteNodeOp -> {\nif (parentId == previous.parentId && role == previous.role && previous.index == index) {\nif (previous.childId == childId) {\n- indexAdjustments.undoNodeRemoved(previous.parentId, previous.role, previous.index)\n+ previous.undoAdjustment(indexAdjustments)\nNoOp()\n} else adjusted()\n} else adjusted()\n@@ -55,8 +55,7 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\nif (previous.sourceParentId != parentId || previous.sourceRole != role || previous.sourceIndex != index) {\nthrow RuntimeException(\"node \" + childId + \" expected to be at \" + parentId + \".\" + role + \"[\" + index + \"]\" + \" but was \" + previous.sourceParentId + \".\" + previous.sourceRole + \"[\" + previous.sourceIndex + \"]\")\n}\n- indexAdjustments.undoNodeRemoved(previous.sourceParentId, previous.sourceRole, previous.sourceIndex)\n- indexAdjustments.undoNodeAdded(previous.targetParentId, previous.targetRole, previous.targetIndex)\n+ previous.undoAdjustment(indexAdjustments)\nDeleteNodeOp(previous.targetParentId, previous.targetRole, previous.targetIndex, childId)\n} else adjusted()\n}\n@@ -71,6 +70,10 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\nindexAdjustments.nodeRemoved(parentId, role, index)\n}\n+ override fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n+ indexAdjustments.undoNodeRemoved(parentId, role, index)\n+ }\n+\noverride fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\nreturn withIndex(indexAdjustments.getAdjustedIndex(parentId, role, index))\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IOperation.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IOperation.kt", "diff": "@@ -30,6 +30,7 @@ interface IOperation {\nfun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation\nfun loadAdjustment(indexAdjustments: IndexAdjustments)\n+ fun undoAdjustment(indexAdjustments: IndexAdjustments)\nfun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -53,7 +53,19 @@ class MoveNodeOp(\nNoOp()\n} else adjusted()\n}\n- is MoveNodeOp -> adjusted()\n+ is MoveNodeOp -> {\n+ if (previous.childId == childId) {\n+ if (previous.sourceParentId != sourceParentId || previous.sourceRole != sourceRole || previous.sourceIndex != sourceIndex) {\n+ throw RuntimeException(\"Both operations move node ${childId.toString(16)} but from ${sourceParentId.toString(16)}.$sourceRole[$sourceIndex] and ${previous.sourceParentId.toString(16)}.${previous.sourceRole}[${previous.sourceIndex}]\")\n+ }\n+ previous.undoAdjustment(indexAdjustments)\n+ MoveNodeOp(\n+ childId,\n+ previous.targetParentId, previous.targetRole, previous.targetIndex,\n+ targetParentId, targetRole, targetIndex\n+ )\n+ } else adjusted()\n+ }\nis SetPropertyOp -> adjusted()\nis SetReferenceOp -> adjusted()\nis NoOp -> adjusted()\n@@ -66,6 +78,11 @@ class MoveNodeOp(\nindexAdjustments.nodeAdded(targetParentId, targetRole, targetIndex)\n}\n+ override fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n+ indexAdjustments.undoNodeAdded(targetParentId, targetRole, targetIndex)\n+ indexAdjustments.undoNodeRemoved(sourceParentId, sourceRole, sourceIndex)\n+ }\n+\noverride fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\nreturn withIndex(\nindexAdjustments.getAdjustedIndex(sourceParentId, sourceRole, sourceIndex),\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -13,22 +13,41 @@ import kotlin.test.fail\nclass ConflictResolutionTest : TreeTestBase() {\n@Test\n- fun random() {\n+ fun randomTest01() {\n+ randomTest(30, 3, 50)\n+ }\n+\n+ @Test\n+ fun randomTest02() {\n+ randomTest(10, 5, 10)\n+ }\n+\n+ @Test\n+ fun randomTest03() {\n+ randomTest(10, 5, 20)\n+ }\n+\n+ @Test\n+ fun randomTest04() {\n+ randomTest(0, 50, 3)\n+ }\n+\n+ fun randomTest(baseChanges: Int, numBranches: Int, branchChanges: Int) {\nval merger = VersionMerger(storeCache, idGenerator)\nval baseExpectedTreeData = ExpectedTreeData()\nval baseBranch = OTBranch(PBranch(initialTree, idGenerator), idGenerator)\nlogDebug({ \"Random changes to base\" }, ConflictResolutionTest::class)\n- for (i in 0..30) {\n+ for (i in 0 until baseChanges) {\napplyRandomChange(baseBranch, baseExpectedTreeData)\n}\nval baseVersion = createVersion(baseBranch.operationsAndTree, null)\n- val maxIndex = 2\n+ val maxIndex = numBranches - 1\nval branches = (0..maxIndex).map { OTBranch(PBranch(baseVersion.tree, idGenerator), idGenerator) }.toList()\nval versions = branches.map { branch ->\nval expectedTreeData = baseExpectedTreeData.clone()\nlogDebug({ \"Random changes to branch\" }, ConflictResolutionTest::class)\n- for (i in 0..50) {\n+ for (i in 0 until branchChanges) {\napplyRandomChange(branch, expectedTreeData)\n}\ncreateVersion(branch.operationsAndTree, baseVersion)\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (5)
426,496
11.08.2020 11:37:14
-7,200
53d1b3073c57275092da5f193fbc47a374ce76ef
Conflict resolution tests (6)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AbstractOperation.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AbstractOperation.kt", "diff": "@@ -30,4 +30,8 @@ abstract class AbstractOperation : IOperation {\noverride fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\nreturn this\n}\n+\n+ override fun toCode(): String {\n+ return \"\"\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "@@ -38,7 +38,7 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\nif (previous.childId == this.parentId) {\nAddNewChildOp(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0, this.childId, this.concept)\n} else {\n- this\n+ adjusted()\n}\n}\nis MoveNodeOp -> adjusted()\n@@ -65,6 +65,10 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\nreturn \"AddNewChildOp ${SerializationUtil.longToHex(childId)}, ${SerializationUtil.longToHex(parentId)}.$role[$index], $concept\"\n}\n+ override fun toCode(): String {\n+ return \"\"\"t.addNewChild(0x${parentId.toString(16)}, \"$role\", $index, 0x${childId.toString(16)}, null)\"\"\"\n+ }\n+\ninner class Applied : AbstractOperation.Applied(), IAppliedOperation {\noverride val originalOp: IOperation\nget() = this@AddNewChildOp\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "@@ -82,6 +82,10 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\nreturn \"DeleteNodeOp ${SerializationUtil.longToHex(childId)}, ${SerializationUtil.longToHex(parentId)}.$role[$index]\"\n}\n+ override fun toCode(): String {\n+ return \"\"\"t.deleteNode(0x${childId.toString(16)})\"\"\"\n+ }\n+\ninner class Applied(private val concept: IConcept?) : AbstractOperation.Applied(), IAppliedOperation {\noverride val originalOp: IOperation\nget() = this@DeleteNodeOp\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IOperation.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IOperation.kt", "diff": "@@ -33,4 +33,5 @@ interface IOperation {\nfun undoAdjustment(indexAdjustments: IndexAdjustments)\nfun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation\n+ fun toCode(): String\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "diff": "@@ -27,7 +27,7 @@ class IndexAdjustments {\n}\nfun getAdjustedIndex(parentId: Long, role: String?, index: Int): Int {\n- return adjustments[Role(parentId, role)]?.find { it.contains(index) }?.adjustment?.adjust(index) ?: 0\n+ return adjustments[Role(parentId, role)]?.find { it.contains(index) }?.adjustment?.adjust(index) ?: index\n}\nprivate fun apply(ranges: MutableList<Range>, newAdjustment: Range) {\n@@ -74,6 +74,9 @@ private class Range(val from: Int, val to: Int, val adjustment: Adjustment) {\nfun intersects(other: Range) = contains(other.from) || contains(other.to) || other.contains(from) || other.contains(to)\nfun contains(index: Int) = index in from..to\nfun contains(other: Range) = other.from in from..to && other.to in from..to\n+ override fun toString(): String {\n+ return \"$from..${if (to == Int.MAX_VALUE) \"\" else to}/$adjustment\"\n+ }\n}\nprivate class Adjustment(val amount: Int, val deleted: Boolean = false, val undoDelete: Boolean = false) {\nfun combine(other: Adjustment): Adjustment {\n@@ -84,9 +87,23 @@ private class Adjustment(val amount: Int, val deleted: Boolean = false, val undo\n)\n}\nfun adjust(index: Int): Int {\n- if (deleted) throw RuntimeException(\"Attempt to access a deleted location: $index\")\n+ if (deleted) {\n+ throw RuntimeException(\"Attempt to access a deleted location: $index\")\n+ }\nreturn index + amount\n}\n+\n+ override fun toString(): String {\n+ return when {\n+ undoDelete -> \"UNDO_DELETE\"\n+ deleted -> \"DELETED\"\n+ else -> amount.toString()\n+ }\n+ }\n+}\n+private data class Role(val nodeId: Long, val role: String?) {\n+ override fun toString(): String {\n+ return \"${nodeId.toString(16)}.$role\"\n+ }\n}\n-private data class Role(val nodeId: Long, val role: String?) {}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -94,6 +94,10 @@ class MoveNodeOp(\nreturn \"MoveNodeOp ${childId.toString(16)}, ${sourceParentId.toString(16)}.$sourceRole[$sourceIndex]->${targetParentId.toString(16)}.$targetRole[$targetIndex]\"\n}\n+ override fun toCode(): String {\n+ return \"\"\"t.moveChild(0x${targetParentId.toString(16)}, \"$targetRole\", $targetIndex, 0x${childId.toString(16)})\"\"\"\n+ }\n+\ninner class Applied : AbstractOperation.Applied(), IAppliedOperation {\noverride val originalOp: IOperation\nget() = this@MoveNodeOp\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "diff": "@@ -27,7 +27,8 @@ import org.modelix.model.logDebug\nclass OTWriteTransaction(private val transaction: IWriteTransaction, private val otBranch: OTBranch, protected var idGenerator: IIdGenerator) : IWriteTransaction {\nprotected fun apply(op: IOperation) {\n- logDebug({ \"apply: $op\" }, OTWriteTransaction::class)\n+ val opCode = op.toCode()\n+ if (opCode.isNotEmpty()) logDebug({ opCode }, OTWriteTransaction::class)\nval appliedOp = op.apply(transaction)\notBranch.operationApplied(appliedOp)\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -2,6 +2,7 @@ package org.modelix.model\nimport org.modelix.model.api.ITree\nimport org.modelix.model.api.ITreeChangeVisitor\n+import org.modelix.model.api.IWriteTransaction\nimport org.modelix.model.api.PBranch\nimport org.modelix.model.lazy.CLTree\nimport org.modelix.model.lazy.CLVersion\n@@ -44,9 +45,9 @@ class ConflictResolutionTest : TreeTestBase() {\nval maxIndex = numBranches - 1\nval branches = (0..maxIndex).map { OTBranch(PBranch(baseVersion.tree, idGenerator), idGenerator) }.toList()\n- val versions = branches.map { branch ->\n+ val versions = branches.mapIndexed { index, branch ->\nval expectedTreeData = baseExpectedTreeData.clone()\n- logDebug({ \"Random changes to branch\" }, ConflictResolutionTest::class)\n+ logDebug({ \"Random changes to branch $index\" }, ConflictResolutionTest::class)\nfor (i in 0 until branchChanges) {\napplyRandomChange(branch, expectedTreeData)\n}\n@@ -65,38 +66,24 @@ class ConflictResolutionTest : TreeTestBase() {\n}\n}\n- @Test\n- fun knownIssue01() {\n+ fun knownIssueTest(baseChanges: (IWriteTransaction) -> Unit, vararg branchChanges: (IWriteTransaction) -> Unit) {\nval merger = VersionMerger(storeCache, idGenerator)\nval baseBranch = OTBranch(PBranch(initialTree, idGenerator), idGenerator)\nbaseBranch.runWrite {\n- val t = baseBranch.writeTransaction\n- t.addNewChild(ITree.ROOT_ID, \"role1\", 0, 0xe, null)\n- t.addNewChild(ITree.ROOT_ID, \"role2\", 0, 0x12, null)\n+ logDebug({ \"Changes to base branch\" }, ConflictResolutionTest::class)\n+ baseChanges(baseBranch.writeTransaction)\n}\nval baseVersion = createVersion(baseBranch.operationsAndTree, null)\n- val maxIndex = 1\n+ val maxIndex = branchChanges.size - 1\nval branches = (0..maxIndex).map { OTBranch(PBranch(baseVersion.tree, idGenerator), idGenerator) }.toList()\n- branches[0].runWrite {\n- val t = branches[0].writeTransaction\n- // role1: [e] role2: [12] role3: []\n- t.moveChild(ITree.ROOT_ID, \"role3\", 0, 0xe)\n- // role1: [] role2: [12] role3: [e]\n- t.deleteNode(0xe)\n- // role1: [] role2: [12] role3: []\n+ for (i in 0..maxIndex) {\n+ branches[i].runWrite {\n+ logDebug({ \"Changes to branch $i\" }, ConflictResolutionTest::class)\n+ branchChanges[i](branches[i].writeTransaction)\n}\n- branches[1].runWrite {\n- val t = branches[1].writeTransaction\n- // role1: [e] role2: [12]\n- t.moveChild(ITree.ROOT_ID, \"role1\", 1, 0x12)\n- // role1: [e, 12] role2: []\n- t.deleteNode(0xe)\n- // role1: [12] role2: []\n- t.deleteNode(0x12) // transforming this fails: Node at 1.role1[0] is expected to be 12, but was e\n- // role1: [] role2: []\n}\nval versions = branches.map { branch ->\ncreateVersion(branch.operationsAndTree, baseVersion)\n@@ -116,55 +103,58 @@ class ConflictResolutionTest : TreeTestBase() {\n}\n@Test\n- fun knownIssue02() {\n- val merger = VersionMerger(storeCache, idGenerator)\n- val baseBranch = OTBranch(PBranch(initialTree, idGenerator), idGenerator)\n-\n- baseBranch.runWrite {\n- val t = baseBranch.writeTransaction\n- t.addNewChild(ITree.ROOT_ID, \"role2\", 0, 0x3, null)\n+ fun knownIssue01() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(ITree.ROOT_ID, \"role1\", 0, 0xe, null)\n+ t.addNewChild(ITree.ROOT_ID, \"role2\", 0, 0x12, null)\n+ }, { t ->\n+ t.moveChild(ITree.ROOT_ID, \"role3\", 0, 0xe)\n+ t.deleteNode(0xe)\n+ }, { t ->\n+ t.moveChild(ITree.ROOT_ID, \"role1\", 1, 0x12)\n+ t.deleteNode(0xe)\n+ t.deleteNode(0x12)\n+ })\n}\n- val baseVersion = createVersion(baseBranch.operationsAndTree, null)\n-\n- val maxIndex = 1\n- val branches = (0..maxIndex).map { OTBranch(PBranch(baseVersion.tree, idGenerator), idGenerator) }.toList()\n- branches[0].runWrite {\n- val t = branches[0].writeTransaction\n+ @Test\n+ fun knownIssue02() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(ITree.ROOT_ID, \"role2\", 0, 0x3, null)\n+ }, { t ->\nt.deleteNode(0x3)\n- //t.addNewChild(ITree.ROOT_ID, \"role2\", 0, 0xe, null)\n- //t.moveChild(ITree.ROOT_ID, \"role2\", 1, 0xe)\n- //t.deleteNode(0xe)\n- }\n- branches[1].runWrite {\n- val t = branches[1].writeTransaction\n+ }, { t ->\nt.deleteNode(0x3)\n-\n- //t.addNewChild(ITree.ROOT_ID, \"role3\", 1, 0x13, null)\n- //t.moveChild(ITree.ROOT_ID, \"role2\", 0, 0x13)\nt.addNewChild(ITree.ROOT_ID, \"role2\", 0, 0x13, null)\n-\n- //t.addNewChild(ITree.ROOT_ID, \"role5\", 0, 0x17, null)\n- //t.moveChild(ITree.ROOT_ID, \"role2\", 1, 0x17)\n- //t.moveChild(ITree.ROOT_ID, \"role1\", 0, 0x17)\n- //t.moveChild(ITree.ROOT_ID, \"role6\", 0, 0x17)\n- t.deleteNode(0x13) // transforming this fails: Both operations delete 1.role2[0] but with different expected IDs ff00000013 and ff00000003\n+ t.deleteNode(0x13)\n+ })\n}\n- val versions = branches.map { branch ->\n- createVersion(branch.operationsAndTree, baseVersion)\n- }.toList()\n-\n- val mergedVersions = ArrayList(versions)\n- for (i in 0..maxIndex) for (i2 in 0..maxIndex) {\n- if (i == i2) continue\n- logDebug({ \"Merge branch $i2 into $i\" }, ConflictResolutionTest::class)\n- mergedVersions[i] = merger.mergeChange(mergedVersions[i], mergedVersions[i2])\n+ @Test\n+ fun knownIssue03() {\n+ knownIssueTest({ t ->\n+ }, { t ->\n+ t.addNewChild(1, \"role2\", 0, 0xff00000007, null)\n+ t.deleteNode(0xff00000007)\n+ }, { t ->\n+ t.addNewChild(1, \"role2\", 0, 0xff0000000a, null)\n+ t.deleteNode(0xff0000000a)\n+ }, { t ->\n+ t.addNewChild(1, \"role2\", 0, 0xff0000000e, null)\n+ t.deleteNode(0xff0000000e)\n+ })\n}\n- for (i in 1..maxIndex) {\n- assertSameTree(mergedVersions[0].tree, mergedVersions[i].tree)\n- }\n+ @Test\n+ fun knownIssue04() {\n+ knownIssueTest({ t ->\n+ }, { t ->\n+ t.addNewChild(1, \"role3\", 0, 0xff00000006, null)\n+ t.addNewChild(0xff00000006, \"role3\", 0, 0xff00000008, null)\n+ t.moveChild(1, \"role1\", 0, 0xff00000006)\n+ }, { t ->\n+ t.addNewChild(1, \"role3\", 0, 0xff0000000e, null)\n+ })\n}\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (6)
426,496
11.08.2020 12:44:25
-7,200
05bf2c11799fa346e0abdedb29a9424550995d51
Conflict resolution tests (7)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -75,9 +75,10 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n}\nbranch.runWrite {\nval t = branch.writeTransaction\n- val leftAppliedOps: MutableList<IAppliedOperation> = ArrayList()\n- val rightAppliedOps: MutableList<IAppliedOperation> = ArrayList()\n- val appliedVersionIds: MutableSet<Long> = HashSet()\n+ val appliedOpsForVersion: MutableMap<Long, List<IAppliedOperation>> = LinkedHashMap()\n+ val appliedVersionIds: MutableSet<Long> = LinkedHashSet()\n+ val leftKnownVersions = leftHistory.map { it.id }.toSet()\n+ val rightKnownVersions = rightHistory.map { it.id }.toSet()\nwhile (leftHistory.isNotEmpty() || rightHistory.isNotEmpty()) {\nval useLeft = when {\nrightHistory.isEmpty() -> true\n@@ -89,21 +90,22 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\ncontinue\n}\nappliedVersionIds.add(versionToApply.id)\n- val oppositeAppliedOps = (if (useLeft) rightAppliedOps else leftAppliedOps)\n- .map { obj: IAppliedOperation -> obj.originalOp }\n- .toList()\n+ val knownVersions = if (useLeft) leftKnownVersions else rightKnownVersions\n+ val concurrentAppliedOps = appliedOpsForVersion\n+ .filterKeys { !knownVersions.contains(it) }\n+ .flatMap { it.value }\n+ .map { it.originalOp }\nvar operationsToApply: List<IOperation> = versionToApply.operations.toList()\n- for (oppositeAppliedOp in oppositeAppliedOps) {\n+ for (oppositeAppliedOp in concurrentAppliedOps) {\nval indexAdjustments = IndexAdjustments()\noppositeAppliedOp.loadAdjustment(indexAdjustments)\noperationsToApply = operationsToApply.map { transformOperation(it, oppositeAppliedOp, indexAdjustments) }.toList()\n}\n- for (op in operationsToApply) {\n- val appliedOp = op.apply(t)\n- if (useLeft) {\n- leftAppliedOps.add(appliedOp)\n- } else {\n- rightAppliedOps.add(appliedOp)\n+ appliedOpsForVersion[versionToApply.id] = operationsToApply.map {\n+ try {\n+ it.apply(t)\n+ } catch (ex: Exception) {\n+ throw RuntimeException(\"Operation failed: $it\", ex)\n}\n}\nmergedVersion = CLVersion(\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -157,6 +157,19 @@ class ConflictResolutionTest : TreeTestBase() {\n})\n}\n+ @Test\n+ fun knownIssue05() {\n+ knownIssueTest({ t ->\n+ }, { t -> // 0\n+ }, { t -> // 1\n+ }, { t -> // 2\n+ t.addNewChild(0x1, \"role3\", 0, 0xff0000000f, null)\n+ }, { t -> // 3\n+ t.addNewChild(0x1, \"role3\", 0, 0xff00000011, null)\n+ t.deleteNode(0xff00000011)\n+ })\n+ }\n+\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\nreturn CLVersion(\nidGenerator.generate(),\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (7)
426,496
11.08.2020 16:07:55
-7,200
2983311473aec1991ced3352ede970d3fc2324b8
Conflict resolution tests (8)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt", "diff": "@@ -295,6 +295,15 @@ class CLTree : ITree {\n}\noverride fun moveChild(targetParentId: Long, targetRole: String?, targetIndex: Int, childId: Long): ITree {\n+ if (childId == ITree.ROOT_ID) throw RuntimeException(\"Moving the root node is not allowed\")\n+ var ancestor = targetParentId\n+ while (ancestor != ITree.ROOT_ID) {\n+ if (ancestor == childId) {\n+ throw RuntimeException(\"${targetParentId.toString(16)} is a descendant of ${childId.toString(16)}\")\n+ }\n+ ancestor = getParent(ancestor)\n+ }\n+\nvar targetIndex = targetIndex\nif (targetIndex != -1) {\nval oldParent = getParent(childId)\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "@@ -42,19 +42,14 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\nval adjusted = { withAdjustedIndex(indexAdjustments) }\nreturn when (previous) {\nis DeleteNodeOp -> {\n- if (parentId == previous.parentId && role == previous.role && previous.index == index) {\nif (previous.childId == childId) {\nprevious.undoAdjustment(indexAdjustments)\nNoOp()\n} else adjusted()\n- } else adjusted()\n}\nis AddNewChildOp -> adjusted()\nis MoveNodeOp -> {\nif (previous.childId == childId) {\n- if (previous.sourceParentId != parentId || previous.sourceRole != role || previous.sourceIndex != index) {\n- throw RuntimeException(\"node \" + childId + \" expected to be at \" + parentId + \".\" + role + \"[\" + index + \"]\" + \" but was \" + previous.sourceParentId + \".\" + previous.sourceRole + \"[\" + previous.sourceIndex + \"]\")\n- }\nprevious.undoAdjustment(indexAdjustments)\nDeleteNodeOp(previous.targetParentId, previous.targetRole, previous.targetIndex, childId)\n} else adjusted()\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -45,19 +45,13 @@ class MoveNodeOp(\nreturn when (previous) {\nis AddNewChildOp -> adjusted()\nis DeleteNodeOp -> {\n- if (previous.parentId == sourceParentId && previous.role == sourceRole && previous.index == sourceIndex) {\n- if (previous.childId != childId) {\n- throw RuntimeException(\"$sourceParentId.$sourceRole[$sourceIndex] expected to be ${childId.toString(16)}, but was ${previous.childId.toString(16)}\")\n- }\n+ if (previous.childId == childId) {\nindexAdjustments.nodeRemoved(targetParentId, targetRole, targetIndex)\nNoOp()\n} else adjusted()\n}\nis MoveNodeOp -> {\nif (previous.childId == childId) {\n- if (previous.sourceParentId != sourceParentId || previous.sourceRole != sourceRole || previous.sourceIndex != sourceIndex) {\n- throw RuntimeException(\"Both operations move node ${childId.toString(16)} but from ${sourceParentId.toString(16)}.$sourceRole[$sourceIndex] and ${previous.sourceParentId.toString(16)}.${previous.sourceRole}[${previous.sourceIndex}]\")\n- }\nprevious.undoAdjustment(indexAdjustments)\nMoveNodeOp(\nchildId,\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -30,7 +30,7 @@ class ConflictResolutionTest : TreeTestBase() {\n@Test\nfun randomTest04() {\n- randomTest(0, 50, 3)\n+ randomTest(100, 5, 100)\n}\nfun randomTest(baseChanges: Int, numBranches: Int, branchChanges: Int) {\n@@ -170,6 +170,24 @@ class ConflictResolutionTest : TreeTestBase() {\n})\n}\n+ @Test\n+ fun knownIssue06() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role1\", 0, 0xff0000000e, null)\n+ t.addNewChild(0x1, \"role2\", 0, 0xff00000011, null)\n+ t.addNewChild(0xff00000011, \"role1\", 0, 0xff00000010, null)\n+ }, { t -> // 0\n+ t.moveChild(0x1, \"role1\", 0, 0xff00000010)\n+ t.deleteNode(0xff00000010)\n+ }, { t -> // 1\n+ t.deleteNode(0xff0000000e)\n+ t.moveChild(0x1, \"role1\", 0, 0xff00000011)\n+ t.deleteNode(0xff00000010)\n+ t.moveChild(0x1, \"role1\", 0, 0xff00000011)\n+ })\n+ // 1.role1[0] expected to be ff00000011, but was ff00000010\n+ }\n+\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\nreturn CLVersion(\nidGenerator.generate(),\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (8)
426,496
11.08.2020 17:44:11
-7,200
e2e0d925c9c0a4a145642e8b9e984431dd62cf5f
Conflict resolution tests (9)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "@@ -58,7 +58,7 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\n}\noverride fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n- return withIndex(indexAdjustments.getAdjustedIndex(parentId, role, index))\n+ return withIndex(indexAdjustments.getAdjustedIndex(parentId, role, index, true))\n}\noverride fun toString(): String {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "diff": "@@ -26,8 +26,8 @@ class IndexAdjustments {\napply(ranges, Range(index, Int.MAX_VALUE, Adjustment(-1)))\n}\n- fun getAdjustedIndex(parentId: Long, role: String?, index: Int): Int {\n- return adjustments[Role(parentId, role)]?.find { it.contains(index) }?.adjustment?.adjust(index) ?: index\n+ fun getAdjustedIndex(parentId: Long, role: String?, index: Int, allowDeleted: Boolean = false): Int {\n+ return adjustments[Role(parentId, role)]?.find { it.contains(index) }?.adjustment?.adjust(index, allowDeleted) ?: index\n}\nprivate fun apply(ranges: MutableList<Range>, newAdjustment: Range) {\n@@ -86,8 +86,8 @@ private class Adjustment(val amount: Int, val deleted: Boolean = false, val undo\nfalse\n)\n}\n- fun adjust(index: Int): Int {\n- if (deleted) {\n+ fun adjust(index: Int, allowDeleted: Boolean): Int {\n+ if (!allowDeleted && deleted) {\nthrow RuntimeException(\"Attempt to access a deleted location: $index\")\n}\nreturn index + amount\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -188,6 +188,21 @@ class ConflictResolutionTest : TreeTestBase() {\n// 1.role1[0] expected to be ff00000011, but was ff00000010\n}\n+ @Test\n+ fun knownIssue07() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role1\", 0, 0xff0000000e, null)\n+ t.addNewChild(0xff0000000e, \"role3\", 0, 0xff00000010, null)\n+ t.addNewChild(0xff00000010, \"role2\", 0, 0xff00000011, null)\n+ }, { t -> // 0\n+ t.deleteNode(0xff00000011)\n+ }, { t -> // 1\n+ t.moveChild(0x1, \"role2\", 0, 0xff00000011)\n+ t.addNewChild(0x1, \"role2\", 0, 0xff00000032, null)\n+ })\n+ // Attempt to access a deleted location: 1\n+ }\n+\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\nreturn CLVersion(\nidGenerator.generate(),\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (9)
426,496
11.08.2020 18:16:58
-7,200
3bd8ed2b94d281cf495a0b6572eef69566acf2a7
Conflict resolution tests (10)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -80,7 +80,7 @@ class MoveNodeOp(\noverride fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\nreturn withIndex(\nindexAdjustments.getAdjustedIndex(sourceParentId, sourceRole, sourceIndex),\n- indexAdjustments.getAdjustedIndex(targetParentId, targetRole, targetIndex)\n+ indexAdjustments.getAdjustedIndex(targetParentId, targetRole, targetIndex, true)\n)\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -203,6 +203,21 @@ class ConflictResolutionTest : TreeTestBase() {\n// Attempt to access a deleted location: 1\n}\n+ @Test\n+ fun knownIssue08() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role1\", 0, 0xff0000000e, null)\n+ t.addNewChild(0x1, \"role5\", 0, 0xff00000010, null)\n+ t.addNewChild(0xff00000010, \"role2\", 0, 0xff00000011, null)\n+ t.addNewChild(0xff00000010, \"role1\", 0, 0xff00000012, null)\n+ }, { t -> // 0\n+ t.moveChild(0xff00000012, \"role2\", 0, 0xff0000000e)\n+ }, { t -> // 1\n+ t.moveChild(0x1, \"role1\", 0, 0xff00000011)\n+ })\n+ // Attempt to access a deleted location: 0\n+ }\n+\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\nreturn CLVersion(\nidGenerator.generate(),\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (10)
426,496
11.08.2020 23:54:56
-7,200
341803c105cabf673ad0f52388f394df21d2d631
Conflict resolution tests (11)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/VersionMerger.kt", "diff": "@@ -96,10 +96,10 @@ class VersionMerger(private val storeCache: IDeserializingKeyValueStore, private\n.flatMap { it.value }\n.map { it.originalOp }\nvar operationsToApply: List<IOperation> = versionToApply.operations.toList()\n- for (oppositeAppliedOp in concurrentAppliedOps) {\n+ for (concurrentAppliedOp in concurrentAppliedOps) {\nval indexAdjustments = IndexAdjustments()\n- oppositeAppliedOp.loadAdjustment(indexAdjustments)\n- operationsToApply = operationsToApply.map { transformOperation(it, oppositeAppliedOp, indexAdjustments) }.toList()\n+ concurrentAppliedOp.loadAdjustment(indexAdjustments)\n+ operationsToApply = operationsToApply.map { transformOperation(it, concurrentAppliedOp, indexAdjustments) }.toList()\n}\nappliedOpsForVersion[versionToApply.id] = operationsToApply.map {\ntry {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/lazy/CLTree.kt", "diff": "@@ -147,13 +147,14 @@ class CLTree : ITree {\nnewChildrenArray = if (index == -1) {\nadd(newChildrenArray, childData.id)\n} else {\n- val anchor = getChildren(parentId, role).drop(index).firstOrNull()\n- if (anchor == null) {\n+ val children = getChildren(parentId, role).toList()\n+ if (index > children.size) throw RuntimeException(\"Invalid index $index. There are only ${children.size} nodes in ${parentId.toString(16)}.$role\")\n+ if (index == children.size) {\nadd(newChildrenArray, childData.id)\n} else {\ninsert(\nnewChildrenArray,\n- newChildrenArray.indexOf(anchor),\n+ index,\nchildData.id\n)\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "@@ -31,7 +31,11 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\n}\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n- val adjusted = { withAdjustedIndex(indexAdjustments) }\n+ val adjusted = {\n+ val a = withAdjustedIndex(indexAdjustments)\n+// indexAdjustments.nodeAdd(parentId, role, index)\n+ a\n+ }\nreturn when (previous) {\nis AddNewChildOp -> adjusted()\nis DeleteNodeOp -> {\n@@ -50,11 +54,11 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\n}\noverride fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n- indexAdjustments.nodeAdded(parentId, role, index)\n+ indexAdjustments.concurrentNodeAdd(parentId, role, index)\n}\noverride fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n- indexAdjustments.undoNodeAdded(parentId, role, index)\n+ indexAdjustments.undoConcurrentNodeAdd(parentId, role, index)\n}\noverride fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "diff": "@@ -16,12 +16,24 @@ class IndexAdjustments {\napply(ranges, Range(index + 1, Int.MAX_VALUE, Adjustment(1)))\n}\n- fun nodeAdded(parent: Long, role: String?, index: Int) {\n+ fun concurrentNodeAdd(parent: Long, role: String?, index: Int) {\nval ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\napply(ranges, Range(index, Int.MAX_VALUE, Adjustment(1)))\n}\n- fun undoNodeAdded(parent: Long, role: String?, index: Int) {\n+ fun nodeAdd(parent: Long, role: String?, index: Int) {\n+ val amount = getAdjustedIndex(parent, role, index, true) - index\n+ var ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n+ ensureRangeBorders(ranges, index, Int.MAX_VALUE)\n+ ranges = (ranges.filter { it.from < index }\n+ + Range(index, index, Adjustment(amount))\n+ + ranges.filter { it.from >= index }.map { Range(it.from + 1, if (it.to < Int.MAX_VALUE) it.to + 1 else Int.MAX_VALUE, it.adjustment) }\n+ ).toMutableList()\n+ mergeRanges(ranges)\n+ adjustments[Role(parent, role)] = ranges\n+ }\n+\n+ fun undoConcurrentNodeAdd(parent: Long, role: String?, index: Int) {\nval ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\napply(ranges, Range(index, Int.MAX_VALUE, Adjustment(-1)))\n}\n@@ -31,18 +43,7 @@ class IndexAdjustments {\n}\nprivate fun apply(ranges: MutableList<Range>, newAdjustment: Range) {\n- var i = 0;\n- while (i < ranges.size) {\n- if (ranges[i].contains(newAdjustment.from) && ranges[i].from != newAdjustment.from) {\n- ranges.add(i + 1, Range(newAdjustment.from, ranges[i].to, ranges[i].adjustment))\n- ranges[i] = Range(ranges[i].from, newAdjustment.from - 1, ranges[i].adjustment)\n- }\n- if (ranges[i].contains(newAdjustment.to) && ranges[i].to != newAdjustment.to) {\n- ranges.add(i + 1, Range(newAdjustment.to + 1, ranges[i].to, ranges[i].adjustment))\n- ranges[i] = Range(ranges[i].from, newAdjustment.to, ranges[i].adjustment)\n- }\n- i++\n- }\n+ ensureRangeBorders(ranges, newAdjustment.from, newAdjustment.to)\nfor (i in ranges.indices) {\nif (ranges[i].intersects(newAdjustment)) {\nrequire(newAdjustment.contains(ranges[i]))\n@@ -56,6 +57,21 @@ class IndexAdjustments {\nmergeRanges(ranges)\n}\n+ private fun ensureRangeBorders(ranges: MutableList<Range>, from: Int, to: Int) {\n+ var i = 0;\n+ while (i < ranges.size) {\n+ if (ranges[i].contains(from) && ranges[i].from != from) {\n+ ranges.add(i + 1, Range(from, ranges[i].to, ranges[i].adjustment))\n+ ranges[i] = Range(ranges[i].from, from - 1, ranges[i].adjustment)\n+ }\n+ if (ranges[i].contains(to) && ranges[i].to != to) {\n+ ranges.add(i + 1, Range(to + 1, ranges[i].to, ranges[i].adjustment))\n+ ranges[i] = Range(ranges[i].from, to, ranges[i].adjustment)\n+ }\n+ i++\n+ }\n+ }\n+\nprivate fun mergeRanges(ranges: MutableList<Range>) {\nvar i = 0;\nwhile (i < ranges.size - 1) {\n@@ -78,16 +94,16 @@ private class Range(val from: Int, val to: Int, val adjustment: Adjustment) {\nreturn \"$from..${if (to == Int.MAX_VALUE) \"\" else to}/$adjustment\"\n}\n}\n-private class Adjustment(val amount: Int, val deleted: Boolean = false, val undoDelete: Boolean = false) {\n+private class Adjustment(val amount: Int, val invalid: Boolean = false, val undoInvalid: Boolean = false) {\nfun combine(other: Adjustment): Adjustment {\nreturn Adjustment(\namount + other.amount,\n- (deleted || other.deleted) && !(undoDelete || other.undoDelete),\n+ (invalid || other.invalid) && !(undoInvalid || other.undoInvalid),\nfalse\n)\n}\nfun adjust(index: Int, allowDeleted: Boolean): Int {\n- if (!allowDeleted && deleted) {\n+ if (!allowDeleted && invalid) {\nthrow RuntimeException(\"Attempt to access a deleted location: $index\")\n}\nreturn index + amount\n@@ -95,8 +111,8 @@ private class Adjustment(val amount: Int, val deleted: Boolean = false, val undo\noverride fun toString(): String {\nreturn when {\n- undoDelete -> \"UNDO_DELETE\"\n- deleted -> \"DELETED\"\n+ undoInvalid -> \"UNDO_DELETE\"\n+ invalid -> \"DELETED\"\nelse -> amount.toString()\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -41,7 +41,11 @@ class MoveNodeOp(\n}\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n- val adjusted = { withAdjustedIndex(indexAdjustments) }\n+ val adjusted = {\n+ val a = withAdjustedIndex(indexAdjustments)\n+ indexAdjustments.nodeAdd(targetParentId, targetRole, targetIndex)\n+ a\n+ }\nreturn when (previous) {\nis AddNewChildOp -> adjusted()\nis DeleteNodeOp -> {\n@@ -69,15 +73,15 @@ class MoveNodeOp(\noverride fun loadAdjustment(indexAdjustments: IndexAdjustments) {\nindexAdjustments.nodeRemoved(sourceParentId, sourceRole, sourceIndex)\n- indexAdjustments.nodeAdded(targetParentId, targetRole, targetIndex)\n+ indexAdjustments.concurrentNodeAdd(targetParentId, targetRole, targetIndex)\n}\noverride fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n- indexAdjustments.undoNodeAdded(targetParentId, targetRole, targetIndex)\n+ indexAdjustments.undoConcurrentNodeAdd(targetParentId, targetRole, targetIndex)\nindexAdjustments.undoNodeRemoved(sourceParentId, sourceRole, sourceIndex)\n}\n- override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n+ override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): MoveNodeOp {\nreturn withIndex(\nindexAdjustments.getAdjustedIndex(sourceParentId, sourceRole, sourceIndex),\nindexAdjustments.getAdjustedIndex(targetParentId, targetRole, targetIndex, true)\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -218,6 +218,46 @@ class ConflictResolutionTest : TreeTestBase() {\n// Attempt to access a deleted location: 0\n}\n+ @Test\n+ fun knownIssue09a() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role1\", 0, 0xff0000000e, null)\n+ t.addNewChild(0x1, \"role2\", 0, 0xff00000011, null)\n+ }, { t -> // 0\n+ t.moveChild(0x1, \"role6\", 0, 0xff0000000e)\n+ }, { t -> // 1\n+ t.moveChild(0x1, \"role1\", 0, 0xff00000011)\n+ t.deleteNode(0xff00000011)\n+ })\n+ }\n+\n+ @Test\n+ fun knownIssue09b() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role1\", 0, 0xff0000000e, null)\n+ t.addNewChild(0x1, \"role2\", 0, 0xff00000011, null)\n+ }, { t -> // 0\n+ t.moveChild(0x1, \"role6\", 0, 0xff0000000e)\n+ }, { t -> // 1\n+ t.moveChild(0x1, \"role1\", 1, 0xff00000011)\n+ t.deleteNode(0xff00000011)\n+ })\n+ }\n+\n+ @Test\n+ fun knownIssue09c() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role1\", 0, 0xff000000aa, null)\n+ t.addNewChild(0x1, \"role1\", 1, 0xff0000000e, null)\n+ t.addNewChild(0x1, \"role2\", 0, 0xff00000011, null)\n+ }, { t -> // 0\n+ t.moveChild(0x1, \"role6\", 0, 0xff0000000e)\n+ }, { t -> // 1\n+ t.moveChild(0x1, \"role1\", 0, 0xff00000011)\n+ t.deleteNode(0xff00000011)\n+ })\n+ }\n+\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\nreturn CLVersion(\nidGenerator.generate(),\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/IndexAdjustmentsTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/IndexAdjustmentsTest.kt", "diff": "@@ -20,7 +20,7 @@ class IndexAdjustmentsTest {\nassertEquals(4, ia.getAdjustedIndex(p, r, 4))\nassertEquals(5, ia.getAdjustedIndex(p, r, 5))\n- ia.nodeAdded(p, r, 1)\n+ ia.concurrentNodeAdd(p, r, 1)\nassertEquals(0, ia.getAdjustedIndex(p, r, 0))\nassertEquals(2, ia.getAdjustedIndex(p, r, 1))\nassertEquals(3, ia.getAdjustedIndex(p, r, 2))\n@@ -28,7 +28,7 @@ class IndexAdjustmentsTest {\nassertEquals(5, ia.getAdjustedIndex(p, r, 4))\nassertEquals(6, ia.getAdjustedIndex(p, r, 5))\n- ia.nodeAdded(p, r, 3)\n+ ia.concurrentNodeAdd(p, r, 3)\nassertEquals(0, ia.getAdjustedIndex(p, r, 0))\nassertEquals(2, ia.getAdjustedIndex(p, r, 1))\nassertEquals(3, ia.getAdjustedIndex(p, r, 2))\n@@ -52,7 +52,7 @@ class IndexAdjustmentsTest {\nassertFails { ia.getAdjustedIndex(p, r, 4) }\nassertEquals(5, ia.getAdjustedIndex(p, r, 5))\n- ia.nodeAdded(p, r, 0)\n+ ia.concurrentNodeAdd(p, r, 0)\nassertEquals(1, ia.getAdjustedIndex(p, r, 0))\nassertEquals(3, ia.getAdjustedIndex(p, r, 1))\nassertFails { ia.getAdjustedIndex(p, r, 2) }\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (11)
426,496
12.08.2020 08:57:53
-7,200
2b7d23c40b1579b244cea01c5e46ac9989bff5e2
Conflict resolution tests (12)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "@@ -33,7 +33,7 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nval adjusted = {\nval a = withAdjustedIndex(indexAdjustments)\n-// indexAdjustments.nodeAdd(parentId, role, index)\n+ indexAdjustments.nodeAdd(parentId, role, index)\na\n}\nreturn when (previous) {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "@@ -39,7 +39,11 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\n}\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\n- val adjusted = { withAdjustedIndex(indexAdjustments) }\n+ val adjusted = {\n+ val a = withAdjustedIndex(indexAdjustments)\n+ indexAdjustments.nodeRemove(parentId, role, index)\n+ a\n+ }\nreturn when (previous) {\nis DeleteNodeOp -> {\nif (previous.childId == childId) {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "diff": "@@ -33,6 +33,14 @@ class IndexAdjustments {\nadjustments[Role(parent, role)] = ranges\n}\n+ fun nodeRemove(parent: Long, role: String?, index: Int) {\n+ var ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n+ ensureRangeBorders(ranges, index, Int.MAX_VALUE)\n+ ranges = ranges.filter { it.from == index }.toMutableList()\n+ mergeRanges(ranges)\n+ adjustments[Role(parent, role)] = ranges\n+ }\n+\nfun undoConcurrentNodeAdd(parent: Long, role: String?, index: Int) {\nval ranges = adjustments.getOrPut(Role(parent, role), { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\napply(ranges, Range(index, Int.MAX_VALUE, Adjustment(-1)))\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -44,6 +44,7 @@ class MoveNodeOp(\nval adjusted = {\nval a = withAdjustedIndex(indexAdjustments)\nindexAdjustments.nodeAdd(targetParentId, targetRole, targetIndex)\n+ indexAdjustments.nodeRemove(sourceParentId, sourceRole, sourceIndex)\na\n}\nreturn when (previous) {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (12)
426,496
12.08.2020 09:32:46
-7,200
a69ec9c950b87b8d1a2efe2e83e5c3e036a00c9e
Conflict resolution tests (13)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "package org.modelix.model.operations\nimport org.modelix.model.api.IConcept\n+import org.modelix.model.api.ITree\nimport org.modelix.model.api.IWriteTransaction\nimport org.modelix.model.persistent.SerializationUtil\n@@ -26,7 +27,7 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\noverride fun apply(transaction: IWriteTransaction): IAppliedOperation {\nif (transaction.getAllChildren(childId).count() != 0) {\n- throw RuntimeException(\"Attempt to delete non-leaf node: $childId\")\n+ throw RuntimeException(\"Attempt to delete non-leaf node: ${childId.toString(16)}\")\n}\nval actualNode = transaction.getChildren(parentId, role).toList()[index]\n@@ -49,6 +50,8 @@ class DeleteNodeOp(val parentId: Long, val role: String?, val index: Int, val ch\nif (previous.childId == childId) {\nprevious.undoAdjustment(indexAdjustments)\nNoOp()\n+ } else if (previous.childId == this.parentId) {\n+ DeleteNodeOp(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0, this.childId)\n} else adjusted()\n}\nis AddNewChildOp -> adjusted()\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -258,6 +258,18 @@ class ConflictResolutionTest : TreeTestBase() {\n})\n}\n+ @Test\n+ fun knownIssue10() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role1\", 0, 0xff00000010, null)\n+ }, { t -> // 0\n+ t.deleteNode(0xff00000010)\n+ }, { t -> // 1\n+ t.addNewChild(0xff00000010, \"role1\", 0, 0xff0000002b, null)\n+ t.deleteNode(0xff0000002b)\n+ })\n+ }\n+\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\nreturn CLVersion(\nidGenerator.generate(),\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (13)
426,496
12.08.2020 10:26:27
-7,200
db0198e0a8b0f0c255b881f7069db3307df9941f
Conflict resolution tests (14)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "package org.modelix.model.operations\n+import org.modelix.model.api.ITree\nimport org.modelix.model.api.IWriteTransaction\nclass MoveNodeOp(\n@@ -53,6 +54,10 @@ class MoveNodeOp(\nif (previous.childId == childId) {\nindexAdjustments.nodeRemoved(targetParentId, targetRole, targetIndex)\nNoOp()\n+ } else if (sourceParentId == previous.childId) {\n+ MoveNodeOp(childId, ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0, targetParentId, targetRole, targetIndex)\n+ } else if (targetParentId == previous.childId) {\n+ MoveNodeOp(childId, sourceParentId, sourceRole, sourceIndex, ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0)\n} else adjusted()\n}\nis MoveNodeOp -> {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -270,6 +270,20 @@ class ConflictResolutionTest : TreeTestBase() {\n})\n}\n+ @Test\n+ fun knownIssue11() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role2\", 0, 0xff00000011, null)\n+ }, { t -> // 0\n+ t.deleteNode(0xff00000011)\n+ }, { t -> // 1\n+ t.addNewChild(0xff00000011, \"role2\", 0, 0xff0000002e, null)\n+ t.moveChild(0x1, \"role3\", 0, 0xff0000002e)\n+ }, { t -> // 2\n+ t.addNewChild(0xff00000011, \"role3\", 0, 0xff00000043, null)\n+ })\n+ }\n+\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\nreturn CLVersion(\nidGenerator.generate(),\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (14)
426,496
12.08.2020 11:11:57
-7,200
1b7ec53d242971d76db111402dd4e19e315bb19f
Conflict resolution tests (15)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "@@ -40,6 +40,7 @@ class AddNewChildOp(val parentId: Long, val role: String?, val index: Int, val c\nis AddNewChildOp -> adjusted()\nis DeleteNodeOp -> {\nif (previous.childId == this.parentId) {\n+ indexAdjustments.concurrentNodeAdd(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0)\nAddNewChildOp(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0, this.childId, this.concept)\n} else {\nadjusted()\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -284,6 +284,21 @@ class ConflictResolutionTest : TreeTestBase() {\n})\n}\n+ @Test\n+ fun knownIssue12() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role1\", 0, 0xff00000012, null)\n+ t.addNewChild(0x1, \"role3\", 0, 0xff0000000e, null)\n+ }, { t -> // 0\n+ t.deleteNode(0xff00000012)\n+ t.deleteNode(0xff0000000e)\n+ }, { t -> // 1\n+ t.addNewChild(0xff00000012, \"role3\", 0, 0xff00000043, null)\n+ t.addNewChild(0xff0000000e, \"role3\", 0, 0xff00000044, null)\n+ t.deleteNode(0xff00000043)\n+ })\n+ }\n+\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\nreturn CLVersion(\nidGenerator.generate(),\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (15)
426,496
12.08.2020 12:30:58
-7,200
d0fcf658cf7b1b50529d9a4f90f504c51d82566d
Conflict resolution tests (16)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -55,8 +55,10 @@ class MoveNodeOp(\nindexAdjustments.nodeRemoved(targetParentId, targetRole, targetIndex)\nNoOp()\n} else if (sourceParentId == previous.childId) {\n+ indexAdjustments.undoConcurrentNodeAdd(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0)\nMoveNodeOp(childId, ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0, targetParentId, targetRole, targetIndex)\n} else if (targetParentId == previous.childId) {\n+ indexAdjustments.concurrentNodeAdd(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0)\nMoveNodeOp(childId, sourceParentId, sourceRole, sourceIndex, ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0)\n} else adjusted()\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/ConflictResolutionTest.kt", "diff": "@@ -299,6 +299,21 @@ class ConflictResolutionTest : TreeTestBase() {\n})\n}\n+ @Test\n+ fun knownIssue13() {\n+ knownIssueTest({ t ->\n+ t.addNewChild(0x1, \"role4\", 0, 0xff00000012, null)\n+ }, { t -> // 0\n+ t.deleteNode(0xff00000012)\n+ }, { t -> // 1\n+ t.addNewChild(0xff00000012, \"role3\", 0, 0xff00000043, null)\n+ t.addNewChild(0x1, \"role5\", 0, 0xff00000044, null)\n+ t.moveChild(0xff00000012, \"role5\", 0, 0xff00000044)\n+ t.deleteNode(0xff00000043)\n+ t.deleteNode(0xff00000044)\n+ })\n+ }\n+\nfun createVersion(opsAndTree: Pair<List<IAppliedOperation>, ITree>, previousVersion: CLVersion?): CLVersion {\nreturn CLVersion(\nidGenerator.generate(),\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (16)
426,496
12.08.2020 20:27:46
-7,200
49a5aaba9f663c2e2ec3685541805045d6da8660
Conflict resolution tests (17)
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AbstractOperation.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AbstractOperation.kt", "diff": "@@ -28,10 +28,8 @@ abstract class AbstractOperation : IOperation {\noverride fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n}\n- override fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n- }\n- override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n+ override fun withAdjustedPosition(indexAdjustments: IndexAdjustments): IOperation {\nreturn this\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/AddNewChildOp.kt", "diff": "package org.modelix.model.operations\nimport org.modelix.model.api.IConcept\n-import org.modelix.model.api.ITree\nimport org.modelix.model.api.IWriteTransaction\nimport org.modelix.model.persistent.SerializationUtil\nclass AddNewChildOp(val position: PositionInRole, val childId: Long, val concept: IConcept?) : AbstractOperation() {\n- fun withIndex(newIndex: Int): AddNewChildOp {\n- return if (newIndex == position.index) this else AddNewChildOp(position.withIndex(newIndex), childId, concept)\n+ fun withPosition(newPos: PositionInRole): AddNewChildOp {\n+ return if (newPos == position) this else AddNewChildOp(newPos, childId, concept)\n}\noverride fun apply(transaction: IWriteTransaction): IAppliedOperation {\n@@ -33,16 +32,17 @@ class AddNewChildOp(val position: PositionInRole, val childId: Long, val concept\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nval adjusted = {\n- val a = withAdjustedIndex(indexAdjustments)\n- indexAdjustments.nodeAdd(position)\n+ val a = withAdjustedPosition(indexAdjustments)\n+// indexAdjustments.nodeAdded(a, position)\na\n}\nreturn when (previous) {\nis AddNewChildOp -> adjusted()\nis DeleteNodeOp -> {\nif (previous.childId == position.nodeId) {\n- indexAdjustments.concurrentNodeAdd(PositionInRole(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0))\n- AddNewChildOp(PositionInRole(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0), this.childId, this.concept)\n+ val redirected = AddNewChildOp(PositionInRole(DETACHED_ROLE, 0), this.childId, this.concept)\n+ indexAdjustments.redirectedAdd(this, position, redirected.position)\n+ redirected\n} else {\nadjusted()\n}\n@@ -56,15 +56,11 @@ class AddNewChildOp(val position: PositionInRole, val childId: Long, val concept\n}\noverride fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n- indexAdjustments.concurrentNodeAdd(position)\n+ indexAdjustments.nodeAdded(this, position)\n}\n- override fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n- indexAdjustments.undoConcurrentNodeAdd(position)\n- }\n-\n- override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n- return withIndex(indexAdjustments.getAdjustedIndex(position, true))\n+ override fun withAdjustedPosition(indexAdjustments: IndexAdjustments): IOperation {\n+ return withPosition(indexAdjustments.getAdjustedPositionForInsert(position))\n}\noverride fun toString(): String {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/DeleteNodeOp.kt", "diff": "@@ -21,8 +21,8 @@ import org.modelix.model.api.IWriteTransaction\nimport org.modelix.model.persistent.SerializationUtil\nclass DeleteNodeOp(val position: PositionInRole, val childId: Long) : AbstractOperation() {\n- fun withIndex(newIndex: Int): DeleteNodeOp {\n- return if (newIndex == position.index) this else DeleteNodeOp(position.withIndex(newIndex), childId)\n+ fun withPosition(newPos: PositionInRole): DeleteNodeOp {\n+ return if (newPos == position) this else DeleteNodeOp(newPos, childId)\n}\noverride fun apply(transaction: IWriteTransaction): IAppliedOperation {\n@@ -41,23 +41,23 @@ class DeleteNodeOp(val position: PositionInRole, val childId: Long) : AbstractOp\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nval adjusted = {\n- val a = withAdjustedIndex(indexAdjustments)\n- indexAdjustments.nodeRemove(position)\n+ val a = withAdjustedPosition(indexAdjustments)\n+// indexAdjustments.nodeRemoved(a, position)\na\n}\nreturn when (previous) {\nis DeleteNodeOp -> {\nif (previous.childId == childId) {\n- previous.undoAdjustment(indexAdjustments)\n+ indexAdjustments.removeAdjustment(previous)\nNoOp()\n- } else if (previous.childId == position.nodeId) {\n- DeleteNodeOp(PositionInRole(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0), this.childId)\n+// } else if (previous.childId == position.nodeId) {\n+// DeleteNodeOp(PositionInRole(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0), this.childId)\n} else adjusted()\n}\nis AddNewChildOp -> adjusted()\nis MoveNodeOp -> {\nif (previous.childId == childId) {\n- previous.undoAdjustment(indexAdjustments)\n+// previous.undoAdjustment(indexAdjustments)\nDeleteNodeOp(previous.targetPosition, childId)\n} else adjusted()\n}\n@@ -69,15 +69,11 @@ class DeleteNodeOp(val position: PositionInRole, val childId: Long) : AbstractOp\n}\noverride fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n- indexAdjustments.nodeRemoved(position)\n+ indexAdjustments.nodeRemoved(this, position)\n}\n- override fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n- indexAdjustments.undoNodeRemoved(position)\n- }\n-\n- override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation {\n- return withIndex(indexAdjustments.getAdjustedIndex(position))\n+ override fun withAdjustedPosition(indexAdjustments: IndexAdjustments): IOperation {\n+ return withPosition(indexAdjustments.getAdjustedPosition(position))\n}\noverride fun toString(): String {\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IOperation.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IOperation.kt", "diff": "@@ -30,8 +30,8 @@ interface IOperation {\nfun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation\nfun loadAdjustment(indexAdjustments: IndexAdjustments)\n- fun undoAdjustment(indexAdjustments: IndexAdjustments)\n- fun withAdjustedIndex(indexAdjustments: IndexAdjustments): IOperation\n+ fun withAdjustedPosition(indexAdjustments: IndexAdjustments): IOperation\n+\nfun toCode(): String\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/IndexAdjustments.kt", "diff": "package org.modelix.model.operations\n+typealias AdjustmentFunction = (PositionInRole, forInsert: Boolean) -> PositionInRole\nclass IndexAdjustments {\n- private val adjustments: MutableMap<RoleInNode, MutableList<Range>> = HashMap()\n+ private val adjustments: MutableList<OwnerAndAdjustment> = ArrayList()\n- fun nodeRemoved(position: PositionInRole) {\n- val ranges = adjustments.getOrPut(position.roleInNode, { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n- apply(ranges, Range(position.index, position.index, Adjustment(0, true, false)))\n- apply(ranges, Range(position.index + 1, Int.MAX_VALUE, Adjustment(-1)))\n+ fun getAdjustedIndex(position: PositionInRole, forInsert: Boolean = false): Int {\n+ return getAdjustedPosition(position, forInsert).index\n}\n- fun undoNodeRemoved(position: PositionInRole) {\n- val ranges = adjustments.getOrPut(position.roleInNode, { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n- apply(ranges, Range(position.index, position.index, Adjustment(0, false, true)))\n- apply(ranges, Range(position.index + 1, Int.MAX_VALUE, Adjustment(1)))\n+ fun getAdjustedPositionForInsert(position: PositionInRole): PositionInRole {\n+ return getAdjustedPosition(position, true)\n}\n- fun concurrentNodeAdd(position: PositionInRole) {\n- val ranges = adjustments.getOrPut(position.roleInNode, { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n- apply(ranges, Range(position.index, Int.MAX_VALUE, Adjustment(1)))\n+ fun getAdjustedPosition(position: PositionInRole, forInsert: Boolean = false): PositionInRole {\n+ var result = position\n+ for (adj in adjustments) {\n+ result = adj.adj(result, forInsert)\n}\n-\n- fun nodeAdd(position: PositionInRole) {\n- val amount = getAdjustedIndex(position, true) - position.index\n- var ranges = adjustments.getOrPut(position.roleInNode, { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n- ensureRangeBorders(ranges, position.index, Int.MAX_VALUE)\n- ranges = (ranges.filter { it.from < position.index }\n- + Range(position.index, position.index, Adjustment(amount))\n- + ranges.filter { it.from >= position.index }.map { Range(it.from + 1, if (it.to < Int.MAX_VALUE) it.to + 1 else Int.MAX_VALUE, it.adjustment) }\n- ).toMutableList()\n- mergeRanges(ranges)\n- adjustments[position.roleInNode] = ranges\n+ return result\n}\n- fun nodeRemove(position: PositionInRole) {\n- var ranges = adjustments.getOrPut(position.roleInNode, { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n- ensureRangeBorders(ranges, position.index, Int.MAX_VALUE)\n- ranges = ranges.filter { it.from == position.index }.toMutableList()\n- mergeRanges(ranges)\n- adjustments[position.roleInNode] = ranges\n+ fun addAdjustment(owner: IOperation, adj: AdjustmentFunction) {\n+ adjustments.add(OwnerAndAdjustment(owner, adj))\n}\n- fun undoConcurrentNodeAdd(position: PositionInRole) {\n- val ranges = adjustments.getOrPut(position.roleInNode, { mutableListOf(Range(0, Int.MAX_VALUE, Adjustment(0))) })\n- apply(ranges, Range(position.index, Int.MAX_VALUE, Adjustment(-1)))\n+ fun removeAdjustment(owner: IOperation) {\n+ adjustments.removeAll { it.owner == owner }\n}\n- fun getAdjustedIndex(position: PositionInRole, allowDeleted: Boolean = false): Int {\n- return adjustments[position.roleInNode]?.find { it.contains(position.index) }?.adjustment?.adjust(position.index, allowDeleted) ?: position.index\n+ fun nodeAdded(owner: IOperation, addedPos: PositionInRole) {\n+ addAdjustment(owner) { posToTransform, forInsert ->\n+ if (posToTransform.roleInNode == addedPos.roleInNode && posToTransform.index >= addedPos.index) {\n+ posToTransform.withIndex(posToTransform.index + 1)\n+ } else {\n+ posToTransform\n+ }\n+ }\n}\n- private fun apply(ranges: MutableList<Range>, newAdjustment: Range) {\n- ensureRangeBorders(ranges, newAdjustment.from, newAdjustment.to)\n- for (i in ranges.indices) {\n- if (ranges[i].intersects(newAdjustment)) {\n- require(newAdjustment.contains(ranges[i]))\n- ranges[i] = Range(\n- ranges[i].from,\n- ranges[i].to,\n- ranges[i].adjustment.combine(newAdjustment.adjustment)\n- )\n+ fun redirectedAdd(owner: IOperation, originalPos: PositionInRole, redirectedPos: PositionInRole) {\n+ addAdjustment(owner) { posToTransform, forInsert ->\n+ if (posToTransform.roleInNode == redirectedPos.roleInNode && posToTransform.index >= redirectedPos.index) {\n+ posToTransform.withIndex(posToTransform.index + 1)\n+ } else {\n+ posToTransform\n}\n}\n- mergeRanges(ranges)\n+ redirectReads(owner, originalPos, redirectedPos)\n}\n- private fun ensureRangeBorders(ranges: MutableList<Range>, from: Int, to: Int) {\n- var i = 0;\n- while (i < ranges.size) {\n- if (ranges[i].contains(from) && ranges[i].from != from) {\n- ranges.add(i + 1, Range(from, ranges[i].to, ranges[i].adjustment))\n- ranges[i] = Range(ranges[i].from, from - 1, ranges[i].adjustment)\n+ fun redirectedMove(owner: IOperation, source: PositionInRole, originalTarget: PositionInRole, redirectedTarget: PositionInRole) {\n+ addAdjustment(owner) { posToTransform, forInsert ->\n+ when {\n+ posToTransform == originalTarget -> {\n+ if (forInsert) posToTransform else redirectedTarget\n}\n- if (ranges[i].contains(to) && ranges[i].to != to) {\n- ranges.add(i + 1, Range(to + 1, ranges[i].to, ranges[i].adjustment))\n- ranges[i] = Range(ranges[i].from, to, ranges[i].adjustment)\n+ posToTransform.roleInNode == originalTarget.roleInNode -> {\n+ when {\n+ posToTransform.index > originalTarget.index -> posToTransform.withIndex(posToTransform.index - 1)\n+ posToTransform.index == originalTarget.index -> {\n+ if (forInsert) posToTransform\n+ else throw RuntimeException(\"$originalTarget was removed\")\n}\n- i++\n+ else -> posToTransform\n}\n}\n-\n- private fun mergeRanges(ranges: MutableList<Range>) {\n- var i = 0;\n- while (i < ranges.size - 1) {\n- if (ranges[i].adjustment == ranges[i + 1].adjustment) {\n- require(ranges[i].to + 1 == ranges[i + 1].from)\n- ranges[i] = Range(ranges[i].from, ranges[i + 1].to, ranges[i].adjustment)\n- ranges.removeAt(i + 1)\n+ posToTransform.roleInNode == redirectedTarget.roleInNode -> {\n+ if (posToTransform.index >= redirectedTarget.index) {\n+ posToTransform.withIndex(posToTransform.index + 1)\n} else {\n- i++\n+ posToTransform\n+ }\n+ }\n+ else -> posToTransform\n}\n}\n}\n+\n+ fun redirectReads(owner: IOperation, originalPos: PositionInRole, redirectedPos: PositionInRole) {\n+ addAdjustment(owner) { posToTransform, forInsert ->\n+ if (!forInsert && posToTransform == originalPos) redirectedPos else posToTransform\n+ }\n}\n-private class Range(val from: Int, val to: Int, val adjustment: Adjustment) {\n- fun intersects(other: Range) = contains(other.from) || contains(other.to) || other.contains(from) || other.contains(to)\n- fun contains(index: Int) = index in from..to\n- fun contains(other: Range) = other.from in from..to && other.to in from..to\n- override fun toString(): String {\n- return \"$from..${if (to == Int.MAX_VALUE) \"\" else to}/$adjustment\"\n+ fun nodeRemoved(owner: IOperation, removedPos: PositionInRole) {\n+ addAdjustment(owner) { posToTransform, forInsert ->\n+ if (posToTransform.roleInNode == removedPos.roleInNode) {\n+ when {\n+ posToTransform.index > removedPos.index -> posToTransform.withIndex(posToTransform.index - 1)\n+ posToTransform.index == removedPos.index -> {\n+ if (forInsert) posToTransform\n+ else throw RuntimeException(\"$removedPos was removed\")\n}\n+ else -> posToTransform\n}\n-private class Adjustment(val amount: Int, val invalid: Boolean = false, val undoInvalid: Boolean = false) {\n- fun combine(other: Adjustment): Adjustment {\n- return Adjustment(\n- amount + other.amount,\n- (invalid || other.invalid) && !(undoInvalid || other.undoInvalid),\n- false\n- )\n+ } else {\n+ posToTransform\n+ }\n+ }\n+ }\n+\n+ fun nodeMoved(owner: IOperation, sourcePos: PositionInRole, targetPos: PositionInRole) {\n+ addAdjustment(owner) { posToTransform, forInsert ->\n+ when (posToTransform.roleInNode) {\n+ sourcePos.roleInNode -> {\n+ when {\n+ posToTransform.index > sourcePos.index -> posToTransform.withIndex(posToTransform.index - 1)\n+ posToTransform.index == sourcePos.index -> {\n+ if (forInsert) posToTransform\n+ else targetPos\n}\n- fun adjust(index: Int, allowDeleted: Boolean): Int {\n- if (!allowDeleted && invalid) {\n- throw RuntimeException(\"Attempt to access a deleted location: $index\")\n+ else -> posToTransform\n}\n- return index + amount\n+ }\n+ targetPos.roleInNode -> {\n+ when {\n+ posToTransform.index >= targetPos.index -> posToTransform.withIndex(posToTransform.index + 1)\n+ else -> posToTransform\n}\n- override fun toString(): String {\n- return when {\n- undoInvalid -> \"UNDO_DELETE\"\n- invalid -> \"DELETED\"\n- else -> amount.toString()\n+ }\n+ else -> {\n+ posToTransform\n+ }\n}\n}\n}\n+}\n+\n+data class OwnerAndAdjustment(val owner: IOperation, val adj: AdjustmentFunction) {}\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/MoveNodeOp.kt", "diff": "@@ -19,11 +19,11 @@ import org.modelix.model.api.ITree\nimport org.modelix.model.api.IWriteTransaction\nclass MoveNodeOp(val childId: Long, val sourcePosition: PositionInRole, val targetPosition: PositionInRole) : AbstractOperation() {\n- fun withIndex(newSourceIndex: Int, newTargetIndex: Int): MoveNodeOp {\n- return if (newSourceIndex == sourcePosition.index && newTargetIndex == targetPosition.index) {\n+ fun withPos(newSource: PositionInRole, newTarget: PositionInRole): MoveNodeOp {\n+ return if (newSource == sourcePosition && newTarget == targetPosition) {\nthis\n} else {\n- MoveNodeOp(childId, sourcePosition.withIndex(newSourceIndex), targetPosition.withIndex(newTargetIndex))\n+ MoveNodeOp(childId, newSource, newTarget)\n}\n}\n@@ -34,28 +34,29 @@ class MoveNodeOp(val childId: Long, val sourcePosition: PositionInRole, val targ\noverride fun transform(previous: IOperation, indexAdjustments: IndexAdjustments): IOperation {\nval adjusted = {\n- val a = withAdjustedIndex(indexAdjustments)\n- indexAdjustments.nodeAdd(targetPosition)\n- indexAdjustments.nodeRemove(sourcePosition)\n+ val a = withAdjustedPosition(indexAdjustments)\n+// indexAdjustments.nodeMoved(a, sourcePosition, targetPosition)\na\n}\nreturn when (previous) {\nis AddNewChildOp -> adjusted()\nis DeleteNodeOp -> {\nif (previous.childId == childId) {\n- indexAdjustments.nodeRemoved(targetPosition)\n+ indexAdjustments.nodeRemoved(this, targetPosition)\nNoOp()\n} else if (sourcePosition.nodeId == previous.childId) {\n- indexAdjustments.undoConcurrentNodeAdd(PositionInRole(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0))\n+ val redirectedTarget = PositionInRole(DETACHED_ROLE, 0)\n+ indexAdjustments.redirectedMove(this, sourcePosition, targetPosition, redirectedTarget)\nMoveNodeOp(childId, PositionInRole(ITree.ROOT_ID, ITree.DETACHED_NODES_ROLE, 0), targetPosition)\n} else if (targetPosition.nodeId == previous.childId) {\n- indexAdjustments.concurrentNodeAdd(PositionInRole(DETACHED_ROLE, 0))\n- MoveNodeOp(childId, sourcePosition, PositionInRole(DETACHED_ROLE, 0))\n+ val redirectedTarget = PositionInRole(DETACHED_ROLE, 0)\n+ indexAdjustments.redirectedMove(this, sourcePosition, targetPosition, redirectedTarget)\n+ MoveNodeOp(childId, sourcePosition, redirectedTarget)\n} else adjusted()\n}\nis MoveNodeOp -> {\nif (previous.childId == childId) {\n- previous.undoAdjustment(indexAdjustments)\n+// previous.undoAdjustment(indexAdjustments)\nMoveNodeOp(\nchildId,\nprevious.targetPosition,\n@@ -71,19 +72,13 @@ class MoveNodeOp(val childId: Long, val sourcePosition: PositionInRole, val targ\n}\noverride fun loadAdjustment(indexAdjustments: IndexAdjustments) {\n- indexAdjustments.nodeRemoved(sourcePosition)\n- indexAdjustments.concurrentNodeAdd(targetPosition)\n+ indexAdjustments.nodeMoved(this, sourcePosition, targetPosition)\n}\n- override fun undoAdjustment(indexAdjustments: IndexAdjustments) {\n- indexAdjustments.undoConcurrentNodeAdd(targetPosition)\n- indexAdjustments.undoNodeRemoved(sourcePosition)\n- }\n-\n- override fun withAdjustedIndex(indexAdjustments: IndexAdjustments): MoveNodeOp {\n- return withIndex(\n- indexAdjustments.getAdjustedIndex(sourcePosition),\n- indexAdjustments.getAdjustedIndex(targetPosition, true)\n+ override fun withAdjustedPosition(indexAdjustments: IndexAdjustments): MoveNodeOp {\n+ return withPos(\n+ indexAdjustments.getAdjustedPosition(sourcePosition),\n+ indexAdjustments.getAdjustedPositionForInsert(targetPosition)\n)\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/operations/OTWriteTransaction.kt", "diff": "@@ -27,7 +27,7 @@ import org.modelix.model.logDebug\nclass OTWriteTransaction(private val transaction: IWriteTransaction, private val otBranch: OTBranch, protected var idGenerator: IIdGenerator) : IWriteTransaction {\nprotected fun apply(op: IOperation) {\n- val opCode = op.toCode()\n+ val opCode = op.toString()\nif (opCode.isNotEmpty()) logDebug({ opCode }, OTWriteTransaction::class)\nval appliedOp = op.apply(transaction)\notBranch.operationApplied(appliedOp)\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/commonTest/kotlin/org/modelix/model/IndexAdjustmentsTest.kt", "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/IndexAdjustmentsTest.kt", "diff": "package org.modelix.model\nimport org.modelix.model.operations.IndexAdjustments\n+import org.modelix.model.operations.NoOp\nimport org.modelix.model.operations.PositionInRole\nimport kotlin.test.Test\nimport kotlin.test.assertEquals\n@@ -13,6 +14,7 @@ class IndexAdjustmentsTest {\nval p = 1L\nval r = \"role\"\nval ia = IndexAdjustments()\n+ val owner = NoOp()\nassertEquals(0, ia.getAdjustedIndex(PositionInRole(p, r, 0)))\nassertEquals(1, ia.getAdjustedIndex(PositionInRole(p, r, 1)))\n@@ -21,7 +23,7 @@ class IndexAdjustmentsTest {\nassertEquals(4, ia.getAdjustedIndex(PositionInRole(p, r, 4)))\nassertEquals(5, ia.getAdjustedIndex(PositionInRole(p, r, 5)))\n- ia.concurrentNodeAdd(PositionInRole(p, r, 1))\n+ ia.nodeAdded(owner, PositionInRole(p, r, 1))\nassertEquals(0, ia.getAdjustedIndex(PositionInRole(p, r, 0)))\nassertEquals(2, ia.getAdjustedIndex(PositionInRole(p, r, 1)))\nassertEquals(3, ia.getAdjustedIndex(PositionInRole(p, r, 2)))\n@@ -29,7 +31,7 @@ class IndexAdjustmentsTest {\nassertEquals(5, ia.getAdjustedIndex(PositionInRole(p, r, 4)))\nassertEquals(6, ia.getAdjustedIndex(PositionInRole(p, r, 5)))\n- ia.concurrentNodeAdd(PositionInRole(p, r, 3))\n+ ia.nodeAdded(owner, PositionInRole(p, r, 3))\nassertEquals(0, ia.getAdjustedIndex(PositionInRole(p, r, 0)))\nassertEquals(2, ia.getAdjustedIndex(PositionInRole(p, r, 1)))\nassertEquals(3, ia.getAdjustedIndex(PositionInRole(p, r, 2)))\n@@ -37,7 +39,7 @@ class IndexAdjustmentsTest {\nassertEquals(6, ia.getAdjustedIndex(PositionInRole(p, r, 4)))\nassertEquals(7, ia.getAdjustedIndex(PositionInRole(p, r, 5)))\n- ia.nodeRemoved(PositionInRole(p, r, 2))\n+ ia.nodeRemoved(owner, PositionInRole(p, r, 2))\nassertEquals(0, ia.getAdjustedIndex(PositionInRole(p, r, 0)))\nassertEquals(2, ia.getAdjustedIndex(PositionInRole(p, r, 1)))\nassertFails { ia.getAdjustedIndex(PositionInRole(p, r, 2)) }\n@@ -45,7 +47,7 @@ class IndexAdjustmentsTest {\nassertEquals(5, ia.getAdjustedIndex(PositionInRole(p, r, 4)))\nassertEquals(6, ia.getAdjustedIndex(PositionInRole(p, r, 5)))\n- ia.nodeRemoved(PositionInRole(p, r, 4))\n+ ia.nodeRemoved(owner, PositionInRole(p, r, 4))\nassertEquals(0, ia.getAdjustedIndex(PositionInRole(p, r, 0)))\nassertEquals(2, ia.getAdjustedIndex(PositionInRole(p, r, 1)))\nassertFails { ia.getAdjustedIndex(PositionInRole(p, r, 2)) }\n@@ -53,7 +55,7 @@ class IndexAdjustmentsTest {\nassertFails { ia.getAdjustedIndex(PositionInRole(p, r, 4)) }\nassertEquals(5, ia.getAdjustedIndex(PositionInRole(p, r, 5)))\n- ia.concurrentNodeAdd(PositionInRole(p, r, 0))\n+ ia.nodeAdded(owner, PositionInRole(p, r, 0))\nassertEquals(1, ia.getAdjustedIndex(PositionInRole(p, r, 0)))\nassertEquals(3, ia.getAdjustedIndex(PositionInRole(p, r, 1)))\nassertFails { ia.getAdjustedIndex(PositionInRole(p, r, 2)) }\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
Conflict resolution tests (17)
426,504
13.08.2020 17:34:00
-7,200
e67788aa5a4f0c35539c2b943af8ff9aecec1e4e
simplifying model-server main
[ { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "diff": "@@ -17,18 +17,17 @@ package org.modelix.model.server;\nimport com.beust.jcommander.JCommander;\nimport com.beust.jcommander.Parameter;\n-import java.io.File;\n-import java.net.InetAddress;\n-import java.net.InetSocketAddress;\n-import java.nio.charset.StandardCharsets;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.log4j.Logger;\n-import org.eclipse.jetty.server.Handler;\nimport org.eclipse.jetty.server.Server;\n-import org.eclipse.jetty.server.handler.ContextHandler;\nimport org.eclipse.jetty.server.handler.HandlerList;\nimport org.eclipse.jetty.servlet.ServletContextHandler;\n+import java.io.File;\n+import java.net.InetAddress;\n+import java.net.InetSocketAddress;\n+import java.nio.charset.StandardCharsets;\n+\nclass CmdLineArgs {\n@Parameter(\n@@ -46,6 +45,7 @@ class CmdLineArgs {\npublic class Main {\nprivate static final Logger LOG = Logger.getLogger(Main.class);\n+ public static final int DEFAULT_PORT = 28101;\npublic static void main(String[] args) {\nCmdLineArgs cmdLineArgs = new CmdLineArgs();\n@@ -61,7 +61,7 @@ public class Main {\nInetSocketAddress bindTo =\nnew InetSocketAddress(\nInetAddress.getByName(\"0.0.0.0\"),\n- portStr == null ? 28101 : Integer.parseInt(portStr));\n+ portStr == null ? DEFAULT_PORT : Integer.parseInt(portStr));\nIgniteStoreClient storeClient = new IgniteStoreClient(cmdLineArgs.jdbcConfFile);\nRestModelServer modelServer = new RestModelServer(storeClient);\n@@ -82,27 +82,17 @@ public class Main {\nRuntime.getRuntime()\n.addShutdownHook(\n- new Thread() {\n- @Override\n- public void run() {\n+ new Thread(() -> {\ntry {\nserver.stop();\n} catch (Exception ex) {\nSystem.out.println(ex.getMessage());\nex.printStackTrace();\n}\n- }\n- });\n+ }));\n} catch (Exception ex) {\nSystem.out.println(\"Server failed: \" + ex.getMessage());\nex.printStackTrace();\n}\n}\n-\n- private static Handler withContext(String path, Handler handler) {\n- ContextHandler contextHandler = new ContextHandler();\n- contextHandler.setContextPath(path);\n- contextHandler.setHandler(handler);\n- return contextHandler;\n- }\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
simplifying model-server main
426,504
13.08.2020 17:34:30
-7,200
16e173d3a7e46e389ca52c38ccc516b0918ca5ac
introduce TEXT_PLAIN constant
[ { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "diff": "@@ -45,6 +45,7 @@ public class RestModelServer {\npublic static final Pattern HASH_PATTERN = Pattern.compile(\"[a-zA-Z0-9\\\\-_]{43}\");\npublic static final String PROTECTED_PREFIX = \"$$$\";\nprivate static final String REPOSITORY_ID_KEY = \"repositoryId\";\n+ private static final String TEXT_PLAIN = \"text/plain\";\nprivate String sharedSecret;\nprivate IStoreClient storeClient;\n@@ -72,11 +73,11 @@ public class RestModelServer {\nthrows ServletException, IOException {\nif (isHealthy()) {\nresp.setStatus(HttpServletResponse.SC_OK);\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.getWriter().print(\"healthy\");\n} else {\nresp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.getWriter().print(\"not healthy\");\n}\n}\n@@ -84,8 +85,8 @@ public class RestModelServer {\nprivate boolean isHealthy() {\nlong value = toLong(storeClient.get(HEALTH_KEY)) + 1;\nstoreClient.put(HEALTH_KEY, Long.toString(value));\n- if (toLong(storeClient.get(HEALTH_KEY)) < value) return false;\n- return true;\n+ boolean healthy = toLong(storeClient.get(HEALTH_KEY)) >= value;\n+ return healthy;\n}\nprivate long toLong(String value) {\n@@ -110,7 +111,7 @@ public class RestModelServer {\nif (value == null) {\nresp.setStatus(HttpServletResponse.SC_NOT_FOUND);\n} else {\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.getWriter().print(value);\n}\n}\n@@ -129,7 +130,7 @@ public class RestModelServer {\n}\nif (email == null || email.isEmpty()) {\nresp.setStatus(HttpServletResponse.SC_FORBIDDEN);\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.getWriter().print(\"Not logged in.\");\nreturn;\n}\n@@ -141,7 +142,7 @@ public class RestModelServer {\nLong.toString(\nSystem.currentTimeMillis()\n+ 7 * 24 * 60 * 60 * 1000));\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.getWriter().print(token);\n}\n}),\n@@ -158,7 +159,7 @@ public class RestModelServer {\nString token = extractToken(req);\nString email =\nstoreClient.get(PROTECTED_PREFIX + \"_token_email_\" + token);\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.getWriter().print(email);\n}\n}),\n@@ -177,7 +178,7 @@ public class RestModelServer {\nthrow new RuntimeException(\"No permission to access \" + key);\n}\nlong value = storeClient.generateId(key);\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\nresp.getWriter().print(Long.toString(value));\n}\n@@ -220,7 +221,7 @@ public class RestModelServer {\nreq.getInputStream(), StandardCharsets.UTF_8);\nstoreClient.put(key, value);\nresp.setStatus(HttpServletResponse.SC_OK);\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\nresp.getWriter().print(\"OK\");\n}\n@@ -255,7 +256,7 @@ public class RestModelServer {\nstoreClient.put(key, value);\n}\nresp.setStatus(HttpServletResponse.SC_OK);\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\nresp.getWriter().print(json.length() + \" entries written\");\n}\n@@ -308,7 +309,7 @@ public class RestModelServer {\n@Override\nprotected void doGet(HttpServletRequest req, HttpServletResponse resp)\nthrows ServletException, IOException {\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.getWriter().println(\"Model Server\");\n}\n}),\n@@ -324,7 +325,7 @@ public class RestModelServer {\nfinal String subscribedKey = req.getPathInfo().substring(1);\nif (subscribedKey.startsWith(PROTECTED_PREFIX)) {\nresp.setStatus(HttpServletResponse.SC_FORBIDDEN);\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.getWriter()\n.print(\"No permission to access \" + subscribedKey);\n}\n@@ -413,7 +414,7 @@ public class RestModelServer {\nreturn true;\n} else {\nresp.setStatus(HttpServletResponse.SC_FORBIDDEN);\n- resp.setContentType(\"text/plain\");\n+ resp.setContentType(TEXT_PLAIN);\nresp.getWriter().print(\"Not logged in.\");\nreturn false;\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
introduce TEXT_PLAIN constant
426,504
13.08.2020 17:57:14
-7,200
a9e2768c4fd704ed2265737424ab341b4a979d62
start documenting the endpoints of the model-server
[ { "change_type": "MODIFY", "old_path": "model-server/README.md", "new_path": "model-server/README.md", "diff": "@@ -30,3 +30,19 @@ bintray_api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n```\nNote that you cannot publish versions ending with 'SNAPSHOT'.\n+\n+## APIs\n+\n+Valid keys are keys starting with the PROTECTED_PREFIX ($$$).\n+\n+* GET `/health`: returns 200 if the system is healthy, 500 otherwise\n+* GET `/get/<key>`: returns 200 if the key is found, 404 otherwise\n+* GET `/generateToken`: returns 403 if the request is not authorized, otherwise the token\n+* GET `/getEmail`: requires authorization. Returns the email associated with token used for authorization\n+* POST `/counter/<key>`: requires authorization. The key should be a valid key. It returns the id associated with the key (TODO: clarify)\n+* GET `/getRecursively/<key>`: requires authorization. Returns an array with all the keys being the given key or any key contained under it\n+* PUT `/put/<key>`: requires authorization. The key should be a valid key. Assign the value (specified as the body of the request) to the given key\n+* PUT `/putAll`: requires authorization. The body should be a JSON array of pairs key/value. Each pair is an object with properties \"key\" and \"value\"\n+* PUT `/getAll`: requires authorization. The body should be a JSON array of keys. It will return a JSON array to objects with properties \"key\" and \"value\"\n+* GET `/`: returns the string \"Model Server\"\n+* GET `/subscribe/<key>`: TBW\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
start documenting the endpoints of the model-server
426,504
14.08.2020 10:37:30
-7,200
1bf06c3f2cc68bbeb56290129bb32fda29b5f691
add CachingStoreClientTest
[ { "change_type": "ADD", "old_path": null, "new_path": ".idea/uiDesigner.xml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<project version=\"4\">\n+ <component name=\"Palette2\">\n+ <group name=\"Swing\">\n+ <item class=\"com.intellij.uiDesigner.HSpacer\" tooltip-text=\"Horizontal Spacer\" icon=\"/com/intellij/uiDesigner/icons/hspacer.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"1\" hsize-policy=\"6\" anchor=\"0\" fill=\"1\" />\n+ </item>\n+ <item class=\"com.intellij.uiDesigner.VSpacer\" tooltip-text=\"Vertical Spacer\" icon=\"/com/intellij/uiDesigner/icons/vspacer.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"1\" anchor=\"0\" fill=\"2\" />\n+ </item>\n+ <item class=\"javax.swing.JPanel\" icon=\"/com/intellij/uiDesigner/icons/panel.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"3\" hsize-policy=\"3\" anchor=\"0\" fill=\"3\" />\n+ </item>\n+ <item class=\"javax.swing.JScrollPane\" icon=\"/com/intellij/uiDesigner/icons/scrollPane.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"7\" hsize-policy=\"7\" anchor=\"0\" fill=\"3\" />\n+ </item>\n+ <item class=\"javax.swing.JButton\" icon=\"/com/intellij/uiDesigner/icons/button.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"3\" anchor=\"0\" fill=\"1\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"Button\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JRadioButton\" icon=\"/com/intellij/uiDesigner/icons/radioButton.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"3\" anchor=\"8\" fill=\"0\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"RadioButton\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JCheckBox\" icon=\"/com/intellij/uiDesigner/icons/checkBox.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"3\" anchor=\"8\" fill=\"0\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"CheckBox\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JLabel\" icon=\"/com/intellij/uiDesigner/icons/label.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"Label\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JTextField\" icon=\"/com/intellij/uiDesigner/icons/textField.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\">\n+ <preferred-size width=\"150\" height=\"-1\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JPasswordField\" icon=\"/com/intellij/uiDesigner/icons/passwordField.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\">\n+ <preferred-size width=\"150\" height=\"-1\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JFormattedTextField\" icon=\"/com/intellij/uiDesigner/icons/formattedTextField.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\">\n+ <preferred-size width=\"150\" height=\"-1\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTextArea\" icon=\"/com/intellij/uiDesigner/icons/textArea.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTextPane\" icon=\"/com/intellij/uiDesigner/icons/textPane.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JEditorPane\" icon=\"/com/intellij/uiDesigner/icons/editorPane.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JComboBox\" icon=\"/com/intellij/uiDesigner/icons/comboBox.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"2\" anchor=\"8\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JTable\" icon=\"/com/intellij/uiDesigner/icons/table.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JList\" icon=\"/com/intellij/uiDesigner/icons/list.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"2\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTree\" icon=\"/com/intellij/uiDesigner/icons/tree.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTabbedPane\" icon=\"/com/intellij/uiDesigner/icons/tabbedPane.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"3\" hsize-policy=\"3\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"200\" height=\"200\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JSplitPane\" icon=\"/com/intellij/uiDesigner/icons/splitPane.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"3\" hsize-policy=\"3\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"200\" height=\"200\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JSpinner\" icon=\"/com/intellij/uiDesigner/icons/spinner.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JSlider\" icon=\"/com/intellij/uiDesigner/icons/slider.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JSeparator\" icon=\"/com/intellij/uiDesigner/icons/separator.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\" />\n+ </item>\n+ <item class=\"javax.swing.JProgressBar\" icon=\"/com/intellij/uiDesigner/icons/progressbar.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"0\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JToolBar\" icon=\"/com/intellij/uiDesigner/icons/toolbar.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"0\" fill=\"1\">\n+ <preferred-size width=\"-1\" height=\"20\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JToolBar$Separator\" icon=\"/com/intellij/uiDesigner/icons/toolbarSeparator.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"0\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JScrollBar\" icon=\"/com/intellij/uiDesigner/icons/scrollbar.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"0\" anchor=\"0\" fill=\"2\" />\n+ </item>\n+ </group>\n+ </component>\n+</project>\n\\ No newline at end of file\n" }, { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -32,6 +32,8 @@ dependencies {\ncompile group: 'commons-io', name: 'commons-io', version: '2.6'\ncompile group: 'com.google.guava', name: 'guava', version: '28.1-jre'\ncompile group: 'com.beust', name: 'jcommander', version: '1.7'\n+\n+ testCompile group: 'junit', name: 'junit', version: '4.12'\n}\ntask copyLibs(type: Copy) {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/test/java/org/modelix/model/server/CachingStoreClientTest.java", "diff": "+package org.modelix.model.server;\n+\n+import org.junit.Assert;\n+import org.junit.Test;\n+\n+import java.util.Arrays;\n+import java.util.LinkedList;\n+import java.util.List;\n+\n+public class CachingStoreClientTest {\n+\n+ class DummyStore implements IStoreClient {\n+\n+ private List<String> requests = new LinkedList<>();\n+\n+ public List<String> getRequests() {\n+ return requests;\n+ }\n+\n+ @Override\n+ public String get(String key) {\n+ requests.add(key);\n+ return key + \"_value\";\n+ }\n+\n+ @Override\n+ public List<String> getAll(List<String> keys) {\n+ throw new UnsupportedOperationException();\n+ }\n+\n+ @Override\n+ public void put(String key, String value) {\n+ throw new UnsupportedOperationException();\n+ }\n+\n+ @Override\n+ public void listen(String key, IKeyListener listener) {\n+ throw new UnsupportedOperationException();\n+ }\n+\n+ @Override\n+ public void removeListener(String key, IKeyListener listener) {\n+ throw new UnsupportedOperationException();\n+ }\n+\n+ @Override\n+ public long generateId(String key) {\n+ throw new UnsupportedOperationException();\n+ }\n+ }\n+\n+ @Test\n+ public void getCacheMiss() {\n+ DummyStore dummyStore = new DummyStore();\n+ CachingStoreClient csc = new CachingStoreClient(dummyStore);\n+ Assert.assertEquals(\"foo_value\", csc.get(\"foo\"));\n+ Assert.assertEquals(Arrays.asList(\"foo\"), dummyStore.requests);\n+ }\n+\n+ @Test\n+ public void getCacheHit() {\n+ DummyStore dummyStore = new DummyStore();\n+ CachingStoreClient csc = new CachingStoreClient(dummyStore);\n+ csc.get(\"foo\");\n+ dummyStore.requests.clear();\n+ Assert.assertEquals(\"foo_value\", csc.get(\"foo\"));\n+ Assert.assertEquals(Arrays.asList(), dummyStore.requests);\n+ }\n+\n+ @Test\n+ public void getAllCacheMiss() {\n+ DummyStore dummyStore = new DummyStore();\n+ CachingStoreClient csc = new CachingStoreClient(dummyStore);\n+ Assert.assertEquals(Arrays.asList(\"foo_value\", \"bar_value\", \"zum_value\"), csc.getAll(Arrays.asList(\"foo\", \"bar\", \"zum\")));\n+ Assert.assertEquals(Arrays.asList(\"foo\", \"bar\", \"zum\"), dummyStore.requests);\n+ }\n+\n+ @Test\n+ public void getAllCacheHit() {\n+ DummyStore dummyStore = new DummyStore();\n+ CachingStoreClient csc = new CachingStoreClient(dummyStore);\n+ csc.get(\"foo\");\n+ csc.get(\"bar\");\n+ csc.get(\"zum\");\n+ dummyStore.requests.clear();\n+ Assert.assertEquals(Arrays.asList(\"foo_value\", \"bar_value\", \"zum_value\"), csc.getAll(Arrays.asList(\"foo\", \"bar\", \"zum\")));\n+ Assert.assertEquals(Arrays.asList(), dummyStore.requests);\n+ }\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add CachingStoreClientTest
426,504
14.08.2020 11:35:14
-7,200
55e06a2c857a03d7226dc9328c12787ad721a742
create InMemoryStoreClient
[ { "change_type": "ADD", "old_path": null, "new_path": ".idea/uiDesigner.xml", "diff": "+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<project version=\"4\">\n+ <component name=\"Palette2\">\n+ <group name=\"Swing\">\n+ <item class=\"com.intellij.uiDesigner.HSpacer\" tooltip-text=\"Horizontal Spacer\" icon=\"/com/intellij/uiDesigner/icons/hspacer.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"1\" hsize-policy=\"6\" anchor=\"0\" fill=\"1\" />\n+ </item>\n+ <item class=\"com.intellij.uiDesigner.VSpacer\" tooltip-text=\"Vertical Spacer\" icon=\"/com/intellij/uiDesigner/icons/vspacer.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"1\" anchor=\"0\" fill=\"2\" />\n+ </item>\n+ <item class=\"javax.swing.JPanel\" icon=\"/com/intellij/uiDesigner/icons/panel.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"3\" hsize-policy=\"3\" anchor=\"0\" fill=\"3\" />\n+ </item>\n+ <item class=\"javax.swing.JScrollPane\" icon=\"/com/intellij/uiDesigner/icons/scrollPane.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"7\" hsize-policy=\"7\" anchor=\"0\" fill=\"3\" />\n+ </item>\n+ <item class=\"javax.swing.JButton\" icon=\"/com/intellij/uiDesigner/icons/button.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"3\" anchor=\"0\" fill=\"1\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"Button\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JRadioButton\" icon=\"/com/intellij/uiDesigner/icons/radioButton.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"3\" anchor=\"8\" fill=\"0\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"RadioButton\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JCheckBox\" icon=\"/com/intellij/uiDesigner/icons/checkBox.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"3\" anchor=\"8\" fill=\"0\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"CheckBox\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JLabel\" icon=\"/com/intellij/uiDesigner/icons/label.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"8\" fill=\"0\" />\n+ <initial-values>\n+ <property name=\"text\" value=\"Label\" />\n+ </initial-values>\n+ </item>\n+ <item class=\"javax.swing.JTextField\" icon=\"/com/intellij/uiDesigner/icons/textField.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\">\n+ <preferred-size width=\"150\" height=\"-1\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JPasswordField\" icon=\"/com/intellij/uiDesigner/icons/passwordField.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\">\n+ <preferred-size width=\"150\" height=\"-1\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JFormattedTextField\" icon=\"/com/intellij/uiDesigner/icons/formattedTextField.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\">\n+ <preferred-size width=\"150\" height=\"-1\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTextArea\" icon=\"/com/intellij/uiDesigner/icons/textArea.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTextPane\" icon=\"/com/intellij/uiDesigner/icons/textPane.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JEditorPane\" icon=\"/com/intellij/uiDesigner/icons/editorPane.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JComboBox\" icon=\"/com/intellij/uiDesigner/icons/comboBox.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"2\" anchor=\"8\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JTable\" icon=\"/com/intellij/uiDesigner/icons/table.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JList\" icon=\"/com/intellij/uiDesigner/icons/list.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"2\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTree\" icon=\"/com/intellij/uiDesigner/icons/tree.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"150\" height=\"50\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JTabbedPane\" icon=\"/com/intellij/uiDesigner/icons/tabbedPane.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"3\" hsize-policy=\"3\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"200\" height=\"200\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JSplitPane\" icon=\"/com/intellij/uiDesigner/icons/splitPane.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"3\" hsize-policy=\"3\" anchor=\"0\" fill=\"3\">\n+ <preferred-size width=\"200\" height=\"200\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JSpinner\" icon=\"/com/intellij/uiDesigner/icons/spinner.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"true\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JSlider\" icon=\"/com/intellij/uiDesigner/icons/slider.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"8\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JSeparator\" icon=\"/com/intellij/uiDesigner/icons/separator.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"6\" anchor=\"0\" fill=\"3\" />\n+ </item>\n+ <item class=\"javax.swing.JProgressBar\" icon=\"/com/intellij/uiDesigner/icons/progressbar.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"0\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JToolBar\" icon=\"/com/intellij/uiDesigner/icons/toolbar.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"6\" anchor=\"0\" fill=\"1\">\n+ <preferred-size width=\"-1\" height=\"20\" />\n+ </default-constraints>\n+ </item>\n+ <item class=\"javax.swing.JToolBar$Separator\" icon=\"/com/intellij/uiDesigner/icons/toolbarSeparator.png\" removable=\"false\" auto-create-binding=\"false\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"0\" hsize-policy=\"0\" anchor=\"0\" fill=\"1\" />\n+ </item>\n+ <item class=\"javax.swing.JScrollBar\" icon=\"/com/intellij/uiDesigner/icons/scrollbar.png\" removable=\"false\" auto-create-binding=\"true\" can-attach-label=\"false\">\n+ <default-constraints vsize-policy=\"6\" hsize-policy=\"0\" anchor=\"0\" fill=\"2\" />\n+ </item>\n+ </group>\n+ </component>\n+</project>\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/main/java/org/modelix/model/server/InMemoryStoreClient.java", "diff": "+package org.modelix.model.server;\n+\n+import java.util.Collections;\n+import java.util.HashMap;\n+import java.util.LinkedList;\n+import java.util.List;\n+import java.util.Map;\n+import java.util.stream.Collectors;\n+\n+public class InMemoryStoreClient implements IStoreClient {\n+\n+ private Map<String, String> values = new HashMap<>();\n+ private Map<String, List<IKeyListener>> listeners = new HashMap<>();\n+\n+ @Override\n+ public String get(String key) {\n+ return values.get(key);\n+ }\n+\n+ @Override\n+ public List<String> getAll(List<String> keys) {\n+ return keys.stream().map(this::get).collect(Collectors.toList());\n+ }\n+\n+ @Override\n+ public void put(String key, String value) {\n+ values.put(key, value);\n+ listeners.getOrDefault(key, Collections.emptyList()).forEach(l -> l.changed(key, value));\n+ }\n+\n+ @Override\n+ public void listen(String key, IKeyListener listener) {\n+ if (!listeners.containsKey(key)) {\n+ listeners.put(key, new LinkedList<>());\n+ }\n+ listeners.get(key).add(listener);\n+ }\n+\n+ @Override\n+ public void removeListener(String key, IKeyListener listener) {\n+ if (!listeners.containsKey(key)) {\n+ return;\n+ }\n+ listeners.get(key).remove(listener);\n+ }\n+\n+ @Override\n+ public long generateId(String key) {\n+ return key.hashCode();\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "diff": "@@ -21,6 +21,8 @@ import java.io.File;\nimport java.net.InetAddress;\nimport java.net.InetSocketAddress;\nimport java.nio.charset.StandardCharsets;\n+\n+import com.beust.jcommander.converters.BooleanConverter;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.log4j.Logger;\nimport org.eclipse.jetty.server.Handler;\n@@ -42,6 +44,12 @@ class CmdLineArgs {\ndescription = \"Path to the JDBC configuration file\",\nconverter = FileConverter.class)\nFile jdbcConfFile = null;\n+\n+ @Parameter(\n+ names = \"-inmemory\",\n+ description = \"Use in-memory storage\",\n+ converter = BooleanConverter.class)\n+ Boolean inmemory = false;\n}\npublic class Main {\n@@ -62,7 +70,12 @@ public class Main {\nnew InetSocketAddress(\nInetAddress.getByName(\"0.0.0.0\"),\nportStr == null ? 28101 : Integer.parseInt(portStr));\n- IgniteStoreClient storeClient = new IgniteStoreClient(cmdLineArgs.jdbcConfFile);\n+ IStoreClient storeClient;\n+ if (cmdLineArgs.inmemory) {\n+ storeClient = new InMemoryStoreClient();\n+ } else {\n+ storeClient = new IgniteStoreClient(cmdLineArgs.jdbcConfFile);\n+ }\nRestModelServer modelServer = new RestModelServer(storeClient);\nFile sharedSecretFile = cmdLineArgs.secretFile;\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "+package org.modelix.model.server;\n+\n+import io.cucumber.java.en.Given;\n+import io.cucumber.java.en.When;\n+import io.cucumber.java.en.Then;\n+\n+public class Stepdefs {\n+\n+ @Given(\"the server has been started with in-memory storage\")\n+ public void the_server_has_been_started_with_in_memory_storage() {\n+ // Write code here that turns the phrase above into concrete actions\n+ throw new io.cucumber.java.PendingException();\n+ }\n+\n+ @When(\"I visit {string}\")\n+ public void i_visit(String string) {\n+ // Write code here that turns the phrase above into concrete actions\n+ throw new io.cucumber.java.PendingException();\n+ }\n+\n+ @Then(\"I should get an OK response\")\n+ public void i_should_get_an_ok_response() {\n+ // Write code here that turns the phrase above into concrete actions\n+ throw new io.cucumber.java.PendingException();\n+ }\n+\n+ @Then(\"the text of the page should be {string}\")\n+ public void the_text_of_the_page_should_be(String string) {\n+ // Write code here that turns the phrase above into concrete actions\n+ throw new io.cucumber.java.PendingException();\n+ }\n+\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/test/resources/functionaltests/basic_routes.feature", "diff": "+Feature: Basic routes\n+ We verify some basic routes work\n+\n+ Scenario: Homepage works\n+ Given the server has been started with in-memory storage\n+ When I visit \"/\"\n+ Then I should get an OK response\n+ And the text of the page should be \"Model Server\"\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
create InMemoryStoreClient
426,504
14.08.2020 11:56:31
-7,200
8cb8703185ac4f7e860b38e0903aa2911ab27528
implementing first steps
[ { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "diff": "@@ -61,6 +61,7 @@ public class Main {\nLOG.info(\"Max memory (bytes): \" + Runtime.getRuntime().maxMemory());\nLOG.info(\"Server process started\");\n+ LOG.info(\"In memory: \" + cmdLineArgs.inmemory);\nLOG.info(\"Path to secret file: \" + cmdLineArgs.secretFile);\nLOG.info(\"Path to JDBC configuration file: \" + cmdLineArgs.jdbcConfFile);\n@@ -72,6 +73,9 @@ public class Main {\nportStr == null ? 28101 : Integer.parseInt(portStr));\nIStoreClient storeClient;\nif (cmdLineArgs.inmemory) {\n+ if (cmdLineArgs.jdbcConfFile != null) {\n+ LOG.warn(\"JDBC conf file is ignored when in-memory flag is set\");\n+ }\nstoreClient = new InMemoryStoreClient();\n} else {\nstoreClient = new IgniteStoreClient(cmdLineArgs.jdbcConfFile);\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "package org.modelix.model.server.functionaltests;\n+import com.google.common.base.Charsets;\n+import io.cucumber.java.After;\n+import io.cucumber.java.Before;\nimport io.cucumber.java.en.Given;\nimport io.cucumber.java.en.When;\nimport io.cucumber.java.en.Then;\n+import java.io.BufferedReader;\n+import java.io.IOException;\n+import java.io.InputStreamReader;\n+import java.net.HttpURLConnection;\n+import java.net.URI;\n+import java.net.URL;\n+import java.net.http.HttpClient;\n+import java.net.http.HttpRequest;\n+import java.net.http.HttpResponse;\n+\n+import static org.junit.Assert.*;\n+\npublic class Stepdefs {\n+ private Process p;\n+ private HttpResponse<String> stringResponse;\n+\n+ @Before\n+ public void prepare() {\n+\n+ }\n+\n+ @After\n+ public void cleanup() {\n+ if (p != null) {\n+ p.destroyForcibly();\n+ p = null;\n+ }\n+ stringResponse = null;\n+ }\n+\n@Given(\"the server has been started with in-memory storage\")\npublic void the_server_has_been_started_with_in_memory_storage() {\n- // Write code here that turns the phrase above into concrete actions\n- throw new io.cucumber.java.PendingException();\n+ try {\n+ p = Runtime.getRuntime().exec(\"../gradlew run --args='-inmemory'\");BufferedReader stdInput = new BufferedReader(new\n+ InputStreamReader(p.getInputStream()));\n+\n+ BufferedReader stdError = new BufferedReader(new\n+ InputStreamReader(p.getErrorStream()));\n+\n+ new Thread(new Runnable() {\n+ @Override\n+ public void run() {\n+ try {\n+ String s;\n+ while ((s = stdInput.readLine()) != null) {\n+ System.out.println(s);\n+ }\n+\n+ // read any errors from the attempted command\n+ while ((s = stdError.readLine()) != null) {\n+ System.out.println(s);\n+ }\n+ } catch (IOException e) {\n+ e.printStackTrace();;\n+ }\n+ }\n+ }).start();\n+ } catch (IOException e) {\n+ throw new RuntimeException(e);\n+ }\n}\n@When(\"I visit {string}\")\n- public void i_visit(String string) {\n- // Write code here that turns the phrase above into concrete actions\n- throw new io.cucumber.java.PendingException();\n+ public void i_visit(String path) {\n+ try {\n+ var client = HttpClient.newHttpClient();\n+ var request = HttpRequest.newBuilder(\n+ URI.create(\"http://localhost:28101\" + path))\n+ .header(\"accept\", \"application/json\")\n+ .build();\n+\n+ stringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n+ } catch (IOException|InterruptedException e) {\n+ e.printStackTrace();\n+ }\n}\n@Then(\"I should get an OK response\")\npublic void i_should_get_an_ok_response() {\n- // Write code here that turns the phrase above into concrete actions\n- throw new io.cucumber.java.PendingException();\n+ Assert.assertEquals(200, stringResponse.statusCode());\n}\n@Then(\"the text of the page should be {string}\")\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
implementing first steps
426,504
14.08.2020 12:15:28
-7,200
df25a9a09a6b1328999c8c0bcdd005ad3f2b4935
implement retry logic in functional tests
[ { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -33,6 +33,7 @@ dependencies {\ncompile group: 'com.google.guava', name: 'guava', version: '28.1-jre'\ncompile group: 'com.beust', name: 'jcommander', version: '1.7'\n+ testImplementation group: 'junit', name: 'junit', version: '4.12'\ntestImplementation group: 'io.cucumber', name: 'cucumber-java', version: '6.2.2'\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/InMemoryStoreClient.java", "new_path": "model-server/src/main/java/org/modelix/model/server/InMemoryStoreClient.java", "diff": "@@ -9,8 +9,8 @@ import java.util.stream.Collectors;\npublic class InMemoryStoreClient implements IStoreClient {\n- private Map<String, String> values = new HashMap<>();\n- private Map<String, List<IKeyListener>> listeners = new HashMap<>();\n+ private final Map<String, String> values = new HashMap<>();\n+ private final Map<String, List<IKeyListener>> listeners = new HashMap<>();\n@Override\npublic String get(String key) {\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "@@ -10,6 +10,7 @@ import io.cucumber.java.en.Then;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\n+import java.net.ConnectException;\nimport java.net.HttpURLConnection;\nimport java.net.URI;\nimport java.net.URL;\n@@ -23,17 +24,22 @@ public class Stepdefs {\nprivate Process p;\nprivate HttpResponse<String> stringResponse;\n+ private int nRetries;\n@Before\npublic void prepare() {\n-\n+ nRetries = 10;\n}\n@After\npublic void cleanup() {\nif (p != null) {\n- p.destroyForcibly();\n+ p.destroy();\np = null;\n+ try {\n+ Thread.sleep(1000);\n+ } catch (InterruptedException e) {\n+ }\n}\nstringResponse = null;\n}\n@@ -47,9 +53,7 @@ public class Stepdefs {\nBufferedReader stdError = new BufferedReader(new\nInputStreamReader(p.getErrorStream()));\n- new Thread(new Runnable() {\n- @Override\n- public void run() {\n+ new Thread(() -> {\ntry {\nString s;\nwhile ((s = stdInput.readLine()) != null) {\n@@ -61,10 +65,14 @@ public class Stepdefs {\nSystem.out.println(s);\n}\n} catch (IOException e) {\n- e.printStackTrace();;\n- }\n+ // this may happen when closing\n}\n}).start();\n+\n+ try {\n+ Thread.sleep(1000);\n+ } catch (InterruptedException e) {\n+ }\n} catch (IOException e) {\nthrow new RuntimeException(e);\n}\n@@ -80,6 +88,48 @@ public class Stepdefs {\n.build();\nstringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n+ } catch (ConnectException e) {\n+ if (nRetries > 0) {\n+ System.out.println(\" (connection failed, retrying in a bit. nRetries=\" + nRetries + \")\");\n+ nRetries--;\n+ try {\n+ Thread.sleep(1000);\n+ } catch (InterruptedException e2) {\n+\n+ }\n+ i_visit(path);\n+ } else {\n+ throw new RuntimeException(e);\n+ }\n+ } catch (IOException|InterruptedException e) {\n+ e.printStackTrace();\n+ }\n+ }\n+\n+ @When(\"I PUT on {string} the value {string}\")\n+ public void i_put_on_the_value(String path, String value) {\n+ try {\n+ var client = HttpClient.newHttpClient();\n+ var request = HttpRequest.newBuilder(\n+ URI.create(\"http://localhost:28101\" + path))\n+ .method(\"PUT\", HttpRequest.BodyPublishers.ofString(value))\n+ .header(\"accept\", \"application/json\")\n+ .build();\n+\n+ stringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n+ } catch (ConnectException e) {\n+ if (nRetries > 0) {\n+ System.out.println(\" (connection failed, retrying in a bit. nRetries=\" + nRetries + \")\");\n+ nRetries--;\n+ try {\n+ Thread.sleep(1000);\n+ } catch (InterruptedException e2) {\n+\n+ }\n+ i_put_on_the_value(path, value);\n+ } else {\n+ throw new RuntimeException(e);\n+ }\n} catch (IOException|InterruptedException e) {\ne.printStackTrace();\n}\n@@ -87,13 +137,17 @@ public class Stepdefs {\n@Then(\"I should get an OK response\")\npublic void i_should_get_an_ok_response() {\n- Assert.assertEquals(200, stringResponse.statusCode());\n+ assertEquals(200, stringResponse.statusCode());\n+ }\n+\n+ @Then(\"I should get a NOT FOUND response\")\n+ public void i_should_get_a_not_found_response() {\n+ assertEquals(404, stringResponse.statusCode());\n}\n@Then(\"the text of the page should be {string}\")\n- public void the_text_of_the_page_should_be(String string) {\n- // Write code here that turns the phrase above into concrete actions\n- throw new io.cucumber.java.PendingException();\n+ public void the_text_of_the_page_should_be(String expectedText) {\n+ assertEquals(expectedText.strip(), stringResponse.body().strip());\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/resources/functionaltests/basic_routes.feature", "new_path": "model-server/src/test/resources/functionaltests/basic_routes.feature", "diff": "@@ -6,3 +6,9 @@ Feature: Basic routes\nWhen I visit \"/\"\nThen I should get an OK response\nAnd the text of the page should be \"Model Server\"\n+\n+ Scenario: Heartbeat works\n+ Given the server has been started with in-memory storage\n+ When I visit \"/health\"\n+ Then I should get an OK response\n+ And the text of the page should be \"healthy\"\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/test/resources/functionaltests/storing.feature", "diff": "+Feature: Storing routes\n+ We verify the core storing routes work\n+\n+ Scenario: Storing and retrieving\n+ Given the server has been started with in-memory storage\n+ When I PUT on \"/put/abc\" the value \"qwerty6789\"\n+ And I visit \"/get/abc\"\n+ Then I should get an OK response\n+ And the text of the page should be \"qwerty6789\"\n+\n+ Scenario: Retrieving unexisting key\n+ Given the server has been started with in-memory storage\n+ When I visit \"/get/abc\"\n+ Then I should get a NOT FOUND response\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
implement retry logic in functional tests
426,504
14.08.2020 12:16:23
-7,200
451dc1c52cbccd8df8e1f28fa2262d7dbffda28c
add functional tests to GitHub actions
[ { "change_type": "MODIFY", "old_path": ".github/workflows/modelclient.yml", "new_path": ".github/workflows/modelclient.yml", "diff": "@@ -54,3 +54,16 @@ jobs:\njava-version: 11\n- name: Run tests for model client\nrun: cd model-client && ../gradlew ktlintCheck\n+\n+ functionalTests:\n+\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - uses: actions/checkout@v1\n+ - name: Set up JDK 11\n+ uses: actions/setup-java@v1\n+ with:\n+ java-version: 11\n+ - name: Run tests for model client\n+ run: cd model-client && ../gradlew cucumber\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add functional tests to GitHub actions
426,504
14.08.2020 14:12:07
-7,200
3b639c33da3f6a38d7e7ab478d3a17bb88338392
add functional tests for getToken
[ { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "@@ -3,22 +3,24 @@ package org.modelix.model.server.functionaltests;\nimport com.google.common.base.Charsets;\nimport io.cucumber.java.After;\nimport io.cucumber.java.Before;\n+import io.cucumber.java.en.And;\nimport io.cucumber.java.en.Given;\n-import io.cucumber.java.en.When;\nimport io.cucumber.java.en.Then;\n+import io.cucumber.java.en.When;\nimport java.io.BufferedReader;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.net.ConnectException;\n-import java.net.HttpURLConnection;\nimport java.net.URI;\n-import java.net.URL;\nimport java.net.http.HttpClient;\nimport java.net.http.HttpRequest;\nimport java.net.http.HttpResponse;\n+import java.util.Arrays;\n+import java.util.regex.Pattern;\n-import static org.junit.Assert.*;\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertTrue;\npublic class Stepdefs {\n@@ -26,6 +28,9 @@ public class Stepdefs {\nprivate HttpResponse<String> stringResponse;\nprivate int nRetries;\n+ private static final boolean VERBOSE_SERVER = false;\n+ private static final boolean VERBOSE_CONNECTION = false;\n+\n@Before\npublic void prepare() {\nnRetries = 10;\n@@ -57,13 +62,17 @@ public class Stepdefs {\ntry {\nString s;\nwhile ((s = stdInput.readLine()) != null) {\n+ if (VERBOSE_SERVER) {\nSystem.out.println(s);\n}\n+ }\n// read any errors from the attempted command\nwhile ((s = stdError.readLine()) != null) {\n+ if (VERBOSE_SERVER) {\nSystem.out.println(s);\n}\n+ }\n} catch (IOException e) {\n// this may happen when closing\n}\n@@ -90,7 +99,9 @@ public class Stepdefs {\nstringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n} catch (ConnectException e) {\nif (nRetries > 0) {\n+ if (VERBOSE_CONNECTION) {\nSystem.out.println(\" (connection failed, retrying in a bit. nRetries=\" + nRetries + \")\");\n+ }\nnRetries--;\ntry {\nThread.sleep(1000);\n@@ -119,7 +130,9 @@ public class Stepdefs {\nstringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n} catch (ConnectException e) {\nif (nRetries > 0) {\n+ if (VERBOSE_CONNECTION) {\nSystem.out.println(\" (connection failed, retrying in a bit. nRetries=\" + nRetries + \")\");\n+ }\nnRetries--;\ntry {\nThread.sleep(1000);\n@@ -150,4 +163,13 @@ public class Stepdefs {\nassertEquals(expectedText.strip(), stringResponse.body().strip());\n}\n+ @Then(\"the text of the page should be {int} characters long\")\n+ public void theTextOfThePageShouldBeCharactersLong(int nLength) {\n+ assertEquals(nLength, stringResponse.body().length());\n+ }\n+\n+ @Then(\"the text of the page contains only hexadecimal digits\")\n+ public void theTextOfThePageContainsOnlyHexadecimalDigits() {\n+ Pattern.matches(\"[a-f0-9]+\", stringResponse.body());\n+ }\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/test/resources/functionaltests/token.feature", "diff": "+Feature: Storing routes\n+ We verify the core storing routes work\n+\n+ Scenario: A token can be generated\n+ Given the server has been started with in-memory storage\n+ When I visit \"/generateToken\"\n+ Then I should get an OK response\n+ And the text of the page should be 32 characters long\n+ And the text of the page contains only hexadecimal digits\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add functional tests for getToken
426,504
14.08.2020 14:44:33
-7,200
4d72d2eda17d8ff3be15887a2cf1806ce1c66488
add putAll/getAll functional tests
[ { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "package org.modelix.model.server.functionaltests;\nimport com.google.common.base.Charsets;\n+import io.cucumber.gherkin.internal.com.eclipsesource.json.JsonValue;\nimport io.cucumber.java.After;\nimport io.cucumber.java.Before;\nimport io.cucumber.java.en.And;\nimport io.cucumber.java.en.Given;\nimport io.cucumber.java.en.Then;\nimport io.cucumber.java.en.When;\n+import io.cucumber.messages.internal.com.google.gson.JsonElement;\n+import io.cucumber.messages.internal.com.google.gson.JsonParser;\n+import io.cucumber.messages.internal.com.google.gson.stream.JsonReader;\nimport java.io.BufferedReader;\nimport java.io.IOException;\n@@ -172,4 +176,10 @@ public class Stepdefs {\npublic void theTextOfThePageContainsOnlyHexadecimalDigits() {\nPattern.matches(\"[a-f0-9]+\", stringResponse.body());\n}\n+\n+ @Then(\"the text of the page should be this JSON {string}\")\n+ public void theTextOfThePageShouldBeThisJSON(String expectedJsonStr) {\n+ JsonElement expectedJson = JsonParser.parseString(expectedJsonStr);\n+ assertEquals(expectedJson, JsonParser.parseString(stringResponse.body()));\n+ }\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/resources/functionaltests/storing.feature", "new_path": "model-server/src/test/resources/functionaltests/storing.feature", "diff": "@@ -12,3 +12,46 @@ Feature: Storing routes\nGiven the server has been started with in-memory storage\nWhen I visit \"/get/abc\"\nThen I should get a NOT FOUND response\n+\n+ Scenario: Retrieving multiple keys, all existing\n+ Given the server has been started with in-memory storage\n+ When I PUT on \"/put/aaa\" the value \"value1\"\n+ And I PUT on \"/put/bbb\" the value \"value2\"\n+ And I PUT on \"/put/ccc\" the value \"value3\"\n+ And I PUT on \"/getAll\" the value \"['aaa', 'bbb', 'ccc']\"\n+ Then I should get an OK response\n+ And the text of the page should be this JSON \"[{'value': 'value1', 'key': 'aaa'}, {'value': 'value2', 'key': 'bbb'}, {'value': 'value3', 'key': 'ccc'}]\"\n+\n+ Scenario: Retrieving multiple keys, some existing\n+ Given the server has been started with in-memory storage\n+ When I PUT on \"/put/aaa\" the value \"value1\"\n+ And I PUT on \"/put/ccc\" the value \"value3\"\n+ And I PUT on \"/getAll\" the value \"['aaa', 'bbb', 'ccc']\"\n+ Then I should get an OK response\n+ And the text of the page should be this JSON \"[{'value': 'value1', 'key': 'aaa'}, {'key': 'bbb'}, {'value': 'value3', 'key': 'ccc'}]\"\n+\n+ Scenario: Retrieving multiple keys, none existing\n+ Given the server has been started with in-memory storage\n+ When I PUT on \"/getAll\" the value \"['aaa', 'bbb', 'ccc']\"\n+ Then I should get an OK response\n+ And the text of the page should be this JSON \"[{'key': 'aaa'}, {'key': 'bbb'}, {'key': 'ccc'}]\"\n+\n+ Scenario: Putting multiple keys, with some nulls, are stored correctly\n+ Given the server has been started with in-memory storage\n+ When I PUT on \"/putAll\" the value \"[{'value': 'value1', 'key': 'aaa'}, {'key': 'bbb'}, {'value': 'value3', 'key': 'ccc'}]\"\n+ And I PUT on \"/getAll\" the value \"['aaa', 'bbb', 'ccc']\"\n+ Then I should get an OK response\n+ And the text of the page should be this JSON \"[{'value': 'value1', 'key': 'aaa'}, {'key': 'bbb'}, {'value': 'value3', 'key': 'ccc'}]\"\n+\n+ Scenario: Putting multiple keys, with some nulls, are recognized correctly\n+ Given the server has been started with in-memory storage\n+ When I PUT on \"/putAll\" the value \"[{'value': 'value1', 'key': 'aaa'}, {'key': 'bbb'}, {'value': 'value3', 'key': 'ccc'}]\"\n+ Then I should get an OK response\n+ And the text of the page should be \"2 entries written\"\n+\n+ Scenario: Putting multiple keys\n+ Given the server has been started with in-memory storage\n+ When I PUT on \"/putAll\" the value \"[{'value': 'value1', 'key': 'aaa'}, {'key': 'bbb', 'value': 'value2'}, {'value': 'value3', 'key': 'ccc'}]\"\n+ And I PUT on \"/getAll\" the value \"['aaa', 'bbb', 'ccc']\"\n+ Then I should get an OK response\n+ And the text of the page should be this JSON \"[{'value': 'value1', 'key': 'aaa'}, {'key': 'bbb', 'value': 'value2'}, {'value': 'value3', 'key': 'ccc'}]\"\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add putAll/getAll functional tests
426,504
14.08.2020 14:44:47
-7,200
f0a217000689dcf730e028dc34a5a8e0689bce21
handling partially correct putAll input
[ { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "diff": "@@ -239,8 +239,15 @@ public class RestModelServer {\nIOUtils.toString(\nreq.getInputStream(), StandardCharsets.UTF_8);\nJSONArray json = new JSONArray(jsonStr);\n+ int writtenEntries = 0;\nfor (Object entry_ : json) {\nJSONObject entry = (JSONObject) entry_;\n+ if (!entry.has(\"key\") || !entry.has(\"value\")) {\n+ // We skip invalid entries instead of failing because we do not\n+ // want to fail after having written some entries\n+ LOG.warn(\"Skipping invalid entry: \" + entry);\n+ continue;\n+ }\nString key = entry.getString(\"key\");\nString value = entry.getString(\"value\");\n@@ -253,11 +260,12 @@ public class RestModelServer {\ncontinue;\n}\nstoreClient.put(key, value);\n+ writtenEntries++;\n}\nresp.setStatus(HttpServletResponse.SC_OK);\nresp.setContentType(\"text/plain\");\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\n- resp.getWriter().print(json.length() + \" entries written\");\n+ resp.getWriter().print(writtenEntries + \" entries written\");\n}\n}),\n\"/putAll\");\n@@ -275,7 +283,7 @@ public class RestModelServer {\nreq.getInputStream(), StandardCharsets.UTF_8);\nJSONArray reqJson = new JSONArray(reqJsonStr);\nJSONArray respJson = new JSONArray();\n- List<String> keys = new ArrayList<String>(reqJson.length());\n+ List<String> keys = new ArrayList<>(reqJson.length());\nfor (Object entry_ : reqJson) {\nString key = (String) entry_;\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
handling partially correct putAll input
426,504
14.08.2020 14:54:01
-7,200
062f14d2f96cf290becb7c83070f49b8b621e4ec
fix which project has the cucumber task executed under github actions
[ { "change_type": "MODIFY", "old_path": ".github/workflows/modelclient.yml", "new_path": ".github/workflows/modelclient.yml", "diff": "@@ -66,4 +66,4 @@ jobs:\nwith:\njava-version: 11\n- name: Run tests for model client\n- run: cd model-client && ../gradlew cucumber\n\\ No newline at end of file\n+ run: cd model-server && ../gradlew cucumber\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
fix which project has the cucumber task executed under github actions
426,504
15.08.2020 08:53:41
-7,200
320b462a5661e469904b36cb2a39e597814f99ae
add functional tests for subscription
[ { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -51,7 +51,7 @@ task cucumber() {\njavaexec {\nmain = \"io.cucumber.core.cli.Main\"\nclasspath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output\n- args = ['--plugin', 'pretty', '--glue', 'org.modelix.model.server.functionaltests', 'src/test/resources/functionaltests/subscription.feature']\n+ args = ['--plugin', 'pretty', '--glue', 'org.modelix.model.server.functionaltests', 'src/test/resources/functionaltests']\n}\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "@@ -201,35 +201,35 @@ public class Stepdefs {\n@Then(\"I should get an event {string}\")\npublic void iShouldGetAnEvent(String expectedEventValue) {\n- assertTrue(events.stream().anyMatch(e -> e.getComment().equals(expectedEventValue)));\n+ try {\n+ Thread.sleep(200);\n+ } catch (InterruptedException e) {\n+\n+ }\n+ assertTrue(events.stream().anyMatch(e -> e.readData().equals(expectedEventValue)));\n+ }\n+\n+ @Then(\"I should NOT get an event {string}\")\n+ public void iShouldNOTGetAnEvent(String expectedEventValue) {\n+ try {\n+ Thread.sleep(200);\n+ } catch (InterruptedException e) {\n+\n+ }\n+ assertTrue(events.stream().noneMatch(e -> e.readData().equals(expectedEventValue)));\n}\n@When(\"I prepare to receive events from {string}\")\npublic void iPrepareToReceiveEvents(String path) {\n- try {\n- Thread.sleep(8000);\n+ // wait for server to be up\n+ i_visit(\"/\");\n+\nClient client = ClientBuilder.newClient();\nWebTarget target = client.target(\"http://localhost:28101\" + path);\nsource = SseEventSource.target(target).build();\nsource.register(inboundSseEvent -> events.add(inboundSseEvent));\nsource.open();\n- } catch (Throwable e) {\n- System.err.println(\"GOTCHA\");\n- if (e.getCause() instanceof ConnectException && nRetries > 0) {\n- if (VERBOSE_CONNECTION) {\n- System.out.println(\" (connection failed, retrying in a bit. nRetries=\" + nRetries + \")\");\n}\n- nRetries--;\n- try {\n- Thread.sleep(1000);\n- } catch (InterruptedException e2) {\n}\n- iPrepareToReceiveEvents(path);\n- } else {\n- throw new RuntimeException(e);\n- }\n- }\n- }\n-}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/resources/functionaltests/subscription.feature", "new_path": "model-server/src/test/resources/functionaltests/subscription.feature", "diff": "@@ -6,3 +6,9 @@ Feature: Storing routes\nWhen I prepare to receive events from \"/subscribe/dylandog\"\nAnd I PUT on \"/put/dylandog\" the value \"a comic book\"\nThen I should get an event \"a comic book\"\n+\n+ Scenario: Events are received only for the key subscribed\n+ Given the server has been started with in-memory storage\n+ When I prepare to receive events from \"/subscribe/dylandog\"\n+ And I PUT on \"/put/topolino\" the value \"a comic book\"\n+ Then I should NOT get an event \"a comic book\"\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add functional tests for subscription
426,504
15.08.2020 09:07:29
-7,200
0a8cfdd933aacd68ab25d192d1bff1f52de70253
make /getEmail return no content when the user provided no token
[ { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "diff": "@@ -153,9 +153,15 @@ public class RestModelServer {\n@Override\nprotected void doGet(HttpServletRequest req, HttpServletResponse resp)\nthrows ServletException, IOException {\n- if (!checkAuthorization(storeClient, req, resp)) return;\n+ if (!checkAuthorization(storeClient, req, resp)) {\n+ return;\n+ }\nString token = extractToken(req);\n+ if (token == null) {\n+ resp.setStatus(HttpServletResponse.SC_NO_CONTENT);\n+ return;\n+ }\nString email =\nstoreClient.get(PROTECTED_PREFIX + \"_token_email_\" + token);\nresp.setContentType(\"text/plain\");\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "@@ -178,6 +178,11 @@ public class Stepdefs {\nassertEquals(404, stringResponse.statusCode());\n}\n+ @Then(\"I should get an NO CONTENT response\")\n+ public void iShouldGetAnNOCONTENTResponse() {\n+ assertEquals(204, stringResponse.statusCode());\n+ }\n+\n@Then(\"the text of the page should be {string}\")\npublic void the_text_of_the_page_should_be(String expectedText) {\nassertEquals(expectedText.strip(), stringResponse.body().strip());\n@@ -231,5 +236,4 @@ public class Stepdefs {\nsource.register(inboundSseEvent -> events.add(inboundSseEvent));\nsource.open();\n}\n-\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/test/resources/functionaltests/userinfo.feature", "diff": "+Feature: Basic routes\n+ We verify some basic routes work\n+\n+ Scenario: No email to get when not logged\n+ Given the server has been started with in-memory storage\n+ When I visit \"/getEmail\"\n+ Then I should get an NO CONTENT response\n+ And the text of the page should be 0 characters long\n+\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
make /getEmail return no content when the user provided no token
426,504
15.08.2020 09:12:53
-7,200
5859808ad9db40bdbcbe69213b4e62e24cb68f52
working on getEmail
[ { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "@@ -137,6 +137,37 @@ public class Stepdefs {\n}\n}\n+ @When(\"I visit {string} with header {string} set to {string}\")\n+ public void iVisitWithHeaderSetTo(String path, String header, String value) {\n+ try {\n+ var client = HttpClient.newHttpClient();\n+ var request = HttpRequest.newBuilder(\n+ URI.create(\"http://localhost:28101\" + path))\n+ .header(\"accept\", \"application/json\")\n+ .header(header, value)\n+ .build();\n+\n+ stringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n+ } catch (ConnectException e) {\n+ if (nRetries > 0) {\n+ if (VERBOSE_CONNECTION) {\n+ System.out.println(\" (connection failed, retrying in a bit. nRetries=\" + nRetries + \")\");\n+ }\n+ nRetries--;\n+ try {\n+ Thread.sleep(1000);\n+ } catch (InterruptedException e2) {\n+\n+ }\n+ iVisitWithHeaderSetTo(path, header, value);\n+ } else {\n+ throw new RuntimeException(e);\n+ }\n+ } catch (IOException|InterruptedException e) {\n+ e.printStackTrace();\n+ }\n+ }\n+\n@When(\"I PUT on {string} the value {string}\")\npublic void i_put_on_the_value(String path, String value) {\ntry {\n@@ -236,4 +267,5 @@ public class Stepdefs {\nsource.register(inboundSseEvent -> events.add(inboundSseEvent));\nsource.open();\n}\n+\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/resources/functionaltests/userinfo.feature", "new_path": "model-server/src/test/resources/functionaltests/userinfo.feature", "diff": "@@ -7,3 +7,8 @@ Feature: Basic routes\nThen I should get an NO CONTENT response\nAnd the text of the page should be 0 characters long\n+# Scenario: No email to get when logged\n+# Given the server has been started with in-memory storage\n+# And I PUT on \"/put/\" the value {string}\n+# When I visit \"/getEmail\" with header \"Authorization\" set to \"Bearer mySpectacularToken\"\n+# Then I should get an OK response\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
working on getEmail
426,504
15.08.2020 11:54:39
-7,200
f3cdeb760dc22b36f1ac7d7869cbcd907e4f2a87
functional tests for getEmail
[ { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -45,8 +45,18 @@ configurations {\n}\n}\n+task fatJar(type: Jar) {\n+ manifest {\n+ attributes 'Main-Class': 'org.modelix.model.server.Main'\n+ }\n+ archiveBaseName = 'model-server-fatJar'\n+ archiveVersion = 'latest'\n+ from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }\n+ with jar\n+}\n+\ntask cucumber() {\n- dependsOn assemble, compileTestJava\n+ dependsOn fatJar, compileTestJava\ndoLast {\njavaexec {\nmain = \"io.cucumber.core.cli.Main\"\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "diff": "@@ -17,11 +17,6 @@ package org.modelix.model.server;\nimport com.beust.jcommander.JCommander;\nimport com.beust.jcommander.Parameter;\n-import java.io.File;\n-import java.net.InetAddress;\n-import java.net.InetSocketAddress;\n-import java.nio.charset.StandardCharsets;\n-\nimport com.beust.jcommander.converters.BooleanConverter;\nimport org.apache.commons.io.FileUtils;\nimport org.apache.log4j.Logger;\n@@ -31,6 +26,13 @@ import org.eclipse.jetty.server.handler.ContextHandler;\nimport org.eclipse.jetty.server.handler.HandlerList;\nimport org.eclipse.jetty.servlet.ServletContextHandler;\n+import java.io.File;\n+import java.net.InetAddress;\n+import java.net.InetSocketAddress;\n+import java.nio.charset.StandardCharsets;\n+import java.util.LinkedList;\n+import java.util.List;\n+\nclass CmdLineArgs {\n@Parameter(\n@@ -50,6 +52,12 @@ class CmdLineArgs {\ndescription = \"Use in-memory storage\",\nconverter = BooleanConverter.class)\nBoolean inmemory = false;\n+\n+ @Parameter(\n+ names = \"-set\",\n+ description = \"Set values\",\n+ arity = 2)\n+ List<String> setValues = new LinkedList<>();\n}\npublic class Main {\n@@ -64,6 +72,7 @@ public class Main {\nLOG.info(\"In memory: \" + cmdLineArgs.inmemory);\nLOG.info(\"Path to secret file: \" + cmdLineArgs.secretFile);\nLOG.info(\"Path to JDBC configuration file: \" + cmdLineArgs.jdbcConfFile);\n+ LOG.info(\"Set values: \" + cmdLineArgs.setValues);\ntry {\nString portStr = System.getenv(\"PORT\");\n@@ -80,6 +89,11 @@ public class Main {\n} else {\nstoreClient = new IgniteStoreClient(cmdLineArgs.jdbcConfFile);\n}\n+ int i = 0;\n+ while (i < cmdLineArgs.setValues.size()) {\n+ storeClient.put(cmdLineArgs.setValues.get(i), cmdLineArgs.setValues.get(i + 1));\n+ i += 2;\n+ }\nRestModelServer modelServer = new RestModelServer(storeClient);\nFile sharedSecretFile = cmdLineArgs.secretFile;\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "diff": "@@ -104,7 +104,8 @@ public class RestModelServer {\nString key = req.getPathInfo().substring(1);\nif (key.startsWith(PROTECTED_PREFIX)) {\n- throw new RuntimeException(\"No permission to access \" + key);\n+ resp.setStatus(HttpServletResponse.SC_FORBIDDEN);\n+ return;\n}\nString value = storeClient.get(key);\nif (value == null) {\n@@ -437,18 +438,29 @@ public class RestModelServer {\nif (isLocalhost(req)) return true;\nString header = req.getHeader(\"Authorization\");\n- if (header == null) return false;\n- if (!header.startsWith(\"Bearer \")) return false;\n+ if (header == null) {\n+ return false;\n+ }\n+ if (!header.startsWith(\"Bearer \")) {\n+ return false;\n+ }\nString token = extractToken(req);\n- if (token == null) return false;\n+ if (token == null) {\n+ return false;\n+ }\n// Used by MPS instances running in the same kubernetes cluster\n- if (sharedSecret != null && sharedSecret.length() > 0 && token.equals(sharedSecret))\n+ if (sharedSecret != null && sharedSecret.length() > 0 && token.equals(sharedSecret)) {\nreturn true;\n+ }\nString expiresStr = store.get(PROTECTED_PREFIX + \"_token_expires_\" + token);\n- if (expiresStr == null) return false;\n- if (System.currentTimeMillis() > Long.parseLong(expiresStr)) return false;\n+ if (expiresStr == null) {\n+ return false;\n+ }\n+ if (System.currentTimeMillis() > Long.parseLong(expiresStr)) {\n+ return false;\n+ }\nreturn true;\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "package org.modelix.model.server.functionaltests;\nimport com.google.common.base.Charsets;\n-import io.cucumber.gherkin.internal.com.eclipsesource.json.JsonValue;\nimport io.cucumber.java.After;\nimport io.cucumber.java.Before;\n-import io.cucumber.java.en.And;\nimport io.cucumber.java.en.Given;\nimport io.cucumber.java.en.Then;\nimport io.cucumber.java.en.When;\nimport io.cucumber.messages.internal.com.google.gson.JsonElement;\nimport io.cucumber.messages.internal.com.google.gson.JsonParser;\n-import io.cucumber.messages.internal.com.google.gson.stream.JsonReader;\n-import org.apache.cxf.interceptor.Fault;\nimport javax.ws.rs.client.Client;\nimport javax.ws.rs.client.ClientBuilder;\n@@ -27,10 +23,13 @@ import java.net.http.HttpClient;\nimport java.net.http.HttpRequest;\nimport java.net.http.HttpResponse;\nimport java.util.Arrays;\n+import java.util.Collections;\n+import java.util.HashMap;\nimport java.util.LinkedList;\nimport java.util.List;\n-import java.util.function.Consumer;\n+import java.util.Map;\nimport java.util.regex.Pattern;\n+import java.util.stream.Collectors;\nimport static org.junit.Assert.assertEquals;\nimport static org.junit.Assert.assertTrue;\n@@ -71,8 +70,25 @@ public class Stepdefs {\n@Given(\"the server has been started with in-memory storage\")\npublic void the_server_has_been_started_with_in_memory_storage() {\n+ startServerInMemory(Collections.emptyMap());\n+ }\n+\n+ @Given(\"the server has been started with in-memory storage loaded with {string}\")\n+ public void theServerHasBeenStartedWithInMemoryStorageLoadedWith(String presetValuesStr) {\n+ Map<String, String> presetValues = new HashMap<>();\n+ Arrays.stream(presetValuesStr.split(\",\")).forEach(s -> {\n+ String[] parts = s.split(\"=\");\n+ presetValues.put(parts[0].strip(), parts[1].strip());\n+ });\n+ startServerInMemory(presetValues);\n+ }\n+\n+ private void startServerInMemory(Map<String, String> presetValues) {\ntry {\n- p = Runtime.getRuntime().exec(\"../gradlew run --args='-inmemory'\");BufferedReader stdInput = new BufferedReader(new\n+ String argsToSetValues = presetValues.entrySet().stream().map(e -> \" -set \" + e.getKey()+ \" \" + e.getValue()).collect(Collectors.joining());\n+ String commandLine = \"java -jar build/libs/model-server-fatJar-latest.jar -inmemory\" + argsToSetValues;\n+ p = Runtime.getRuntime().exec(commandLine);\n+ BufferedReader stdInput = new BufferedReader(new\nInputStreamReader(p.getInputStream()));\nBufferedReader stdError = new BufferedReader(new\n@@ -83,14 +99,13 @@ public class Stepdefs {\nString s;\nwhile ((s = stdInput.readLine()) != null) {\nif (VERBOSE_SERVER) {\n- System.out.println(s);\n+ System.out.println(\"SERVER OUT \" + s);\n}\n}\n- // read any errors from the attempted command\nwhile ((s = stdError.readLine()) != null) {\nif (VERBOSE_SERVER) {\n- System.out.println(s);\n+ System.out.println(\"SERVER ERR \" + s);\n}\n}\n} catch (IOException e) {\n@@ -214,6 +229,11 @@ public class Stepdefs {\nassertEquals(204, stringResponse.statusCode());\n}\n+ @Then(\"I should get a FORBIDDEN response\")\n+ public void iShouldGetAFORBIDDENResponse() {\n+ assertEquals(403, stringResponse.statusCode());\n+ }\n+\n@Then(\"the text of the page should be {string}\")\npublic void the_text_of_the_page_should_be(String expectedText) {\nassertEquals(expectedText.strip(), stringResponse.body().strip());\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/resources/functionaltests/storing.feature", "new_path": "model-server/src/test/resources/functionaltests/storing.feature", "diff": "@@ -13,6 +13,11 @@ Feature: Storing routes\nWhen I visit \"/get/abc\"\nThen I should get a NOT FOUND response\n+ Scenario: Retrieving forbidden key\n+ Given the server has been started with in-memory storage\n+ When I visit \"/get/$$$_abc\"\n+ Then I should get a FORBIDDEN response\n+\nScenario: Retrieving multiple keys, all existing\nGiven the server has been started with in-memory storage\nWhen I PUT on \"/put/aaa\" the value \"value1\"\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/resources/functionaltests/userinfo.feature", "new_path": "model-server/src/test/resources/functionaltests/userinfo.feature", "diff": "@@ -7,8 +7,9 @@ Feature: Basic routes\nThen I should get an NO CONTENT response\nAnd the text of the page should be 0 characters long\n-# Scenario: No email to get when logged\n-# Given the server has been started with in-memory storage\n-# And I PUT on \"/put/\" the value {string}\n-# When I visit \"/getEmail\" with header \"Authorization\" set to \"Bearer mySpectacularToken\"\n-# Then I should get an OK response\n\\ No newline at end of file\n+ Scenario: No email to get when logged\n+ # the token should expire in year 2286\n+ Given the server has been started with in-memory storage loaded with \"$$$_token_expires_mySpectacularToken=9999999999999,[email protected]\"\n+ When I visit \"/getEmail\" with header \"Authorization\" set to \"Bearer mySpectacularToken\"\n+ Then I should get an OK response\n+ And the text of the page should be \"[email protected]\"\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
functional tests for getEmail
426,504
15.08.2020 12:04:00
-7,200
9e41135ff6d7b46a4f7d1f90f8d8c552cbe32846
adding functional tests to generate and use token
[ { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "@@ -154,6 +154,9 @@ public class Stepdefs {\n@When(\"I visit {string} with header {string} set to {string}\")\npublic void iVisitWithHeaderSetTo(String path, String header, String value) {\n+ if (value.contains(\"#TEXT_OF_LAST_PAGE#\")) {\n+ value = value.replaceAll(\"#TEXT_OF_LAST_PAGE#\", stringResponse.body().strip());\n+ }\ntry {\nvar client = HttpClient.newHttpClient();\nvar request = HttpRequest.newBuilder(\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/resources/functionaltests/userinfo.feature", "new_path": "model-server/src/test/resources/functionaltests/userinfo.feature", "diff": "@@ -13,3 +13,10 @@ Feature: Basic routes\nWhen I visit \"/getEmail\" with header \"Authorization\" set to \"Bearer mySpectacularToken\"\nThen I should get an OK response\nAnd the text of the page should be \"[email protected]\"\n+\n+ Scenario: Default email after token is generated\n+ Given the server has been started with in-memory storage\n+ And I visit \"/generateToken\"\n+ When I visit \"/getEmail\" with header \"Authorization\" set to \"Bearer #TEXT_OF_LAST_PAGE#\"\n+ Then I should get an OK response\n+ And the text of the page should be \"localhost\"\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
adding functional tests to generate and use token
426,504
15.08.2020 12:13:20
-7,200
83f904296ff696b8ab5445c89a2745ea915d8576
adding scenario Get correct email after token is generated with email
[ { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "@@ -152,18 +152,35 @@ public class Stepdefs {\n}\n}\n+ @When(\"I visit {string} with headers {string}\")\n+ public void iVisitWithHeaders(String path, String headersStr) {\n+ Map<String, String> headers = new HashMap<>();\n+ Arrays.stream(headersStr.split(\",\")).forEach(s -> {\n+ String[] parts = s.split(\"=\");\n+ headers.put(parts[0].strip(), parts[1].strip());\n+ });\n+ visitPath(path, headers);\n+ }\n+\n@When(\"I visit {string} with header {string} set to {string}\")\npublic void iVisitWithHeaderSetTo(String path, String header, String value) {\n- if (value.contains(\"#TEXT_OF_LAST_PAGE#\")) {\n- value = value.replaceAll(\"#TEXT_OF_LAST_PAGE#\", stringResponse.body().strip());\n+ visitPath(path, Collections.singletonMap(header, value));\n}\n+\n+ private void visitPath(String path, Map<String, String> headers) {\ntry {\nvar client = HttpClient.newHttpClient();\n- var request = HttpRequest.newBuilder(\n+ var builder = HttpRequest.newBuilder(\nURI.create(\"http://localhost:28101\" + path))\n- .header(\"accept\", \"application/json\")\n- .header(header, value)\n- .build();\n+ .header(\"accept\", \"application/json\");\n+ for (Map.Entry<String, String> e : headers.entrySet()) {\n+ String value = e.getValue();\n+ if (value.contains(\"#TEXT_OF_LAST_PAGE#\")) {\n+ value = value.replaceAll(\"#TEXT_OF_LAST_PAGE#\", stringResponse.body().strip());\n+ }\n+ builder = builder.header(e.getKey(), value);\n+ }\n+ var request = builder.build();\nstringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n} catch (ConnectException e) {\n@@ -177,7 +194,7 @@ public class Stepdefs {\n} catch (InterruptedException e2) {\n}\n- iVisitWithHeaderSetTo(path, header, value);\n+ visitPath(path, headers);\n} else {\nthrow new RuntimeException(e);\n}\n@@ -290,5 +307,4 @@ public class Stepdefs {\nsource.register(inboundSseEvent -> events.add(inboundSseEvent));\nsource.open();\n}\n-\n}\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/test/resources/functionaltests/userinfo.feature", "new_path": "model-server/src/test/resources/functionaltests/userinfo.feature", "diff": "@@ -20,3 +20,10 @@ Feature: Basic routes\nWhen I visit \"/getEmail\" with header \"Authorization\" set to \"Bearer #TEXT_OF_LAST_PAGE#\"\nThen I should get an OK response\nAnd the text of the page should be \"localhost\"\n+\n+ Scenario: Get correct email after token is generated with email\n+ Given the server has been started with in-memory storage\n+ And I visit \"/generateToken\" with headers \"[email protected]\"\n+ When I visit \"/getEmail\" with headers \"Authorization=Bearer #TEXT_OF_LAST_PAGE#\"\n+ Then I should get an OK response\n+ And the text of the page should be \"[email protected]\"\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
adding scenario Get correct email after token is generated with email
426,504
15.08.2020 12:32:03
-7,200
81a9cb366fb45609447bb3160dbab3e1e08b99b6
add scenarios for counter
[ { "change_type": "MODIFY", "old_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "new_path": "model-server/src/test/java/org/modelix/model/server/functionaltests/Stepdefs.java", "diff": "@@ -32,15 +32,16 @@ import java.util.regex.Pattern;\nimport java.util.stream.Collectors;\nimport static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertNotEquals;\nimport static org.junit.Assert.assertTrue;\npublic class Stepdefs {\nprivate Process p;\n- private HttpResponse<String> stringResponse;\nprivate int nRetries;\nprivate SseEventSource source;\nprivate List<InboundSseEvent> events = new LinkedList<InboundSseEvent>();\n+ private List<HttpResponse<String>> allStringResponses = new LinkedList<>();\nprivate static final boolean VERBOSE_SERVER = false;\nprivate static final boolean VERBOSE_CONNECTION = false;\n@@ -60,12 +61,12 @@ public class Stepdefs {\n} catch (InterruptedException e) {\n}\n}\n- stringResponse = null;\nif (source != null) {\nsource.close();\n}\nsource = null;\nevents.clear();\n+ allStringResponses.clear();\n}\n@Given(\"the server has been started with in-memory storage\")\n@@ -124,14 +125,19 @@ public class Stepdefs {\n@When(\"I visit {string}\")\npublic void i_visit(String path) {\n+ httpRequest(\"GET\", path);\n+ }\n+\n+ private void httpRequest(String method, String path) {\ntry {\nvar client = HttpClient.newHttpClient();\nvar request = HttpRequest.newBuilder(\nURI.create(\"http://localhost:28101\" + path))\n+ .method(method, HttpRequest.BodyPublishers.noBody())\n.header(\"accept\", \"application/json\")\n.build();\n- stringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n+ allStringResponses.add(client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8)));\n} catch (ConnectException e) {\nif (nRetries > 0) {\nif (VERBOSE_CONNECTION) {\n@@ -143,7 +149,7 @@ public class Stepdefs {\n} catch (InterruptedException e2) {\n}\n- i_visit(path);\n+ httpRequest(method, path);\n} else {\nthrow new RuntimeException(e);\n}\n@@ -152,6 +158,11 @@ public class Stepdefs {\n}\n}\n+ @When(\"I POST {string}\")\n+ public void iPOST(String path) {\n+ httpRequest(\"POST\", path);\n+ }\n+\n@When(\"I visit {string} with headers {string}\")\npublic void iVisitWithHeaders(String path, String headersStr) {\nMap<String, String> headers = new HashMap<>();\n@@ -167,6 +178,14 @@ public class Stepdefs {\nvisitPath(path, Collections.singletonMap(header, value));\n}\n+ private String lastStringResponse() {\n+ return allStringResponses.get(allStringResponses.size() - 1).body().strip();\n+ }\n+\n+ private int lastStatusCode() {\n+ return allStringResponses.get(allStringResponses.size() - 1).statusCode();\n+ }\n+\nprivate void visitPath(String path, Map<String, String> headers) {\ntry {\nvar client = HttpClient.newHttpClient();\n@@ -176,13 +195,13 @@ public class Stepdefs {\nfor (Map.Entry<String, String> e : headers.entrySet()) {\nString value = e.getValue();\nif (value.contains(\"#TEXT_OF_LAST_PAGE#\")) {\n- value = value.replaceAll(\"#TEXT_OF_LAST_PAGE#\", stringResponse.body().strip());\n+ value = value.replaceAll(\"#TEXT_OF_LAST_PAGE#\", lastStringResponse());\n}\nbuilder = builder.header(e.getKey(), value);\n}\nvar request = builder.build();\n- stringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n+ allStringResponses.add(client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8)));\n} catch (ConnectException e) {\nif (nRetries > 0) {\nif (VERBOSE_CONNECTION) {\n@@ -213,7 +232,7 @@ public class Stepdefs {\n.header(\"accept\", \"application/json\")\n.build();\n- stringResponse = client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8));\n+ allStringResponses.add(client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8)));\n} catch (ConnectException e) {\nif (nRetries > 0) {\nif (VERBOSE_CONNECTION) {\n@@ -236,43 +255,43 @@ public class Stepdefs {\n@Then(\"I should get an OK response\")\npublic void i_should_get_an_ok_response() {\n- assertEquals(200, stringResponse.statusCode());\n+ assertEquals(200, lastStatusCode());\n}\n@Then(\"I should get a NOT FOUND response\")\npublic void i_should_get_a_not_found_response() {\n- assertEquals(404, stringResponse.statusCode());\n+ assertEquals(404, lastStatusCode());\n}\n@Then(\"I should get an NO CONTENT response\")\npublic void iShouldGetAnNOCONTENTResponse() {\n- assertEquals(204, stringResponse.statusCode());\n+ assertEquals(204, lastStatusCode());\n}\n@Then(\"I should get a FORBIDDEN response\")\npublic void iShouldGetAFORBIDDENResponse() {\n- assertEquals(403, stringResponse.statusCode());\n+ assertEquals(403, lastStatusCode());\n}\n@Then(\"the text of the page should be {string}\")\npublic void the_text_of_the_page_should_be(String expectedText) {\n- assertEquals(expectedText.strip(), stringResponse.body().strip());\n+ assertEquals(expectedText.strip(), lastStringResponse());\n}\n@Then(\"the text of the page should be {int} characters long\")\npublic void theTextOfThePageShouldBeCharactersLong(int nLength) {\n- assertEquals(nLength, stringResponse.body().length());\n+ assertEquals(nLength, lastStringResponse().length());\n}\n@Then(\"the text of the page contains only hexadecimal digits\")\npublic void theTextOfThePageContainsOnlyHexadecimalDigits() {\n- Pattern.matches(\"[a-f0-9]+\", stringResponse.body());\n+ Pattern.matches(\"[a-f0-9]+\", lastStringResponse());\n}\n@Then(\"the text of the page should be this JSON {string}\")\npublic void theTextOfThePageShouldBeThisJSON(String expectedJsonStr) {\nJsonElement expectedJson = JsonParser.parseString(expectedJsonStr);\n- assertEquals(expectedJson, JsonParser.parseString(stringResponse.body()));\n+ assertEquals(expectedJson, JsonParser.parseString(lastStringResponse()));\n}\n@Then(\"I should get an event {string}\")\n@@ -307,4 +326,18 @@ public class Stepdefs {\nsource.register(inboundSseEvent -> events.add(inboundSseEvent));\nsource.open();\n}\n+\n+ @Then(\"the text of the page should be the same as before\")\n+ public void theTextOfThePageShouldBeTheSameAsBefore() {\n+ String last = allStringResponses.get(allStringResponses.size() - 1).body().strip();\n+ String secondToLast = allStringResponses.get(allStringResponses.size() - 2).body().strip();\n+ assertEquals(secondToLast, last);\n+ }\n+\n+ @Then(\"the text of the page should be different than before\")\n+ public void theTextOfThePageShouldBeDifferentThanBefore() {\n+ String last = allStringResponses.get(allStringResponses.size() - 1).body().strip();\n+ String secondToLast = allStringResponses.get(allStringResponses.size() - 2).body().strip();\n+ assertNotEquals(secondToLast, last);\n+ }\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/test/resources/functionaltests/counter.feature", "diff": "+Feature: Storing routes\n+ We verify the core storing routes work\n+\n+ Scenario: We should get the same ID for the same key\n+ Given the server has been started with in-memory storage\n+ When I POST \"/counter/a\"\n+ And I should get an OK response\n+ And I POST \"/counter/a\"\n+ Then the text of the page should be the same as before\n+\n+ Scenario: We should get different IDs for different keys\n+ Given the server has been started with in-memory storage\n+ When I POST \"/counter/a\"\n+ And I should get an OK response\n+ And I POST \"/counter/b\"\n+ Then the text of the page should be different than before\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add scenarios for counter
426,504
15.08.2020 14:43:53
-7,200
187a99997db16b8a605aabe27d3e40a725446fad
adding unit test for model-server
[ { "change_type": "MODIFY", "old_path": ".github/workflows/modelclient.yml", "new_path": ".github/workflows/modelclient.yml", "diff": "@@ -54,16 +54,3 @@ jobs:\njava-version: 11\n- name: Run tests for model client\nrun: cd model-client && ../gradlew ktlintCheck\n-\n- functionalTests:\n-\n- runs-on: ubuntu-latest\n-\n- steps:\n- - uses: actions/checkout@v1\n- - name: Set up JDK 11\n- uses: actions/setup-java@v1\n- with:\n- java-version: 11\n- - name: Run tests for model client\n- run: cd model-server && ../gradlew cucumber\n\\ No newline at end of file\n" }, { "change_type": "ADD", "old_path": null, "new_path": ".github/workflows/modelserver.yml", "diff": "+name: ModelClient_BuildAndTest\n+\n+on: [push]\n+\n+jobs:\n+ build:\n+\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - uses: actions/checkout@v1\n+ - name: Set up JDK 11\n+ uses: actions/setup-java@v1\n+ with:\n+ java-version: 11\n+ - name: Run tests for model client\n+ run: cd model-server && ../gradlew assemble\n+\n+ unitTests:\n+\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - uses: actions/checkout@v1\n+ - name: Set up JDK 11\n+ uses: actions/setup-java@v1\n+ with:\n+ java-version: 11\n+ - name: Run tests for model client\n+ run: cd model-server && ../gradlew yest\n+\n+ lint:\n+\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - uses: actions/checkout@v1\n+ - name: Set up JDK 11\n+ uses: actions/setup-java@v1\n+ with:\n+ java-version: 11\n+ - name: Run tests for model client\n+ run: cd model-server && ../gradlew spotlessCheck\n+\n+ functionalTests:\n+\n+ runs-on: ubuntu-latest\n+\n+ steps:\n+ - uses: actions/checkout@v1\n+ - name: Set up JDK 11\n+ uses: actions/setup-java@v1\n+ with:\n+ java-version: 11\n+ - name: Run tests for model client\n+ run: cd model-server && ../gradlew cucumber\n" }, { "change_type": "MODIFY", "old_path": "model-server/build.gradle", "new_path": "model-server/build.gradle", "diff": "@@ -4,6 +4,7 @@ plugins {\nid \"com.diffplug.gradle.spotless\"\nid 'maven-publish'\nid \"com.jfrog.bintray\"\n+ id 'com.adarshr.test-logger' version '2.1.0'\n}\ngroup = 'org.modelix'\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "diff": "@@ -393,7 +393,6 @@ public class RestModelServer {\nwhile (!pending.isEmpty()) {\nList<String> keys = new ArrayList<>(pending);\n- System.out.println(\"query \" + keys.size() + \" keys\");\npending.clear();\nList<String> values = storeClient.getAll(keys);\nfor (int i = 0; i < keys.size(); i++) {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-server/src/test/java/org/modelix/model/server/RestModelServerTest.java", "diff": "+package org.modelix.model.server;\n+\n+import org.json.JSONArray;\n+import org.junit.Test;\n+\n+import java.util.Arrays;\n+import java.util.HashSet;\n+\n+import static org.junit.Assert.assertEquals;\n+\n+public class RestModelServerTest {\n+\n+ @Test\n+ public void testCollectUnexistingKey() {\n+ InMemoryStoreClient storeClient = new InMemoryStoreClient();\n+ RestModelServer rms = new RestModelServer(storeClient);\n+ JSONArray result = rms.collect(\"unexistingKey\");\n+ assertEquals(1, result.length());\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\")), result.getJSONObject(0).keySet());\n+ assertEquals(\"unexistingKey\", result.getJSONObject(0).get(\"key\"));\n+ }\n+\n+ @Test\n+ public void testCollectExistingKeyNotHash() {\n+ InMemoryStoreClient storeClient = new InMemoryStoreClient();\n+ storeClient.put(\"existingKey\", \"foo\");\n+ RestModelServer rms = new RestModelServer(storeClient);\n+ JSONArray result = rms.collect(\"existingKey\");\n+ assertEquals(1, result.length());\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), result.getJSONObject(0).keySet());\n+ assertEquals(\"existingKey\", result.getJSONObject(0).get(\"key\"));\n+ assertEquals(\"foo\", result.getJSONObject(0).get(\"value\"));\n+ }\n+\n+ @Test\n+ public void testCollectExistingKeyHash() {\n+ InMemoryStoreClient storeClient = new InMemoryStoreClient();\n+ storeClient.put(\"existingKey\", \"hash-0123456789-0123456789-0123456789-00001\");\n+ storeClient.put(\"hash-0123456789-0123456789-0123456789-00001\", \"bar\");\n+ RestModelServer rms = new RestModelServer(storeClient);\n+ JSONArray result = rms.collect(\"existingKey\");\n+ assertEquals(2, result.length());\n+\n+ var obj = result.getJSONObject(0);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"existingKey\", obj.get(\"key\"));\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00001\", obj.get(\"value\"));\n+\n+ obj = result.getJSONObject(1);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00001\", obj.get(\"key\"));\n+ assertEquals(\"bar\", obj.get(\"value\"));\n+ }\n+\n+ @Test\n+ public void testCollectExistingKeyHashChained() {\n+ InMemoryStoreClient storeClient = new InMemoryStoreClient();\n+ storeClient.put(\"root\", \"hash-0123456789-0123456789-0123456789-00001\");\n+ storeClient.put(\"hash-0123456789-0123456789-0123456789-00001\", \"hash-0123456789-0123456789-0123456789-00002\");\n+ storeClient.put(\"hash-0123456789-0123456789-0123456789-00002\", \"hash-0123456789-0123456789-0123456789-00003\");\n+ storeClient.put(\"hash-0123456789-0123456789-0123456789-00003\", \"hash-0123456789-0123456789-0123456789-00004\");\n+ storeClient.put(\"hash-0123456789-0123456789-0123456789-00004\", \"end\");\n+ RestModelServer rms = new RestModelServer(storeClient);\n+ JSONArray result = rms.collect(\"root\");\n+ assertEquals(5, result.length());\n+\n+ var obj = result.getJSONObject(0);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"root\", obj.get(\"key\"));\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00001\", obj.get(\"value\"));\n+\n+ obj = result.getJSONObject(1);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00001\", obj.get(\"key\"));\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00002\", obj.get(\"value\"));\n+\n+ obj = result.getJSONObject(2);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00002\", obj.get(\"key\"));\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00003\", obj.get(\"value\"));\n+\n+ obj = result.getJSONObject(3);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00003\", obj.get(\"key\"));\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00004\", obj.get(\"value\"));\n+\n+ obj = result.getJSONObject(4);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00004\", obj.get(\"key\"));\n+ assertEquals(\"end\", obj.get(\"value\"));\n+ }\n+\n+ @Test\n+ public void testCollectExistingKeyHashChainedWithRepetitions() {\n+ InMemoryStoreClient storeClient = new InMemoryStoreClient();\n+ storeClient.put(\"root\", \"hash-0123456789-0123456789-0123456789-00001\");\n+ storeClient.put(\"hash-0123456789-0123456789-0123456789-00001\", \"hash-0123456789-0123456789-0123456789-00002\");\n+ storeClient.put(\"hash-0123456789-0123456789-0123456789-00002\", \"hash-0123456789-0123456789-0123456789-00003\");\n+ storeClient.put(\"hash-0123456789-0123456789-0123456789-00003\", \"hash-0123456789-0123456789-0123456789-00001\");\n+ RestModelServer rms = new RestModelServer(storeClient);\n+ JSONArray result = rms.collect(\"root\");\n+ assertEquals(4, result.length());\n+\n+ var obj = result.getJSONObject(0);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"root\", obj.get(\"key\"));\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00001\", obj.get(\"value\"));\n+\n+ obj = result.getJSONObject(1);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00001\", obj.get(\"key\"));\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00002\", obj.get(\"value\"));\n+\n+ obj = result.getJSONObject(2);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00002\", obj.get(\"key\"));\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00003\", obj.get(\"value\"));\n+\n+ obj = result.getJSONObject(3);\n+ assertEquals(new HashSet<>(Arrays.asList(\"key\", \"value\")), obj.keySet());\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00003\", obj.get(\"key\"));\n+ assertEquals(\"hash-0123456789-0123456789-0123456789-00001\", obj.get(\"value\"));\n+ }\n+}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
adding unit test for model-server
426,504
15.08.2020 14:51:08
-7,200
3c538eddce876e2fa46fb52e4bb7b905fefc4313
add scenario 'Get recursively'
[ { "change_type": "MODIFY", "old_path": "model-server/src/test/resources/functionaltests/storing.feature", "new_path": "model-server/src/test/resources/functionaltests/storing.feature", "diff": "@@ -60,3 +60,11 @@ Feature: Storing routes\nAnd I PUT on \"/getAll\" the value \"['aaa', 'bbb', 'ccc']\"\nThen I should get an OK response\nAnd the text of the page should be this JSON \"[{'value': 'value1', 'key': 'aaa'}, {'key': 'bbb', 'value': 'value2'}, {'value': 'value3', 'key': 'ccc'}]\"\n+\n+ Scenario: Get recursively\n+ Given the server has been started with in-memory storage\n+ And I PUT on \"/put/existingKey\" the value \"hash-0123456789-0123456789-0123456789-00001\"\n+ And I PUT on \"/put/hash-0123456789-0123456789-0123456789-00001\" the value \"bar\"\n+ When I visit \"/getRecursively/existingKey\"\n+ Then I should get an OK response\n+ And the text of the page should be this JSON \"[{'value': 'hash-0123456789-0123456789-0123456789-00001', 'key': 'existingKey'}, {'key': 'hash-0123456789-0123456789-0123456789-00001', 'value': 'bar'}]\"\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
add scenario 'Get recursively'
426,504
15.08.2020 14:58:42
-7,200
6d3090e4ea1159e689903ba60832b40909bac7a6
revise labels in GitHub actions
[ { "change_type": "MODIFY", "old_path": ".github/workflows/modelclient.yml", "new_path": ".github/workflows/modelclient.yml", "diff": "@@ -13,7 +13,7 @@ jobs:\nuses: actions/setup-java@v1\nwith:\njava-version: 11\n- - name: Run tests for model client\n+ - name: Assemble\nrun: cd model-client && ../gradlew compileKotlinJs compileKotlinJvm\njvmTest:\n@@ -26,7 +26,7 @@ jobs:\nuses: actions/setup-java@v1\nwith:\njava-version: 11\n- - name: Run tests for model client\n+ - name: Run JVM unit tests\nrun: cd model-client && ../gradlew jvmTest\njsTest:\n@@ -39,7 +39,7 @@ jobs:\nuses: actions/setup-java@v1\nwith:\njava-version: 11\n- - name: Run tests for model client\n+ - name: Run JS unit tests\nrun: cd model-client && ../gradlew jsTest\nlint:\n@@ -52,5 +52,5 @@ jobs:\nuses: actions/setup-java@v1\nwith:\njava-version: 11\n- - name: Run tests for model client\n+ - name: Run linter\nrun: cd model-client && ../gradlew ktlintCheck\n" }, { "change_type": "MODIFY", "old_path": ".github/workflows/modelserver.yml", "new_path": ".github/workflows/modelserver.yml", "diff": "@@ -13,7 +13,7 @@ jobs:\nuses: actions/setup-java@v1\nwith:\njava-version: 11\n- - name: Run tests for model client\n+ - name: Assemble\nrun: cd model-server && ../gradlew assemble\nunitTests:\n@@ -26,8 +26,8 @@ jobs:\nuses: actions/setup-java@v1\nwith:\njava-version: 11\n- - name: Run tests for model client\n- run: cd model-server && ../gradlew yest\n+ - name: Run unit tests\n+ run: cd model-server && ../gradlew test\nlint:\n@@ -39,7 +39,7 @@ jobs:\nuses: actions/setup-java@v1\nwith:\njava-version: 11\n- - name: Run tests for model client\n+ - name: Run linter\nrun: cd model-server && ../gradlew spotlessCheck\nfunctionalTests:\n@@ -52,5 +52,5 @@ jobs:\nuses: actions/setup-java@v1\nwith:\njava-version: 11\n- - name: Run tests for model client\n+ - name: Run functional tests\nrun: cd model-server && ../gradlew cucumber\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
revise labels in GitHub actions
426,504
15.08.2020 17:12:04
-7,200
93d81ff676793f0c63f8bc716527a5fa09212544
make test_t1 runnable
[ { "change_type": "MODIFY", "old_path": "model-client/src/jvmTest/kotlin/org/modelix/model/ModelClient_Test.kt", "new_path": "model-client/src/jvmTest/kotlin/org/modelix/model/ModelClient_Test.kt", "diff": "package org.modelix.model\n+import org.junit.After\nimport org.junit.Assert\n+import org.junit.Before\n+import org.junit.Test\nimport org.modelix.model.client.RestWebModelClient\nimport java.util.*\nclass ModelClient_Test {\n- // Disabled because it requires a running model server\n- // @Test\n+\n+ private var modelServer = ModelServerManager()\n+\n+ @Before\n+ fun prepare() {\n+ modelServer.startServerInMemory(emptyMap())\n+ modelServer.waitItIsUp()\n+ }\n+\n+ @After\n+ fun cleaning() {\n+ modelServer.kill()\n+ }\n+\n+ // This test requires a running model server\n+ @Test\nfun test_t1() {\nval rand = Random(67845)\nval url = \"http://localhost:28101/\"\n- val clients = Arrays.asList(RestWebModelClient(url), RestWebModelClient(url), RestWebModelClient(url))\n+ val clients = listOf(RestWebModelClient(url), RestWebModelClient(url), RestWebModelClient(url))\nval listeners: MutableList<Listener> = ArrayList()\nval expected: MutableMap<String, String> = HashMap()\nfor (client in clients) {\nfor (i in 0..9) {\n+ println(\"Phase A: client $client i=$i of 10\")\nThread.sleep(1000)\nval key = \"test_$i\"\nval l = Listener(key, client)\n@@ -38,9 +56,11 @@ class ModelClient_Test {\n}\n}\nfor (i in 0..99) {\n- Thread.sleep(400)\n+ println(\"Phase B: i=$i of 100\")\n+ //Thread.sleep(400)\n+ Thread.sleep(200)\nval key = \"test_\" + rand.nextInt(10)\n- val value = java.lang.Long.toString(rand.nextLong())\n+ val value = rand.nextLong().toString()\nexpected[key] = value\nprintln(\"put $key = $value\")\nclients[rand.nextInt(clients.size)].put(key, value)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/jvmTest/kotlin/org/modelix/model/ModelServerManager.kt", "diff": "+package org.modelix.model\n+\n+import com.google.common.base.Charsets\n+import java.io.BufferedReader\n+import java.io.IOException\n+import java.io.InputStreamReader\n+import java.net.ConnectException\n+import java.net.URI\n+import java.net.http.HttpClient\n+import java.net.http.HttpRequest\n+import java.net.http.HttpResponse\n+import java.util.stream.Collectors\n+\n+class ModelServerManager {\n+ private val VERBOSE_SERVER = false\n+ private val VERBOSE_CONNECTION = false\n+ private var p: Process? = null\n+ fun kill() {\n+ if (p != null) {\n+ p!!.destroy()\n+ p = null\n+ try {\n+ Thread.sleep(1000)\n+ } catch (e: InterruptedException) {\n+ }\n+ }\n+ }\n+\n+ fun waitItIsUp() {\n+ httpRequest(\"GET\", \"/\")\n+ }\n+\n+ private fun httpRequest(method: String, path: String, nRetries: Int = 10) {\n+ try {\n+ val client = HttpClient.newHttpClient()\n+ val request = HttpRequest.newBuilder(URI.create(\"http://localhost:28101$path\"))\n+ .method(method, HttpRequest.BodyPublishers.noBody())\n+ .header(\"accept\", \"application/json\")\n+ .build()\n+ client.send(request, HttpResponse.BodyHandlers.ofString(Charsets.UTF_8))\n+ } catch (e: ConnectException) {\n+ if (nRetries > 0) {\n+ if (VERBOSE_CONNECTION) {\n+ println(\n+ \" (connection failed, retrying in a bit. nRetries=$nRetries)\")\n+ }\n+ try {\n+ Thread.sleep(1000)\n+ } catch (e2: InterruptedException) {\n+ }\n+ httpRequest(method, path, nRetries - 1)\n+ } else {\n+ throw RuntimeException(e)\n+ }\n+ } catch (e: IOException) {\n+ e.printStackTrace()\n+ } catch (e: InterruptedException) {\n+ e.printStackTrace()\n+ }\n+ }\n+\n+ fun startServerInMemory(presetValues: Map<String, String>) {\n+ try {\n+ val argsToSetValues = presetValues.entries.stream()\n+ .map { e: Map.Entry<String, String> -> \" -set \" + e.key + \" \" + e.value }\n+ .collect(Collectors.joining())\n+ val commandLine = (\"java -jar ../model-server/build/libs/model-server-fatJar-latest.jar -inmemory\"\n+ + argsToSetValues)\n+ p = Runtime.getRuntime().exec(commandLine)\n+ val stdInput = BufferedReader(InputStreamReader(p!!.inputStream))\n+ val stdError = BufferedReader(InputStreamReader(p!!.errorStream))\n+ Thread(\n+ Runnable {\n+ try {\n+ var s: String?\n+ while (stdInput.readLine().also { s = it } != null) {\n+ if (VERBOSE_SERVER) {\n+ println(\"SERVER OUT $s\")\n+ }\n+ }\n+ while (stdError.readLine().also { s = it } != null) {\n+ if (VERBOSE_SERVER) {\n+ println(\"SERVER ERR $s\")\n+ }\n+ }\n+ } catch (e: IOException) {\n+ // this may happen when closing\n+ }\n+ })\n+ .start()\n+ try {\n+ Thread.sleep(1000)\n+ } catch (e: InterruptedException) {\n+ }\n+ } catch (e: IOException) {\n+ throw RuntimeException(e)\n+ }\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
make test_t1 runnable
426,504
15.08.2020 17:31:46
-7,200
8b1ff0550e21b812c46b5094268e319e8af75bce
working on long running test
[ { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/client/RestWebModelClient.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/client/RestWebModelClient.kt", "diff": "@@ -211,9 +211,10 @@ class RestWebModelClient @JvmOverloads constructor(var baseUrl: String? = null)\nLOG.debug(\"PUT $key = $value\")\n}\n}\n- val response = client.target(baseUrl + \"put/\" + URLEncoder.encode(key, StandardCharsets.UTF_8)).request(MediaType.TEXT_PLAIN).put(Entity.text(value))\n+ val url = baseUrl + \"put/\" + URLEncoder.encode(key, StandardCharsets.UTF_8)\n+ val response = client.target(url).request(MediaType.TEXT_PLAIN).put(Entity.text(value))\nif (response.statusInfo.family != Response.Status.Family.SUCCESSFUL) {\n- throw RuntimeException(\"Failed to store entry (\" + response.statusInfo + \") \" + key + \" = \" + value)\n+ throw RuntimeException(\"Failed to store entry (${response.statusInfo} ${response.status}) $key = $value. URL: $url\")\n}\n}\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmTest/kotlin/org/modelix/model/ModelServerManager.kt", "new_path": "model-client/src/jvmTest/kotlin/org/modelix/model/ModelServerManager.kt", "diff": "@@ -12,7 +12,7 @@ import java.net.http.HttpResponse\nimport java.util.stream.Collectors\nclass ModelServerManager {\n- private val VERBOSE_SERVER = false\n+ private val VERBOSE_SERVER = true\nprivate val VERBOSE_CONNECTION = false\nprivate var p: Process? = null\nfun kill() {\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
working on long running test
426,504
15.08.2020 18:13:04
-7,200
d614638884a3307175e0120882f44c1814cb6aa0
adding logs to debug failing test
[ { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/client/RestWebModelClient.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/client/RestWebModelClient.kt", "diff": "@@ -18,6 +18,8 @@ package org.modelix.model.client\nimport org.apache.commons.io.FileUtils\nimport org.apache.log4j.Level\nimport org.apache.log4j.LogManager\n+import org.glassfish.jersey.client.ClientConfig\n+import org.glassfish.jersey.client.ClientProperties\nimport org.json.JSONArray\nimport org.json.JSONObject\nimport org.modelix.model.IKeyListener\n@@ -102,6 +104,7 @@ class RestWebModelClient @JvmOverloads constructor(var baseUrl: String? = null)\n}\nprivate set\nprivate val client: Client\n+ private val sseClient: Client\nprivate val listeners: MutableList<SseListener> = ArrayList()\noverride val asyncStore: IKeyValueStore = GarbageFilteringStore(AsyncStore(this))\nprivate val cache = ObjectStoreCache(KeyValueStoreCache(asyncStore))\n@@ -212,10 +215,16 @@ class RestWebModelClient @JvmOverloads constructor(var baseUrl: String? = null)\n}\n}\nval url = baseUrl + \"put/\" + URLEncoder.encode(key, StandardCharsets.UTF_8)\n+ println(\"put with url $url\")\n+ try {\nval response = client.target(url).request(MediaType.TEXT_PLAIN).put(Entity.text(value))\n+ println(\"put with url $url got response $response\")\nif (response.statusInfo.family != Response.Status.Family.SUCCESSFUL) {\nthrow RuntimeException(\"Failed to store entry (${response.statusInfo} ${response.status}) $key = $value. URL: $url\")\n}\n+ } catch (e: Exception) {\n+ throw RuntimeException(\"Failed executing a put to $url\", e)\n+ }\n}\noverride fun putAll(entries: Map<String, String?>) {\n@@ -321,7 +330,7 @@ class RestWebModelClient @JvmOverloads constructor(var baseUrl: String? = null)\nif (LOG.isTraceEnabled) {\nLOG.trace(\"Connecting to $url\")\n}\n- val target = client.target(url)\n+ val target = sseClient.target(url)\nsse[i] = Sse(SseEventSource.target(target).reconnectingEvery(1, TimeUnit.SECONDS).build())\nsse[i]!!.sse.register(\n{ event ->\n@@ -364,12 +373,15 @@ class RestWebModelClient @JvmOverloads constructor(var baseUrl: String? = null)\nif (!(baseUrl!!.endsWith(\"/\"))) {\nbaseUrl += \"/\"\n}\n- client = ClientBuilder.newBuilder().register(object : ClientRequestFilter {\n- @Throws(IOException::class)\n- override fun filter(ctx: ClientRequestContext) {\n- ctx.headers.add(HttpHeaders.AUTHORIZATION, \"Bearer $authToken\")\n- }\n- }).build()\n+ // a read timeout could be an issue for the usage of SSE but a connect timeout\n+ // is useful to recognize when the server is down\n+ client = ClientBuilder.newBuilder()\n+ .connectTimeout(1000, TimeUnit.MILLISECONDS)\n+ .readTimeout(1000, TimeUnit.MILLISECONDS)\n+ .register(ClientRequestFilter { ctx -> ctx.headers.add(HttpHeaders.AUTHORIZATION, \"Bearer $authToken\") }).build()\n+ sseClient = ClientBuilder.newBuilder()\n+ .connectTimeout(1000, TimeUnit.MILLISECONDS)\n+ .register(ClientRequestFilter { ctx -> ctx.headers.add(HttpHeaders.AUTHORIZATION, \"Bearer $authToken\") }).build()\nidGenerator = IdGenerator(clientId)\nwatchDogTask = fixDelay(\n1000,\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmTest/kotlin/org/modelix/model/ModelClient_Test.kt", "new_path": "model-client/src/jvmTest/kotlin/org/modelix/model/ModelClient_Test.kt", "diff": "package org.modelix.model\n+import org.glassfish.jersey.client.ClientConfig\n+import org.glassfish.jersey.client.ClientProperties\nimport org.junit.After\nimport org.junit.Assert\nimport org.junit.Before\nimport org.junit.Test\nimport org.modelix.model.client.RestWebModelClient\n-import java.lang.IllegalStateException\nimport java.util.*\n+\nclass ModelClient_Test {\nprivate var modelServer = ModelServerManager()\n@@ -68,6 +70,7 @@ class ModelClient_Test {\nexpected[key] = value\nprintln(\" put $key = $value\")\nval client = rand.nextInt(clients.size)\n+ println(\" client is $client\")\nclients[client].put(key, value)\nprintln(\" put to client $client\")\nfor (client in clients) {\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "new_path": "model-server/src/main/java/org/modelix/model/server/Main.java", "diff": "@@ -114,7 +114,7 @@ public class Main {\ntry {\nserver.stop();\n} catch (Exception ex) {\n- System.out.println(ex.getMessage());\n+ System.err.println(\"Exception: \" + ex.getMessage());\nex.printStackTrace();\n}\n}));\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "diff": "@@ -213,6 +213,7 @@ public class RestModelServer {\n@Override\nprotected void doPut(HttpServletRequest req, HttpServletResponse resp)\nthrows ServletException, IOException {\n+ try {\nif (!checkAuthorization(storeClient, req, resp)) return;\nString key = req.getPathInfo().substring(1);\n@@ -231,6 +232,11 @@ public class RestModelServer {\nresp.setContentType(TEXT_PLAIN);\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\nresp.getWriter().print(\"OK\");\n+ } catch (Exception e) {\n+ e.printStackTrace();\n+ resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\n+ resp.getWriter().print(e.getMessage());\n+ }\n}\n}),\n\"/put/*\");\n@@ -363,7 +369,7 @@ public class RestModelServer {\ntry {\nemitter.data(value);\n} catch (IOException e) {\n- System.out.println(e.getMessage());\n+ System.err.println(\"Exception: \" + e.getMessage());\ne.printStackTrace();\n}\n}\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
adding logs to debug failing test
426,504
16.08.2020 11:07:45
-7,200
8ab0444ebe26b1c9425fbb8389d76a90796be393
correct test_t1
[ { "change_type": "MODIFY", "old_path": "model-client/src/jvmMain/kotlin/org/modelix/model/client/RestWebModelClient.kt", "new_path": "model-client/src/jvmMain/kotlin/org/modelix/model/client/RestWebModelClient.kt", "diff": "@@ -377,10 +377,10 @@ class RestWebModelClient @JvmOverloads constructor(var baseUrl: String? = null)\n// is useful to recognize when the server is down\nclient = ClientBuilder.newBuilder()\n.connectTimeout(1000, TimeUnit.MILLISECONDS)\n- .readTimeout(1000, TimeUnit.MILLISECONDS)\n+ //.readTimeout(1000, TimeUnit.MILLISECONDS)\n.register(ClientRequestFilter { ctx -> ctx.headers.add(HttpHeaders.AUTHORIZATION, \"Bearer $authToken\") }).build()\nsseClient = ClientBuilder.newBuilder()\n- .connectTimeout(1000, TimeUnit.MILLISECONDS)\n+ //.connectTimeout(1000, TimeUnit.MILLISECONDS)\n.register(ClientRequestFilter { ctx -> ctx.headers.add(HttpHeaders.AUTHORIZATION, \"Bearer $authToken\") }).build()\nidGenerator = IdGenerator(clientId)\nwatchDogTask = fixDelay(\n" }, { "change_type": "MODIFY", "old_path": "model-client/src/jvmTest/kotlin/org/modelix/model/ModelClient_Test.kt", "new_path": "model-client/src/jvmTest/kotlin/org/modelix/model/ModelClient_Test.kt", "diff": "package org.modelix.model\n-import org.glassfish.jersey.client.ClientConfig\n-import org.glassfish.jersey.client.ClientProperties\nimport org.junit.After\nimport org.junit.Assert\nimport org.junit.Before\n@@ -36,6 +34,17 @@ class ModelClient_Test {\n}\nmodelServer.startServerInMemory(emptyMap())\nmodelServer.waitItIsUp()\n+\n+ Runtime.getRuntime()\n+ .addShutdownHook(\n+ Thread(Runnable {\n+ try {\n+ modelServer.kill()\n+ } catch (ex: Exception) {\n+ System.err.println(\"Exception: \" + ex.message)\n+ ex.printStackTrace()\n+ }\n+ }))\n}\n@After\n@@ -44,6 +53,7 @@ class ModelClient_Test {\n}\n// This test requires a running model server\n+ // It should be marked as a slow test and run separately from unit tests\n@Test\nfun test_t1() {\nval rand = Random(67845)\n@@ -63,8 +73,10 @@ class ModelClient_Test {\n}\nfor (i in 0..99) {\nprintln(\"Phase B: i=$i of 100\")\n- //Thread.sleep(400)\nThread.sleep(200)\n+ if (!modelServer.isUp()) {\n+ throw IllegalStateException(\"The model-server is not up\")\n+ }\nval key = \"test_\" + rand.nextInt(10)\nval value = rand.nextLong().toString()\nexpected[key] = value\n" }, { "change_type": "MODIFY", "old_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "new_path": "model-server/src/main/java/org/modelix/model/server/RestModelServer.java", "diff": "@@ -32,6 +32,7 @@ import javax.servlet.http.HttpServletResponse;\nimport org.apache.commons.io.IOUtils;\nimport org.apache.log4j.LogManager;\nimport org.apache.log4j.Logger;\n+import org.eclipse.jetty.io.EofException;\nimport org.eclipse.jetty.servlet.ServletContextHandler;\nimport org.eclipse.jetty.servlet.ServletHolder;\nimport org.eclipse.jetty.servlets.EventSource;\n@@ -227,7 +228,17 @@ public class RestModelServer {\nString value =\nIOUtils.toString(\nreq.getInputStream(), StandardCharsets.UTF_8);\n+ try {\nstoreClient.put(key, value);\n+ } catch (Throwable t) {\n+ System.err.println(\"failed to write value\");\n+ t.printStackTrace();\n+ resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);\n+ resp.setContentType(TEXT_PLAIN);\n+ resp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\n+ resp.getWriter().print(\"Put failed on server side: \" + t.getMessage());\n+ return;\n+ }\nresp.setStatus(HttpServletResponse.SC_OK);\nresp.setContentType(TEXT_PLAIN);\nresp.setCharacterEncoding(StandardCharsets.UTF_8.toString());\n@@ -368,6 +379,9 @@ public class RestModelServer {\nif (subscribedKey.equals(changedKey)) {\ntry {\nemitter.data(value);\n+ } catch (EofException e) {\n+ System.err.println(\"The peer has probably closed the connection, therefore we are unable to notify them of changes. We will not retry\");\n+ emitter = null;\n} catch (IOException e) {\nSystem.err.println(\"Exception: \" + e.getMessage());\ne.printStackTrace();\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
correct test_t1
426,504
16.08.2020 11:18:53
-7,200
d92023cb418425900a20a34fed7eca6a9c272f1c
adding CompositeNodeResolveContextTest
[ { "change_type": "MODIFY", "old_path": "model-client/src/commonMain/kotlin/org/modelix/model/api/CompositeNodeResolveContext.kt", "new_path": "model-client/src/commonMain/kotlin/org/modelix/model/api/CompositeNodeResolveContext.kt", "diff": "package org.modelix.model.api\nclass CompositeNodeResolveContext(contexts: Iterable<INodeResolveContext>) : INodeResolveContext {\n- private val contexts: List<INodeResolveContext?>\n+ private val contexts: List<INodeResolveContext> = contexts.toList()\n- constructor(vararg contexts: INodeResolveContext) : this(contexts.toList()) {}\n+ constructor(vararg contexts: INodeResolveContext) : this(contexts.toList())\noverride fun resolve(ref: INodeReference?): INode? {\n- return contexts.mapNotNull { it?.resolve(ref) }.firstOrNull()\n- }\n-\n- init {\n- this.contexts = contexts.toList()\n+ return contexts.mapNotNull { it.resolve(ref) }.firstOrNull()\n}\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "model-client/src/commonTest/kotlin/org/modelix/model/api/CompositeNodeResolveContextTest.kt", "diff": "+package org.modelix.model.api\n+\n+import kotlin.test.Test\n+import kotlin.test.assertEquals\n+\n+class MyNodeReference : INodeReference {\n+ override fun resolveNode(context: INodeResolveContext?): INode? {\n+ TODO(\"Not yet implemented\")\n+ }\n+}\n+\n+class MyNode(val name: String) : INode {\n+ override val isValid: Boolean\n+ get() = TODO(\"Not yet implemented\")\n+ override val reference: INodeReference\n+ get() = TODO(\"Not yet implemented\")\n+ override val concept: IConcept?\n+ get() = TODO(\"Not yet implemented\")\n+ override val roleInParent: String?\n+ get() = TODO(\"Not yet implemented\")\n+ override val parent: INode?\n+ get() = TODO(\"Not yet implemented\")\n+\n+ override fun getChildren(role: String?): Iterable<INode> {\n+ TODO(\"Not yet implemented\")\n+ }\n+\n+ override val allChildren: Iterable<INode>\n+ get() = TODO(\"Not yet implemented\")\n+\n+ override fun addChild(role: String?, index: Int, node: INode) {\n+ TODO(\"Not yet implemented\")\n+ }\n+\n+ override fun addNewChild(role: String?, index: Int, concept: IConcept?): INode {\n+ TODO(\"Not yet implemented\")\n+ }\n+\n+ override fun removeChild(child: INode) {\n+ TODO(\"Not yet implemented\")\n+ }\n+\n+ override fun getReferenceTarget(role: String): INode? {\n+ TODO(\"Not yet implemented\")\n+ }\n+\n+ override fun setReferenceTarget(role: String, target: INode?) {\n+ TODO(\"Not yet implemented\")\n+ }\n+\n+ override fun getPropertyValue(role: String): String? {\n+ TODO(\"Not yet implemented\")\n+ }\n+\n+ override fun setPropertyValue(role: String, value: String?) {\n+ TODO(\"Not yet implemented\")\n+ }\n+\n+ override fun equals(other: Any?): Boolean {\n+ return if (other is MyNode) {\n+ this.name == other.name\n+ } else {\n+ false\n+ }\n+ }\n+\n+ override fun hashCode(): Int {\n+ return name.hashCode()\n+ }\n+}\n+\n+class MyNodeResolveContext(val knownResolutions : Map<INodeReference, INode>) : INodeResolveContext {\n+ override fun resolve(ref: INodeReference?): INode? {\n+ return knownResolutions[ref]\n+ }\n+}\n+\n+class CompositeNodeResolveContextTest {\n+\n+ @Test\n+ fun resolveWhenEmpty() {\n+ val instance = CompositeNodeResolveContext()\n+ assertEquals(null, instance.resolve(null))\n+ assertEquals(null, instance.resolve(PNodeReference(123)))\n+ assertEquals(null, instance.resolve(MyNodeReference()))\n+ }\n+\n+ @Test\n+ fun resolveWhenNotEmpty() {\n+ val instance = CompositeNodeResolveContext(\n+ MyNodeResolveContext(mapOf(PNodeReference(123) to MyNode(\"foo\"))),\n+ MyNodeResolveContext(mapOf(PNodeReference(456) to MyNode(\"bar\")))\n+ )\n+ assertEquals(null, instance.resolve(null))\n+ assertEquals(MyNode(\"foo\"), instance.resolve(PNodeReference(123)))\n+ assertEquals(MyNode(\"bar\"), instance.resolve(PNodeReference(456)))\n+ assertEquals(null, instance.resolve(PNodeReference(789)))\n+ assertEquals(null, instance.resolve(MyNodeReference()))\n+ }\n+}\n\\ No newline at end of file\n" } ]
Kotlin
Apache License 2.0
modelix/modelix
adding CompositeNodeResolveContextTest