本文整理匯總了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;
}