/*
 * Copyright 2015 Bay of Many
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 *
 * This project is derived from code in the TinkerPop project under the following license:
 *
 *    TinkerPop3
 *    http://www.apache.org/licenses/LICENSE-2.0
 */

package peapod;

import org.apache.tinkerpop.gremlin.structure.T;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.Before;
import org.junit.Test;
import peapod.model.Person;

import java.util.List;
import java.util.stream.Collectors;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.hasProperty;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;

public class FramedGraphTest extends GraphTest {

    private FramedGraph graph;
    private Vertex alice;

    @Before
    public void init() {
        alice = g.addVertex(T.label, "Person", "name", "alice");
        Vertex b = g.addVertex(T.label, "Person", "name", "bob");
        Vertex c = g.addVertex(T.label, "Person", "name", "charlie");
        alice.addEdge("friend", b);
        alice.addEdge("friend", c);
        graph = new FramedGraph(g, Person.class.getPackage());
    }

    @Test
    public void testAddVertex() throws Exception {
        Person person = graph.addVertex(Person.class);
        assertNotNull(person);
        assertNotNull(person.vertex());
        assertNotNull(person.vertex().id());
        assertEquals("Person", person.vertex().label());
    }

    @Test
    public void testAddVertexWithId() throws Exception {
        assumeTrue(graph.features().vertex().supportsUserSuppliedIds());

        Person person = graph.addVertex(Person.class, 456);
        assertNotNull(person);
        assertNotNull(person.vertex());
        assertEquals(456, person.vertex().id());
        assertEquals("Person", person.vertex().label());
    }

    @Test
    public void testV() throws Exception {
        Person p = graph.v(alice.id());
        assertEquals(alice.id(), p.vertex().id());
        assertEquals("alice", p.getName());
    }

    @Test
    public void testFindAll() throws Exception {
        List<Person> result = graph.V(Person.class).toList();
        assertEquals(3, result.size());
        assertThat(result.stream().map(Person::getName).collect(Collectors.toList()), containsInAnyOrder("alice", "bob", "charlie"));
        assertEquals("alice", result.get(0).getName());
    }

    @Test
    public void testHas() throws Exception {
        List<Person> result = graph.V(Person.class).has("name", "alice").toList();
        assertEquals(1, result.size());
        assertEquals("alice", result.get(0).getName());
    }

    @Test
    public void testIn() throws Exception {
        List<Person> result = graph.V(Person.class).has("name", "bob").in("friend", Person.class).toList();
        assertEquals(1, result.size());
        assertEquals("alice", result.get(0).getName());

        assertThat(graph.v(alice.id(), Person.class).getFriends(), hasItem(hasProperty("name", equalTo("bob"))));
    }

    @Test
    public void testConfiguration() throws Exception {
        assertNotNull(graph.configuration());
    }

    @Test
    public void testVariables() throws Exception {
        assertEquals(g.variables().keys(), graph.variables().keys());
    }

    @Test
    public void testFeatures() throws Exception {
        assertEquals(g.features().toString(), graph.features().toString());
    }

    @Test
    public void testGraph() throws Exception {
        assertEquals(g, graph.graph());
    }

    @Test
    public void testTx() throws Exception {
        assumeTrue(graph.features().graph().supportsTransactions());
        assertNotNull(graph.tx());
    }

}
@@ -2980,64 +2980,8 @@
 ));%0A
-        assertEquals(%22alice%22, result.get(0).getName());%0A
     

upgrade apache tinkerpop 3.0.0-M9