package com.smbtec.xo.tinkerpop.blueprints.test.repository;

import com.buschmais.xo.api.ResultIterable;
import com.buschmais.xo.api.XOManager;
import com.buschmais.xo.api.bootstrap.XOUnit;
import com.smbtec.xo.tinkerpop.blueprints.test.AbstractTinkerPopXOManagerTest;
import com.smbtec.xo.tinkerpop.blueprints.test.repository.composite.A;
import com.smbtec.xo.tinkerpop.blueprints.test.repository.composite.DatastoreSpecificRepository;
import com.smbtec.xo.tinkerpop.blueprints.test.repository.composite.GenericRepository;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.net.URISyntaxException;
import java.util.Collection;

import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

@RunWith(Parameterized.class)
public class RepositoryTest extends AbstractTinkerPopXOManagerTest {

    public RepositoryTest(XOUnit xoUnit) {
        super(xoUnit);
    }

    @Parameterized.Parameters
    public static Collection<Object[]> getXOUnits() throws URISyntaxException {
        return xoUnits(A.class, GenericRepository.class, DatastoreSpecificRepository.class);
    }

    @Test
    public void genericRepository() {
        XOManager xoManager = getXoManager();
        xoManager.currentTransaction().begin();
        A a = xoManager.create(A.class);
        a.setName("A1");
        GenericRepository repository = xoManager.getRepository(GenericRepository.class);
        assertThat(repository.findByName("A1"), equalTo(a));
        assertThat(repository.find("A1"), equalTo(a));
        xoManager.currentTransaction().commit();
    }

    @Test
    public void datastoreSpecificRepository() {
        XOManager xoManager = getXoManager();
        xoManager.currentTransaction().begin();
        A a = xoManager.create(A.class);
        a.setName("A1");
        DatastoreSpecificRepository repository = xoManager.getRepository(DatastoreSpecificRepository.class);
        assertThat(repository.findAll(A.class).getSingleResult(), equalTo(a));
        assertThat(repository.findByName("A1"), equalTo(a));
        assertThat(repository.find("A1"), equalTo(a));
        assertThat(repository.count(A.class), equalTo(1L));
        xoManager.currentTransaction().commit();
    }
}

@@ -65,44 +65,252 @@
 ort 
-com.buschmais.xo.api.ResultIterable;
+static org.hamcrest.Matchers.equalTo;%0Aimport static org.junit.Assert.assertThat;%0A%0Aimport java.net.URISyntaxException;%0Aimport java.util.Collection;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized;%0A
 %0Aimp
@@ -730,260 +730,8 @@
 y;%0A%0A
-import org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.Parameterized;%0A%0Aimport java.net.URISyntaxException;%0Aimport java.util.Collection;%0A%0Aimport static org.hamcrest.Matchers.equalTo;%0Aimport static org.junit.Assert.assertThat;%0A%0A
 @Run

remove obsolete import