/**
 * Copyright 2010 OpenEngSB Division, Vienna University of Technology
 *
 * 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.
 */

package org.openengsb.integrationtest.exam;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.openengsb.integrationtest.util.AbstractExamTestHelper;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;

@RunWith(JUnit4TestRunner.class)
public class PersistenceIT extends AbstractExamTestHelper {

    @Test
    public void testCreate() throws Exception {
    }

    @Test
    public void testUpdate() throws Exception {
    }

    @Test
    public void testDelete() throws Exception {
    }

    @Test
    public void testQuery() throws Exception {
    }
}

@@ -673,16 +673,153 @@
 .exam;%0A%0A
+import static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0A%0Aimport java.util.List;%0A%0Aimport org.junit.Before;%0A
 import o
@@ -866,16 +866,74 @@
 unWith;%0A
+import org.openengsb.core.persistence.PersistenceService;%0A
 import o
@@ -1135,16 +1135,403 @@
 lper %7B%0A%0A
+    private PersistenceService persistence;%0A    private TestObject element;%0A    private TestObject wildcard;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        persistence = retrieveService(getBundleContext(), PersistenceService.class);%0A%0A        element = new TestObject(%2242%22, 42);%0A        persistence.create(element);%0A%0A        wildcard = new TestObject(null, null);%0A    %7D%0A%0A
     @Tes
@@ -1558,16 +1558,24 @@
 stCreate
+AndQuery
 () throw
@@ -1580,32 +1580,289 @@
 ows Exception %7B%0A
+        TestObject test = new TestObject(%22test%22, 1);%0A        persistence.create(test);%0A        List%3CTestObject%3E result = persistence.query(new TestObject(%22test%22, null));%0A        assertThat(result.size(), is(1));%0A        assertThat(result.get(0), is(test));%0A
     %7D%0A%0A    @Test
@@ -1888,16 +1888,24 @@
 stUpdate
+AndQuery
 () throw
@@ -1926,132 +1926,1797 @@
     
-%7D%0A%0A    @Test%0A    public void testDelete() throws Exception %7B%0A    %7D%0A%0A    @Test%0A    public void testQuery() throws Exception %7B
+    element.string = %22foo%22;%0A%0A        persistence.update(persistence.query(wildcard).get(0), element);%0A%0A        List%3CTestObject%3E result = persistence.query(wildcard);%0A        assertThat(result.size(), is(1));%0A        assertThat(result.get(0).getString(), is(%22foo%22));%0A    %7D%0A%0A    @Test%0A    public void testDelete() throws Exception %7B%0A        persistence.delete(element);%0A        List%3CTestObject%3E result = persistence.query(wildcard);%0A        assertThat(result.isEmpty(), is(true));%0A    %7D%0A%0A    public static class TestObject %7B%0A        private String string;%0A%0A        private Integer integer;%0A%0A        public TestObject(String string, Integer integer) %7B%0A            this.string = string;%0A            this.integer = integer;%0A        %7D%0A%0A        public Integer getInteger() %7B%0A            return integer;%0A        %7D%0A%0A        public String getString() %7B%0A            return string;%0A        %7D%0A%0A        @Override%0A        public int hashCode() %7B%0A            final int prime = 31;%0A            int result = 1;%0A            result = prime * result + ((integer == null) ? 0 : integer.hashCode());%0A            result = prime * result + ((string == null) ? 0 : string.hashCode());%0A            return result;%0A        %7D%0A%0A        @Override%0A        public boolean equals(Object obj) %7B%0A            if (this == obj)%0A                return true;%0A            if (obj == null)%0A                return false;%0A            if (getClass() != obj.getClass())%0A                return false;%0A            TestObject other = (TestObject) obj;%0A            return safeEquals(this.string, other.string) && safeEquals(this.integer, other.integer);%0A        %7D%0A%0A        private boolean safeEquals(Object a, Object b) %7B%0A            if (a == null) %7B%0A                return b == null;%0A            %7D%0A            return a.equals(b);%0A        %7D%0A
 %0A   

Implement persistence integration test.