當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。