pass file tests

This commit is contained in:
2025-01-01 20:50:16 +01:00
parent 57ea21a3b2
commit f5ceb23615
3 changed files with 10 additions and 9 deletions

View File

@@ -51,7 +51,6 @@ public class KleppmannTree<TimestampT extends Comparable<TimestampT>, PeerIdT ex
private void undoEffect(LogEffect<TimestampT, PeerIdT, MetaT, NodeIdT> effect) {
if (effect.oldInfo() != null) {
var node = _storage.getById(effect.childId());
var oldParent = _storage.getById(effect.oldInfo().oldParent());
var curParent = _storage.getById(effect.newParentId());
{
var newCurParentChildren = new HashMap<>(curParent.children());
@@ -62,6 +61,9 @@ public class KleppmannTree<TimestampT extends Comparable<TimestampT>, PeerIdT ex
if (!node.meta().getClass().equals(effect.oldInfo().oldMeta().getClass()))
throw new IllegalArgumentException("Class mismatch for meta for node " + node.key());
// Needs to be read after changing curParent, as it might be the same node
var oldParent = _storage.getById(effect.oldInfo().oldParent());
{
var newOldParentChildren = new HashMap<>(oldParent.children());
newOldParentChildren.put(node.meta().getName(), node.key());
@@ -296,7 +298,6 @@ public class KleppmannTree<TimestampT extends Comparable<TimestampT>, PeerIdT ex
TreeNode<TimestampT, PeerIdT, MetaT, NodeIdT> newParentNode;
TreeNode<TimestampT, PeerIdT, MetaT, NodeIdT> node;
newParentNode = _storage.getById(effect.newParentId());
if (effect.oldInfo() != null) {
oldParentNode = _storage.getById(effect.oldInfo().oldParent());
}
@@ -312,6 +313,9 @@ public class KleppmannTree<TimestampT extends Comparable<TimestampT>, PeerIdT ex
_storage.putNode(oldParentNode);
}
// Needs to be read after changing oldParentNode, as it might be the same node
newParentNode = _storage.getById(effect.newParentId());
{
var newNewParentChildren = new HashMap<>(newParentNode.children());
newNewParentChildren.put(effect.newMeta().getName(), effect.childId());

View File

@@ -75,7 +75,7 @@ public class JObjectManager {
} else if (type.isInstance(ref.data())) {
return (JDataVersionedWrapper<T>) ref;
} else {
throw new IllegalArgumentException("Object type mismatch: " + ref.getClass() + " vs " + type);
throw new IllegalArgumentException("Object type mismatch: " + ref.data().getClass() + " vs " + type);
}
}
}

View File

@@ -1,20 +1,17 @@
package com.usatiuk.dhfs.files;
import com.usatiuk.dhfs.TempDataProfile;
import com.usatiuk.dhfs.files.objects.ChunkData;
import com.usatiuk.dhfs.files.objects.File;
import com.usatiuk.dhfs.files.service.DhfsFileService;
import com.usatiuk.dhfs.objects.TransactionManager;
import com.usatiuk.dhfs.objects.transaction.Transaction;
import com.usatiuk.kleppmanntree.AlreadyExistsException;
import com.usatiuk.objects.common.runtime.JObjectKey;
import jakarta.inject.Inject;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static org.awaitility.Awaitility.await;
class Profiles {
public static class DhfsFileServiceSimpleTestProfile extends TempDataProfile {
@@ -211,8 +208,8 @@ public class DhfsFileServiceSimpleTestImpl {
jObjectTxManager.run(() -> {
var oldfile = curTx.get(File.class, ret2.get()).orElseThrow(IllegalStateException::new);
var chunk = oldfile.chunks().get(0);
var chunkObj = curTx.get(File.class, chunk).orElseThrow(IllegalStateException::new);
var chunk = oldfile.chunks().get(0L);
var chunkObj = curTx.get(ChunkData.class, chunk).orElseThrow(IllegalStateException::new);
});
Assertions.assertTrue(fileService.rename("/moveOverTest1", "/moveOverTest2"));