package peergos.server.tests;

import org.junit.*;
import org.junit.runner.*;
import org.junit.runners.*;
import peergos.shared.*;
import peergos.shared.user.*;
import peergos.shared.user.fs.*;

import java.net.*;
import java.util.*;

@RunWith(Parameterized.class)
public class RemoteUserTests {

    private final NetworkAccess network;
    private final Crypto crypto = Crypto.initJava();

    public RemoteUserTests(String remoteUrl) throws Exception {
        this.network = NetworkAccess.buildJava(new URL(remoteUrl)).get();
    }

    @Parameterized.Parameters(name = "{index}: {0}")
    public static Collection<Object[]> parameters() {
        return Arrays.asList(new Object[][] {
                {"https://demo.peergos.net"}
        });
    }

    @Test
    public void loginAndTest() throws Exception {
        String username = "ianopolous";
        String password = "notmypassword";
        UserContext context = ensureSignedUp(username, password, network, crypto);
        FileTreeNode userRoot = context.getUserRoot().get();
        // Do stuff
        System.out.println(userRoot);
    }

    public static UserContext ensureSignedUp(String username, String password, NetworkAccess network, Crypto crypto) throws Exception {
        return UserContext.ensureSignedUp(username, password, network, crypto).get();
    }
}

@@ -781,20 +781,31 @@
 loginAnd
-Test
+CleanADirectory
 () throw
@@ -984,16 +984,16 @@
 rypto);%0A
-
         
@@ -1041,24 +1041,278 @@
 ot().get();%0A
+        FileTreeNode dirToFixChildLinks = context.getByPath(%22/%22 + username + %22/peergos%22).get().get();%0A        dirToFixChildLinks.cleanUnreachableChildren(context).get();%0A        Set%3CFileTreeNode%3E children = dirToFixChildLinks.getChildren(context).get();%0A
         // D

Add example to clean a broken directory