本文整理汇总了Java中org.neo4j.server.rest.repr.OutputFormat类的典型用法代码示例。如果您正苦于以下问题:Java OutputFormat类的具体用法?Java OutputFormat怎么用?Java OutputFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OutputFormat类属于org.neo4j.server.rest.repr包,在下文中一共展示了OutputFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldDeleteUserAndReturnSuccess
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldDeleteUserAndReturnSuccess() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( NEO4J_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
when( authManager.deleteUser( "foo" ) ).thenReturn( true );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserDeleteService userDeleteService = new UserDeleteService( authManager, outputFormat );
// When
Response response = userDeleteService.deleteUser( "foo", req );
// Then
assertThat( response.getStatus(), equalTo( 200 ) );
verify( authManager ).deleteUser( "foo" );
}
示例2: shouldReturn404WhenDeletingUserIfNotAuthenticated
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn404WhenDeletingUserIfNotAuthenticated() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( null );
AuthManager authManager = mock( AuthManager.class );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserDeleteService userDeleteService = new UserDeleteService( authManager, outputFormat );
// When
Response response = userDeleteService.deleteUser( "foo", req );
// Then
assertThat( response.getStatus(), equalTo( 404 ) );
}
示例3: shouldReturn404WhenDeletingUserIfNotNeo4jUser
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn404WhenDeletingUserIfNotNeo4jUser() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( BAD_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserDeleteService userDeleteService = new UserDeleteService( authManager, outputFormat );
// When
Response response = userDeleteService.deleteUser( "foo", req );
// Then
assertThat( response.getStatus(), equalTo( 404 ) );
verifyZeroInteractions( authManager );
}
示例4: shouldReturn404WhenDeletingInvalidUser
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn404WhenDeletingInvalidUser() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( NEO4J_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
when( authManager.deleteUser( "foo" ) ).thenReturn( false );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserDeleteService userDeleteService = new UserDeleteService( authManager, outputFormat );
// When
Response response = userDeleteService.deleteUser( "foo", req );
// Then
assertThat( response.getStatus(), equalTo( 404 ) );
verify( authManager ).deleteUser( "foo" );
}
示例5: shouldCreateUserAndReturnSuccess
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldCreateUserAndReturnSuccess() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( NEO4J_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
when( authManager.newUser( "foo", "bar", true ) ).thenReturn( FOO_USER );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserAddService userAddService = new UserAddService( authManager, new JsonFormat(), outputFormat );
// When
Response response = userAddService.createUser( "foo", req, "{ \"password\" : \"bar\" }" );
// Then
assertThat( response.getStatus(), equalTo( 200 ) );
verify( authManager ).newUser( "foo", "bar", true );
}
示例6: shouldReturn404WhenCreatingUserIfNotAuthenticated
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn404WhenCreatingUserIfNotAuthenticated() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( null );
AuthManager authManager = mock( AuthManager.class );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserAddService userAddService = new UserAddService( authManager, new JsonFormat(), outputFormat );
// When
Response response = userAddService.createUser( "foo", req, "{ \"password\" : \"bar\" }" );
// Then
assertThat( response.getStatus(), equalTo( 404 ) );
}
示例7: shouldReturn404WhenCreatingUserIfNotNeo4jUser
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn404WhenCreatingUserIfNotNeo4jUser() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( BAD_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserAddService userAddService = new UserAddService( authManager, new JsonFormat(), outputFormat );
// When
Response response = userAddService.createUser( "foo", req, "{ \"password\" : \"bar\" }" );
// Then
assertThat( response.getStatus(), equalTo( 404 ) );
verifyZeroInteractions( authManager );
}
示例8: shouldReturn400IfPayloadIsInvalid
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn400IfPayloadIsInvalid() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( NEO4J_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
InputFormat inputFormat = mock( InputFormat.class );
when( inputFormat.readMap( anyString() )).thenThrow( new BadInputException( "Barf" ) );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserAddService userAddService = new UserAddService( authManager, inputFormat, outputFormat );
// When
Response response = userAddService.createUser( "foo", req, "{ \"password\" : \"bar\" }" );
// Then
assertThat( response.getStatus(), equalTo( 400 ) );
String json = new String( (byte[]) response.getEntity() );
assertNotNull( json );
assertThat( json, containsString( "\"code\" : \"Neo.ClientError.Request.InvalidFormat\"" ) );
}
示例9: shouldReturn422IfMissingPassword
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn422IfMissingPassword() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( NEO4J_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserAddService userAddService = new UserAddService( authManager, new JsonFormat(), outputFormat );
// When
Response response = userAddService.createUser( "foo", req, "{ \"unknown\" : \"unknown\" }" );
// Then
assertThat( response.getStatus(), equalTo( 422 ) );
String json = new String( (byte[]) response.getEntity() );
assertNotNull( json );
assertThat( json, containsString( "\"code\" : \"Neo.ClientError.Request.InvalidFormat\"" ) );
assertThat( json, containsString( "\"message\" : \"Required parameter 'password' is missing.\"" ) );
}
示例10: shouldReturn422IfInvalidPasswordType
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn422IfInvalidPasswordType() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( NEO4J_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserAddService userAddService = new UserAddService( authManager, new JsonFormat(), outputFormat );
// When
Response response = userAddService.createUser( "foo", req, "{ \"password\" : 1 }" );
// Then
assertThat( response.getStatus(), equalTo( 422 ) );
String json = new String( (byte[]) response.getEntity() );
assertNotNull( json );
assertThat( json, containsString( "\"code\" : \"Neo.ClientError.Request.InvalidFormat\"" ) );
assertThat( json, containsString( "\"message\" : \"Expected 'password' to be a string.\"" ) );
}
示例11: shouldReturn422IfEmptyPassword
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn422IfEmptyPassword() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( NEO4J_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserAddService userAddService = new UserAddService( authManager, new JsonFormat(), outputFormat );
// When
Response response = userAddService.createUser( "foo", req, "{ \"password\" : \"\" }" );
// Then
assertThat( response.getStatus(), equalTo( 422 ) );
String json = new String( (byte[]) response.getEntity() );
assertNotNull( json );
assertThat( json, containsString( "\"code\" : \"Neo.ClientError.Request.Invalid\"" ) );
assertThat( json, containsString( "\"message\" : \"Password cannot be empty.\"" ) );
}
示例12: shouldReturn500IfDuplicateUser
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Test
public void shouldReturn500IfDuplicateUser() throws Exception
{
// Given
HttpServletRequest req = mock( HttpServletRequest.class );
when( req.getUserPrincipal() ).thenReturn( NEO4J_PRINCIPLE );
AuthManager authManager = mock( AuthManager.class );
when( authManager.newUser( "foo", "bar", true ) ).thenThrow( new IllegalUsernameException("The specified user already exists") );
OutputFormat outputFormat = new EntityOutputFormat( new JsonFormat(), new URI( "http://www.example.com" ), null );
UserAddService userAddService = new UserAddService( authManager, new JsonFormat(), outputFormat );
// When
Response response = userAddService.createUser( "foo", req, "{ \"password\" : \"bar\" }" );
// Then
assertThat( response.getStatus(), equalTo( 500 ) );
String json = new String( (byte[]) response.getEntity() );
assertNotNull( json );
assertThat( json, containsString( "\"code\" : \"Neo.ClientError.Request.Invalid\"" ) );
assertThat( json, containsString( "\"message\" : \"The specified user already exists\"" ) );
}
示例13: UserAddService
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
public UserAddService( @Context AuthManager authManager,
@Context InputFormat input, @Context OutputFormat output )
{
this.authManager = authManager;
this.input = input;
this.output = output;
}
示例14: setUp
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
@Before
public void setUp() throws Exception
{
GraphDatabaseService db = new TestGraphDatabaseFactory().newImpermanentDatabase();
this.database = new WrappedDatabase((AbstractGraphDatabase) db);
this.consoleService = new ConsoleService( this, database, new OutputFormat( new JsonFormat(), uri, null ) );
}
示例15: UserDeleteService
import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
public UserDeleteService( @Context AuthManager authManager,
@Context OutputFormat output )
{
this.authManager = authManager;
this.output = output;
}