.grantPermissions(Manifest.permission.ACCESS_NETWORK_STATE); Parse.Configuration configuration = new Parse.Configuration.Builder(RuntimeEnvironment.application) .applicationId(BuildConfig.APPLICATION_ID) .server("https://api.parse.com/1") .enableLocalDataStore() .build(); ParsePlugins plugins = ParseTestUtils.mockParsePlugins(configuration); JSONObject mockResponse = new JSONObject();
@Override public void onCreate() { super.onCreate(); // Enable Local Datastore. Parse.enableLocalDatastore(this); // Add your initialization code here Parse.initialize(new Parse.Configuration.Builder(getApplicationContext()) .applicationId("aghr56hFHJTefFGG65") .clientKey(null) .server("http://uberclone5599.herokuapp.com/parse/") .build() ); //enable our AutomaticUser ParseUser.enableAutomaticUser(); ParseACL defaultACL = new ParseACL(); // Optionally enable public read access. // defaultACL.setPublicReadAccess(true); ParseACL.setDefaultACL(defaultACL, true); } }
@Override public void onCreate() { super.onCreate(); // Required - Initialize the Parse SDK Parse.Configuration configuration = new Parse.Configuration.Builder(this) .build(); Parse.initialize(configuration); Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG); ParseFacebookUtils.initialize(this); // Optional - If you don't want to allow Twitter login, you can // remove this line (and other related ParseTwitterUtils calls) ParseTwitterUtils.initialize(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret)); } }
@Override public void onCreate() { super.onCreate(); // Required - Initialize the Parse SDK Parse.Configuration configuration = new Parse.Configuration.Builder(this) .build(); Parse.initialize(configuration); Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG); ParseFacebookUtils.initialize(this); // Optional - If you don't want to allow Twitter login, you can // remove this line (and other related ParseTwitterUtils calls) ParseTwitterUtils.initialize(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret)); } }
@Override public void onCreate() { super.onCreate(); // Required - Initialize the Parse SDK Parse.Configuration configuration = new Parse.Configuration.Builder(this) .build(); Parse.initialize(configuration); Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG); ParseFacebookUtils.initialize(this); // Optional - If you don't want to allow Twitter login, you can // remove this line (and other related ParseTwitterUtils calls) ParseTwitterUtils.initialize(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret)); } }
@Override public void onCreate() { super.onCreate(); // Required - Initialize the Parse SDK Parse.Configuration configuration = new Parse.Configuration.Builder(this) .build(); Parse.initialize(configuration); Parse.setLogLevel(Parse.LOG_LEVEL_DEBUG); ParseFacebookUtils.initialize(this); // Optional - If you don't want to allow Twitter login, you can // remove this line (and other related ParseTwitterUtils calls) ParseTwitterUtils.initialize(getString(R.string.twitter_consumer_key), getString(R.string.twitter_consumer_secret)); } }
@Override public void onCreate() { super.onCreate(); Parse.Configuration configuration = new Parse.Configuration.Builder(this) .build(); Parse.initialize(configuration); } }
Parse.Configuration configuration = new Parse.Configuration.Builder(RuntimeEnvironment.application) .build(); ParsePlugins plugins = mock(ParsePlugins.class); when(plugins.configuration()).thenReturn(configuration);
@Test public void testFailingDelete() throws Exception { ParseRESTCommand.server = new URL("https://api.parse.com/1"); Parse.Configuration configuration = new Parse.Configuration.Builder(RuntimeEnvironment.application) .build(); ParsePlugins plugins = mock(ParsePlugins.class); when(plugins.configuration()).thenReturn(configuration); when(plugins.applicationContext()).thenReturn(RuntimeEnvironment.application); ParsePlugins.set(plugins); JSONObject mockResponse = new JSONObject(); mockResponse.put("code", 141); mockResponse.put("error", "Delete is not allowed"); ParseHttpClient restClient = ParseTestUtils.mockParseHttpClientWithResponse(mockResponse, 400, "Bad Request"); when(plugins.restClient()).thenReturn(restClient); ParseObject.State state = mock(ParseObject.State.class); when(state.className()).thenReturn("TestObject"); when(state.objectId()).thenReturn("test_id"); when(state.keySet()).thenReturn(Collections.singleton("key")); when(state.get("key")).thenReturn("data"); ParseObject object = ParseObject.from(state); thrown.expect(ParseException.class); thrown.expectMessage("Delete is not allowed"); object.delete(); }
@Test public void testBuilderServerMissingSlashURL() { Parse.Configuration.Builder builder = new Parse.Configuration.Builder(null); builder.server("http://myserver.com/missingslash"); Parse.Configuration configuration = builder.build(); assertEquals(configuration.server, "http://myserver.com/missingslash/"); } }
@Test public void testBuilderServerURL() { Parse.Configuration.Builder builder = new Parse.Configuration.Builder(null); builder.server("http://myserver.com/parse/"); Parse.Configuration configuration = builder.build(); assertEquals(configuration.server, "http://myserver.com/parse/"); }
@Before public void setUp() throws Exception { super.setUp(); Parse.Configuration configuration = new Parse.Configuration.Builder(null) .applicationId("1234") .build(); ParsePlugins.initialize(null, configuration); }
@Test public void testBuilder() { Parse.Configuration.Builder builder = new Parse.Configuration.Builder(null); builder.applicationId("foo"); builder.clientKey("bar"); builder.enableLocalDataStore(); Parse.Configuration configuration = builder.build(); assertNull(configuration.context); assertEquals(configuration.applicationId, "foo"); assertEquals(configuration.clientKey, "bar"); assertEquals(configuration.localDataStoreEnabled, true); }