// Path: lib/src/test/java/io/reist/sklad/TestUtils.java
// static final String TEST_NAME_1 = "z12";
// 
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java
// static void assertTestObject(Storage storage) throws IOException {
//     assertTestObject(storage, 0);
// }


import android.os.Build;
import android.support.annotation.NonNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okio.Buffer;
import static io.reist.sklad.TestUtils.TEST_NAME_1;
import static io.reist.sklad.TestUtils.assertTestObject;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

        assertTrue(storage.contains(TestUtils.TEST_NAME_2));
        assertFalse(storage.contains(TestUtils.TEST_NAME_2_INVALID));

        OutputStream remoteStream = storage.getRemote().openOutputStream(TestUtils.TEST_NAME_3);
        remoteStream.write(TestUtils.TEST_DATA_3);
        remoteStream.flush();
        remoteStream.close();

        assertTrue(storage.contains(TestUtils.TEST_NAME_3));
        assertFalse(storage.contains(TestUtils.TEST_NAME_3_INVALID));

        server.shutdown();

    }

    @Test
    public final void testDownload() throws Exception {

        Buffer buffer = new Buffer();
        buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1));

        MockWebServer server = new MockWebServer();
        server.enqueue(new MockResponse().setBody(buffer));
        server.start();

        baseUrl = server.url("/");

        CachedStorage storage = createStorage();
        storage.cache(TEST_NAME_1);
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java
// static final String TEST_NAME_1 = "z12";
// 
// Path: lib/src/test/java/io/reist/sklad/TestUtils.java
// static void assertTestObject(Storage storage) throws IOException {
//     assertTestObject(storage, 0);
// }


// Path: lib/src/test/java/io/reist/sklad/CachedStorageTest.java
import android.os.Build;
import android.support.annotation.NonNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okio.Buffer;
import static io.reist.sklad.TestUtils.TEST_NAME_1;
import static io.reist.sklad.TestUtils.assertTestObject;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;


        assertTrue(storage.contains(TestUtils.TEST_NAME_2));
        assertFalse(storage.contains(TestUtils.TEST_NAME_2_INVALID));

        OutputStream remoteStream = storage.getRemote().openOutputStream(TestUtils.TEST_NAME_3);
        remoteStream.write(TestUtils.TEST_DATA_3);
        remoteStream.flush();
        remoteStream.close();

        assertTrue(storage.contains(TestUtils.TEST_NAME_3));
        assertFalse(storage.contains(TestUtils.TEST_NAME_3_INVALID));

        server.shutdown();

    }

    @Test
    public final void testDownload() throws Exception {

        Buffer buffer = new Buffer();
        buffer.readFrom(new ByteArrayInputStream(TestUtils.TEST_DATA_1));

        MockWebServer server = new MockWebServer();
        server.enqueue(new MockResponse().setBody(buffer));
        server.start();

        baseUrl = server.url("/");

        CachedStorage storage = createStorage();
        storage.cache(TEST_NAME_1);
        assertTestObject(storage.getLocal());