本文整理了Java中org.neo4j.function.Factory.newInstance()
方法的一些代码示例,展示了Factory.newInstance()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Factory.newInstance()
方法的具体详情如下:
包路径:org.neo4j.function.Factory
类名称:Factory
方法名:newInstance
暂无
代码示例来源:origin: neo4j/neo4j
@Test
public void drop_non_existent_index()
{
String labelName = labels.newInstance();
String propertyKey = properties.newInstance();
gen.get()
.expectedStatus( 404 )
.delete( getSchemaIndexLabelPropertyUri( labelName, propertyKey ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void drop_non_existent_constraint()
{
String labelName = labels.newInstance();
String propertyKey = properties.newInstance();
gen.get().expectedStatus( 404 )
.delete( getSchemaConstraintLabelUniquenessPropertyUri( labelName, propertyKey ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void create_compound_schema_index()
{
Map<String,Object> definition = map( "property_keys",
asList( properties.newInstance(), properties.newInstance() ) );
gen.get().expectedStatus( 200 )
.payload( createJsonFrom( definition ) ).post( getSchemaIndexLabelUri( labels.newInstance() ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void create_compound_schema_constraint()
{
Map<String,Object> definition = map( "property_keys",
asList( properties.newInstance(), properties.newInstance() ) );
gen.get().expectedStatus( 405 )
.payload( createJsonFrom( definition ) ).post( getSchemaConstraintLabelUri( labels.newInstance() ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void create_compound_index()
{
Map<String,Object> definition = map( "property_keys", asList( properties.newInstance(), properties.newInstance()) );
gen.get()
.expectedStatus( 200 )
.payload( createJsonFrom( definition ) )
.post( getSchemaIndexLabelUri( labels.newInstance() ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldGet404WhenRequestingIndexUriWhichDoesntExist()
{
String key = "key3";
String value = "value";
String indexName = indexes.newInstance();
String indexUri = functionalTestHelper.relationshipIndexUri() + indexName + "/" + key + "/" + value;
JaxRsResponse response = httpGet( indexUri );
assertEquals( Status.NOT_FOUND.getStatusCode(), response.getStatus() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldGet404WhenDeletingNonExistentIndex()
{
String indexName = indexes.newInstance();
String indexUri = functionalTestHelper.relationshipIndexUri() + indexName;
JaxRsResponse response = request.delete( indexUri );
assertEquals( Status.NOT_FOUND.getStatusCode(), response.getStatus() );
}
代码示例来源:origin: neo4j/neo4j
@SuppressWarnings( "unchecked" )
@Documented( "Get all indexes." )
@Test
@GraphDescription.Graph( nodes = {} )
public void get_indexes() throws Exception
{
data.get();
String labelName1 = labels.newInstance();
String propertyKey1 = properties.newInstance();
String labelName2 = labels.newInstance();
String propertyKey2 = properties.newInstance();
createIndex( labelName1, propertyKey1 );
createIndex( labelName2, propertyKey2 );
List<Map<String,Object>> serializedList = retryOnStillPopulating(
() -> gen.get().expectedStatus( 200 ).get( getSchemaIndexUri() ).entity() );
Map<String,Object> index1 = new HashMap<>();
index1.put( "label", labelName1 );
index1.put( "labels", singletonList( labelName1 ) );
index1.put( "property_keys", singletonList( propertyKey1 ) );
Map<String,Object> index2 = new HashMap<>();
index2.put( "label", labelName2 );
index2.put( "labels", singletonList( labelName2 ) );
index2.put( "property_keys", singletonList( propertyKey2 ) );
assertThat( serializedList, hasItems( index1, index2 ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldGet404WhenRequestingIndexUriWhichDoesntExist()
{
String key = "key3";
String value = "value";
String indexName = indexes.newInstance();
String indexUri = functionalTestHelper.nodeIndexUri() + indexName + "/" + key + "/" + value;
JaxRsResponse response = RestRequest.req()
.get( indexUri );
assertEquals( Status.NOT_FOUND.getStatusCode(), response.getStatus() );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldGet404WhenDeletingNonExistentIndex()
{
final String indexName = indexes.newInstance();
String indexUri = functionalTestHelper.nodeIndexUri() + indexName;
JaxRsResponse response = RestRequest.req().delete( indexUri );
assertEquals( Status.NOT_FOUND.getStatusCode(), response.getStatus() );
}
代码示例来源:origin: neo4j/neo4j
/**
* Create an index for a label and property key which already exists.
*/
@Test
public void create_existing_index()
{
String labelName = labels.newInstance();
String propertyKey = properties.newInstance();
createIndex( labelName, propertyKey );
Map<String,Object> definition = map( "property_keys", singletonList( propertyKey ) );
gen.get()
.expectedStatus( 409 )
.payload( createJsonFrom( definition ) )
.post( getSchemaIndexLabelUri( labelName ) );
}
代码示例来源:origin: neo4j/neo4j
/**
* Create an index for a label and property key which already exists.
*/
@Test
public void create_existing_constraint()
{
String labelName = labels.newInstance();
String propertyKey = properties.newInstance();
createLabelUniquenessPropertyConstraint( labelName, propertyKey );
Map<String, Object> definition = map( "property_keys", singletonList( propertyKey ) );
gen.get().expectedStatus( 409 ).payload( createJsonFrom( definition ) )
.post( getSchemaConstraintLabelUniquenessUri( labelName ) ).entity();
}
代码示例来源:origin: neo4j/neo4j
@Documented( "Get a specific uniqueness constraint.\n" +
"Get a specific uniqueness constraint for a label and a property." )
@Test
@GraphDescription.Graph( nodes = {} )
public void getLabelUniquenessPropertyConstraint() throws JsonParseException
{
data.get();
String labelName = labels.newInstance();
String propertyKey = properties.newInstance();
createLabelUniquenessPropertyConstraint( labelName, propertyKey );
String result = gen.get().expectedStatus( 200 ).get(
getSchemaConstraintLabelUniquenessPropertyUri( labelName, propertyKey ) ).entity();
List<Map<String, Object>> serializedList = jsonToList( result );
Map<String, Object> constraint = new HashMap<>( );
constraint.put( "type", ConstraintType.UNIQUENESS.name() );
constraint.put( "label", labelName );
constraint.put( "property_keys", singletonList( propertyKey ) );
assertThat( serializedList, hasItem( constraint ) );
}
代码示例来源:origin: neo4j/neo4j
@SuppressWarnings( "unchecked" )
@Documented( "Get all uniqueness constraints for a label." )
@Test
@GraphDescription.Graph( nodes = {} )
public void getLabelUniquenessPropertyConstraints() throws JsonParseException
{
data.get();
String labelName = labels.newInstance();
String propertyKey1 = properties.newInstance();
String propertyKey2 = properties.newInstance();
createLabelUniquenessPropertyConstraint( labelName, propertyKey1 );
createLabelUniquenessPropertyConstraint( labelName, propertyKey2 );
String result = gen.get().expectedStatus( 200 ).get( getSchemaConstraintLabelUniquenessUri( labelName ) ).entity();
List<Map<String, Object>> serializedList = jsonToList( result );
Map<String, Object> constraint1 = new HashMap<>( );
constraint1.put( "type", ConstraintType.UNIQUENESS.name() );
constraint1.put( "label", labelName );
constraint1.put( "property_keys", singletonList( propertyKey1 ) );
Map<String, Object> constraint2 = new HashMap<>( );
constraint2.put( "type", ConstraintType.UNIQUENESS.name() );
constraint2.put( "label", labelName );
constraint2.put( "property_keys", singletonList( propertyKey2 ) );
assertThat( serializedList, hasItems( constraint1, constraint2 ) );
}
代码示例来源:origin: neo4j/neo4j
@Documented( "Create index.\n" +
"\n" +
"This will start a background job in the database that will create and populate the index.\n" +
"You can check the status of your index by listing all the indexes for the relevant label." )
@Test
@GraphDescription.Graph( nodes = {} )
public void create_index() throws JsonParseException
{
data.get();
String labelName = labels.newInstance();
String propertyKey = properties.newInstance();
Map<String,Object> definition = map( "property_keys", singletonList( propertyKey ) );
String result = gen.get()
.expectedStatus( 200 )
.payload( createJsonFrom( definition ) )
.post( getSchemaIndexLabelUri( labelName ) )
.entity();
Map<String,Object> serialized = jsonToMap( result );
Map<String,Object> index = new HashMap<>();
index.put( "label", labelName );
index.put( "labels", singletonList( labelName ) );
index.put( "property_keys", singletonList( propertyKey ) );
assertThat( serialized, equalTo( index ) );
}
代码示例来源:origin: neo4j/neo4j
@Documented( "Create uniqueness constraint.\n" +
"Create a uniqueness constraint on a property." )
@Test
@GraphDescription.Graph( nodes = {} )
public void createPropertyUniquenessConstraint() throws JsonParseException
{
data.get();
String labelName = labels.newInstance();
String propertyKey = properties.newInstance();
Map<String, Object> definition = map( "property_keys", singletonList( propertyKey ) );
String result = gen.get().expectedStatus( 200 ).payload( createJsonFrom( definition ) ).post(
getSchemaConstraintLabelUniquenessUri( labelName ) ).entity();
Map<String, Object> serialized = jsonToMap( result );
Map<String, Object> constraint = new HashMap<>( );
constraint.put( "type", ConstraintType.UNIQUENESS.name() );
constraint.put( "label", labelName );
constraint.put( "property_keys", singletonList( propertyKey ) );
assertThat( serialized, equalTo( constraint ) );
}
代码示例来源:origin: neo4j/neo4j
@Documented( "List indexes for a label." )
@Test
@GraphDescription.Graph( nodes = {} )
public void get_indexes_for_label() throws Exception
{
data.get();
String labelName = labels.newInstance();
String propertyKey = properties.newInstance();
createIndex( labelName, propertyKey );
Map<String,Object> definition = map( "property_keys", singletonList( propertyKey ) );
List<Map<String,Object>> serializedList = retryOnStillPopulating( () -> gen.get()
.expectedStatus( 200 )
.payload( createJsonFrom( definition ) )
.get( getSchemaIndexLabelUri( labelName ) )
.entity() );
Map<String,Object> index = new HashMap<>();
index.put( "label", labelName );
index.put( "labels", singletonList( labelName ) );
index.put( "property_keys", singletonList( propertyKey ) );
assertThat( serializedList, hasItem( index ) );
}
代码示例来源:origin: neo4j/neo4j
@SuppressWarnings( "unchecked" )
@Documented( "Get all constraints for a label." )
@Test
@GraphDescription.Graph( nodes = {} )
public void getLabelPropertyConstraints() throws JsonParseException
{
data.get();
String labelName = labels.newInstance();
String propertyKey1 = properties.newInstance();
createLabelUniquenessPropertyConstraint( labelName, propertyKey1 );
String result = gen.get().expectedStatus( 200 ).get( getSchemaConstraintLabelUri( labelName ) ).entity();
List<Map<String, Object>> serializedList = jsonToList( result );
Map<String, Object> constraint1 = new HashMap<>( );
constraint1.put( "type", ConstraintType.UNIQUENESS.name() );
constraint1.put( "label", labelName );
constraint1.put( "property_keys", singletonList( propertyKey1 ) );
assertThat( serializedList, hasItems( constraint1 ) );
}
代码示例来源:origin: neo4j/neo4j
@SuppressWarnings( "unchecked" )
@Documented( "Get all constraints." )
@Test
@GraphDescription.Graph( nodes = {} )
public void get_constraints() throws JsonParseException
{
data.get();
String labelName1 = labels.newInstance();
String propertyKey1 = properties.newInstance();
createLabelUniquenessPropertyConstraint( labelName1, propertyKey1 );
String result = gen.get().expectedStatus( 200 ).get( getSchemaConstraintUri() ).entity();
List<Map<String,Object>> serializedList = jsonToList( result );
Map<String, Object> constraint1 = new HashMap<>();
constraint1.put( "type", ConstraintType.UNIQUENESS.name() );
constraint1.put( "label", labelName1 );
constraint1.put( "property_keys", singletonList( propertyKey1 ) );
assertThat( serializedList, hasItems( constraint1 ) );
}
代码示例来源:origin: neo4j/neo4j
@Test
public void shouldRespondWith400WhenSendingCorruptJson()
{
final String indexName = indexes.newInstance();
helper.createRelationshipIndex( indexName );
final String corruptJson = "{[}";
JaxRsResponse response = RestRequest.req().post( functionalTestHelper.indexRelationshipUri( indexName ),
corruptJson );
assertEquals( 400, response.getStatus() );
}
内容来源于网络,如有侵权,请联系作者删除!