|
| 1 | +/** |
| 2 | + * Copyright (c) 2002-2016 "Neo Technology," |
| 3 | + * Network Engine for Objects in Lund AB [http://neotechnology.com] |
| 4 | + * |
| 5 | + * This file is part of Neo4j. |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + */ |
| 19 | +package org.neo4j.driver.v1; |
| 20 | + |
| 21 | +import javadoctest.DocSnippet; |
| 22 | +import javadoctest.DocTestRunner; |
| 23 | +import org.junit.Rule; |
| 24 | +import org.junit.runner.RunWith; |
| 25 | + |
| 26 | +import java.util.LinkedList; |
| 27 | +import java.util.List; |
| 28 | + |
| 29 | +import org.neo4j.driver.v1.util.TestNeo4jSession; |
| 30 | + |
| 31 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 32 | +import static org.hamcrest.Matchers.containsInAnyOrder; |
| 33 | +import static org.junit.Assert.assertEquals; |
| 34 | + |
| 35 | +@RunWith( DocTestRunner.class ) |
| 36 | +public class DriverDocIT |
| 37 | +{ |
| 38 | + @Rule |
| 39 | + public TestNeo4jSession session = new TestNeo4jSession(); |
| 40 | + |
| 41 | + /** @see Driver */ |
| 42 | + @SuppressWarnings("unchecked") |
| 43 | + public void exampleUsage( DocSnippet snippet ) |
| 44 | + { |
| 45 | + // given |
| 46 | + snippet.addImport( List.class ); |
| 47 | + snippet.addImport( LinkedList.class ); |
| 48 | + session.run( "MATCH (n) DETACH DELETE (n)" ); |
| 49 | + |
| 50 | + // when |
| 51 | + snippet.run(); |
| 52 | + |
| 53 | + // then it should've created a bunch of data |
| 54 | + StatementResult result = session.run( "MATCH (n) RETURN count(n)" ); |
| 55 | + assertEquals( 3, result.single().get( 0 ).asInt() ); |
| 56 | + assertThat( (List<String>)snippet.get( "names" ), containsInAnyOrder( "Bob", "Alice", "Tina" ) ); |
| 57 | + } |
| 58 | +} |
0 commit comments