package org.rmatil.sync.event.aggregator.test.mocks;

import org.rmatil.sync.commons.hashing.Hash;
import org.rmatil.sync.event.aggregator.config.Config;
import org.rmatil.sync.persistence.exceptions.InputOutputException;
import org.rmatil.sync.version.api.IObjectManager;
import org.rmatil.sync.version.core.model.Index;
import org.rmatil.sync.version.core.model.PathObject;

import java.util.HashMap;
import java.util.Map;

/**
 * Mocks an object manager
 *
 * @see IObjectManager
 */
public class ObjectManagerMock implements IObjectManager {

    Index index;

    Map<String, PathObject> pathObjects;

    public ObjectManagerMock() {
        this.index = new Index(new HashMap<>());
        this.pathObjects = new HashMap<>();
    }

    @Override
    public void writeObject(PathObject path)
            throws InputOutputException {
        this.pathObjects.put(Hash.hash(Config.DEFAULT.getHashingAlgorithm(), path.getAbsolutePath()), path);
    }

    @Override
    public PathObject getObject(String fileNameHash)
            throws InputOutputException {
        return this.pathObjects.get(fileNameHash);
    }

    @Override
    public void removeObject(String fileNameHash)
            throws InputOutputException {
        this.pathObjects.remove(fileNameHash);
    }

    @Override
    public Index getIndex() {
        return this.index;
    }

    @Override
    public String getIndexFileName() {
        return "index.json";
    }
}

@@ -387,23 +387,74 @@
 va.util.
-HashMap
+ArrayList;%0Aimport java.util.HashMap;%0Aimport java.util.List
 ;%0Aimport
@@ -1320,32 +1320,443 @@
 meHash);%0A    %7D%0A%0A
+    @Override%0A    public List%3CPathObject%3E getChildren(String s)%0A            throws InputOutputException %7B%0A        List%3CPathObject%3E pathObjects = new ArrayList%3C%3E();%0A        for (Map.Entry%3CString, PathObject%3E entry : this.pathObjects.entrySet()) %7B%0A            if (entry.getKey().startsWith(s + %22/%22)) %7B%0A                pathObjects.add(entry.getValue());%0A            %7D%0A        %7D%0A%0A        return pathObjects;%0A    %7D%0A%0A
     @Override%0A  

Add missing method