Skip to content

Commit

Permalink
Exclude deprecated fields from default procedure result
Browse files Browse the repository at this point in the history
  • Loading branch information
thobe committed Mar 24, 2017
1 parent 4ccfd57 commit 51268ce
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 12 deletions.
Expand Up @@ -42,7 +42,7 @@ object ResolvedCall {
}

private def signatureResults(signature: ProcedureSignature, position: InputPosition): IndexedSeq[ProcedureResultItem] =
signature.outputSignature.getOrElse(Seq.empty).map {
signature.outputSignature.getOrElse(Seq.empty).filter(!_.deprecated).map {
field => ProcedureResultItem(Variable(field.name)(position))(position)
}.toIndexedSeq
}
Expand Down
Expand Up @@ -21,6 +21,12 @@ package org.neo4j.internal.cypher.acceptance

import java.util

import org.neo4j.collection.RawIterator
import org.neo4j.helpers.collection.MapUtil.map
import org.neo4j.kernel.api.exceptions.ProcedureException
import org.neo4j.kernel.api.proc.CallableProcedure.BasicProcedure
import org.neo4j.kernel.api.proc.{Context, FieldSignature, Neo4jTypes}

class ProcedureCallSupportAcceptanceTest extends ProcedureCallAcceptanceTest {

test("should return correctly typed map result (even if converting to and from scala representation internally)") {
Expand Down Expand Up @@ -62,4 +68,23 @@ class ProcedureCallSupportAcceptanceTest extends ProcedureCallAcceptanceTest {
java.util.Collections.singletonMap("out", stream)
))
}

test("should not yield deprecated fields") {
// given
registerProcedure("something.with.deprecated.output") { builder =>
builder.out(util.Arrays.asList(
FieldSignature.outputField("one",Neo4jTypes.NTString),
FieldSignature.outputField("oldTwo",Neo4jTypes.NTString, true),
FieldSignature.outputField("newTwo",Neo4jTypes.NTString) ))
new BasicProcedure(builder.build) {
override def apply(ctx: Context, input: Array[AnyRef]): RawIterator[Array[AnyRef], ProcedureException] =
RawIterator.of[Array[AnyRef], ProcedureException](Array("alpha","junk","beta"))
}
}

// then
graph.execute("CALL something.with.deprecated.output()").stream().toArray.toList should equal(List(
map("one", "alpha", "newTwo", "beta")
))
}
}
Expand Up @@ -227,9 +227,9 @@ public void assertSessionKilled( BoltSubject subject )
}

@Override
public String getConnectionDetails()
public String getConnectionProtocol()
{
return "bolt-session";
return "bolt";
}

private static BoltResult collectResults( TransportConnection client ) throws Exception
Expand Down
Expand Up @@ -1048,7 +1048,7 @@ private Matcher<Map<String,Object>> listedQueryOfInteractionLevel( OffsetDateTim
hasQueryId(),
hasStartTimeAfter( startTime ),
hasNoParameters(),
hasConnectionDetails( neo.getConnectionDetails() )
hasProtocol( neo.getConnectionProtocol() )
);
}

Expand Down Expand Up @@ -1113,10 +1113,9 @@ private Matcher<Map<String, Object>> hasNoParameters()
}

@SuppressWarnings( "unchecked" )
private Matcher<Map<String, Object>> hasConnectionDetails( String expected )
private Matcher<Map<String, Object>> hasProtocol( String expected )
{
return (Matcher) hasEntry( equalTo( "connectionDetails" ),
containsString( expected ) );
return (Matcher) hasEntry( "protocol", expected );
}

@SuppressWarnings( "unchecked" )
Expand Down
Expand Up @@ -185,8 +185,8 @@ public void assertSessionKilled( EnterpriseSecurityContext subject )
}

@Override
public String getConnectionDetails()
public String getConnectionProtocol()
{
return "embedded-session";
return null;
}
}
Expand Up @@ -72,5 +72,5 @@ static String tempPath(String prefix, String suffix ) throws IOException

void assertSessionKilled( S subject );

String getConnectionDetails();
String getConnectionProtocol();
}
Expand Up @@ -214,9 +214,9 @@ public void assertSessionKilled( RESTSubject subject )
}

@Override
public String getConnectionDetails()
public String getConnectionProtocol()
{
return "server-session";
return "http";
}

private String parseErrorMessage( HTTP.Response response )
Expand Down

0 comments on commit 51268ce

Please sign in to comment.