Skip to content

Commit

Permalink
Reorganize procedure interaction level based test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
boggle authored and systay committed Sep 6, 2016
1 parent 1e74a86 commit 3244ee4
Show file tree
Hide file tree
Showing 18 changed files with 680 additions and 498 deletions.
@@ -1,3 +1,22 @@
/*
* Copyright (c) 2002-2016 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.kernel.impl.query;

import org.junit.Test;
Expand All @@ -23,6 +42,7 @@
public class Neo4jTransactionalContextTest
{

@SuppressWarnings( "ConstantConditions" )
@Test
public void neverStopsExecutingQueryDuringCommitAndRestartTx()
{
Expand Down
Expand Up @@ -61,7 +61,7 @@

public class AuthProceduresIT
{
static final String PWD_CHANGE = PASSWORD_CHANGE_REQUIRED.name().toLowerCase();
private static final String PWD_CHANGE = PASSWORD_CHANGE_REQUIRED.name().toLowerCase();

protected GraphDatabaseAPI db;
private EphemeralFileSystemAbstraction fs;
Expand Down Expand Up @@ -278,8 +278,8 @@ private void assertFail( BasicAuthSubject subject, String query, String partOfEr
containsString( partOfErrorMsg ) );
}

void assertSuccess( BasicAuthSubject subject, String query,
Consumer<ResourceIterator<Map<String, Object>>> resultConsumer )
private void assertSuccess( BasicAuthSubject subject, String query,
Consumer<ResourceIterator<Map<String,Object>>> resultConsumer )
{
assertThat(
execute( subject, query, resultConsumer ),
Expand All @@ -301,24 +301,35 @@ private String execute( BasicAuthSubject subject, String query,
}
}

List<Object> getObjectsAsList( ResourceIterator<Map<String, Object>> r, String key )
private List<Object> getObjectsAsList( ResourceIterator<Map<String,Object>> r, String key )
{
return r.stream().map( s -> s.get( key ) ).collect( Collectors.toList() );
}

void assertKeyIs( ResourceIterator<Map<String, Object>> r, String key, String... items )
private void assertKeyIs( ResourceIterator<Map<String,Object>> r, String key, String... items )
{
assertKeyIsArray( r, key, items );
}

void assertKeyIsArray( ResourceIterator<Map<String, Object>> r, String key, String[] items )
private void assertKeyIsArray( ResourceIterator<Map<String,Object>> r, String key, String[] items )
{
List<Object> results = getObjectsAsList( r, key );
assertEquals( Arrays.asList( items ).size(), results.size() );
Assert.assertThat( results, containsInAnyOrder( items ) );
}

protected void assertKeyIsMap( ResourceIterator<Map<String, Object>> r, String keyKey, String valueKey, Map<String,Object> expected )
protected String[] with( String[] strs, String... moreStr )
{
return Stream.concat( Arrays.stream(strs), Arrays.stream( moreStr ) ).toArray( String[]::new );
}

private List<String> listOf( String... values )
{
return Stream.of( values ).collect( Collectors.toList() );
}

@SuppressWarnings( "unchecked" )
public static void assertKeyIsMap( ResourceIterator<Map<String, Object>> r, String keyKey, String valueKey, Map<String,Object> expected )
{
List<Map<String, Object>> result = r.stream().collect( Collectors.toList() );

Expand Down Expand Up @@ -351,14 +362,4 @@ protected void assertKeyIsMap( ResourceIterator<Map<String, Object>> r, String k
}
}
}

protected String[] with( String[] strs, String... moreStr )
{
return Stream.concat( Arrays.stream(strs), Arrays.stream( moreStr ) ).toArray( String[]::new );
}

protected List<String> listOf( String... values )
{
return Stream.of( values ).collect( Collectors.toList() );
}
}
Expand Up @@ -19,6 +19,10 @@
*/
package org.neo4j.kernel.impl.query;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
Expand All @@ -32,19 +36,15 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.ResourceIterator;
import org.neo4j.graphdb.Result;
import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.kernel.configuration.Settings;
import org.neo4j.logging.AssertableLogProvider;
import org.neo4j.kernel.enterprise.api.security.EnterpriseAuthSubject;
import org.neo4j.server.security.enterprise.auth.NeoShallowEmbeddedInteraction;
import org.neo4j.logging.AssertableLogProvider;
import org.neo4j.server.security.enterprise.auth.EmbeddedInteraction;
import org.neo4j.test.TestEnterpriseGraphDatabaseFactory;
import org.neo4j.test.rule.TestDirectory;
import org.neo4j.test.rule.fs.EphemeralFileSystemRule;
Expand All @@ -55,7 +55,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import static org.neo4j.kernel.api.security.AccessMode.Static.FULL;
import static org.neo4j.kernel.impl.query.QueryEngineProvider.embeddedSession;

Expand Down Expand Up @@ -86,7 +85,7 @@ public void shouldLogCustomUserName() throws Throwable
// turn on query logging
databaseBuilder.setConfig( GraphDatabaseSettings.logs_directory, logsDirectory.getPath() );
databaseBuilder.setConfig( GraphDatabaseSettings.log_queries, Settings.TRUE );
NeoShallowEmbeddedInteraction db = new NeoShallowEmbeddedInteraction( databaseBuilder );
EmbeddedInteraction db = new EmbeddedInteraction( databaseBuilder );

// create users
db.getManager().newUser( "mats", "neo4j", false );
Expand Down

0 comments on commit 3244ee4

Please sign in to comment.