当前位置: 首页>>代码示例>>Java>>正文


Java OutputFormat类代码示例

本文整理汇总了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" );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:21,代码来源:UserDeleteServiceTest.java

示例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 ) );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:19,代码来源:UserDeleteServiceTest.java

示例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 );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:20,代码来源:UserDeleteServiceTest.java

示例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" );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:21,代码来源:UserDeleteServiceTest.java

示例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 );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:21,代码来源:UserAddServiceTest.java

示例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 ) );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:19,代码来源:UserAddServiceTest.java

示例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 );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:20,代码来源:UserAddServiceTest.java

示例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\"" ) );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:25,代码来源:UserAddServiceTest.java

示例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.\"" ) );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:23,代码来源:UserAddServiceTest.java

示例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.\"" ) );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:23,代码来源:UserAddServiceTest.java

示例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.\"" ) );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:23,代码来源:UserAddServiceTest.java

示例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\"" ) );
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:24,代码来源:UserAddServiceTest.java

示例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;
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:8,代码来源:UserAddService.java

示例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 ) );
}
 
开发者ID:neo4j-contrib,项目名称:gremlin-plugin,代码行数:8,代码来源:GremlinConsoleServiceTest.java

示例15: UserDeleteService

import org.neo4j.server.rest.repr.OutputFormat; //导入依赖的package包/类
public UserDeleteService( @Context AuthManager authManager,
    @Context OutputFormat output )
{
    this.authManager = authManager;
    this.output = output;
}
 
开发者ID:rbramley,项目名称:neo4j-useradd,代码行数:7,代码来源:UserDeleteService.java


注:本文中的org.neo4j.server.rest.repr.OutputFormat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。