NCMBInstallationService extends NCMBService { public NCMBInstallation fetchInstallation(String objectId) throws NCMBException { if (objectId == null) { throw new NCMBException(new IllegalArgumentException("objectId is must not be null.")); } RequestParams request = createRequestParams(objectId, null, null, NCMBRequest.HTTP_METHOD_GET); NCMBResponse response = sendRequest(request); if (response.statusCode != HTTP_STATUS_INSTALLATION_GOTTEN) { throw new NCMBException(NCMBException.NOT_EFFICIENT_VALUE, "Getting failed."); } return new NCMBInstallation(response.responseData); } NCMBInstallationService(NCMBContext context); JSONObject createInstallation(String registrationId, JSONObject params); void createInstallationInBackground(String registrationId, JSONObject params, final ExecuteServiceCallback callback); JSONObject updateInstallation(String objectId, JSONObject params); void updateInstallationInBackground(final String objectId, JSONObject params, final ExecuteServiceCallback callback); void deleteInstallation(String objectId); void deleteInstallationInBackground(final String objectId, DoneCallback callback); NCMBInstallation fetchInstallation(String objectId); void fetchInstallationInBackground(String objectId, final FetchCallback callback); List searchInstallation(JSONObject conditions); void searchInstallationInBackground(JSONObject conditions, final SearchInstallationCallback callback); static final String SERVICE_PATH; static final int HTTP_STATUS_INSTALLATION_CREATED; static final int HTTP_STATUS_INSTALLATION_UPDATED; static final int HTTP_STATUS_INSTALLATION_DELETED; static final int HTTP_STATUS_INSTALLATION_GOTTEN; }
@Test public void fetchInstallation() throws Exception { NCMBInstallationService installationService = (NCMBInstallationService) NCMB.factory(NCMB.ServiceType.INSTALLATION); NCMBInstallation installation = installationService.fetchInstallation("7FrmPTBKSNtVjajm"); Assert.assertEquals("7FrmPTBKSNtVjajm", installation.getString("objectId")); Assert.assertEquals("value", installation.getString("key")); }
@Test public void installationPropertyCheck() throws Exception { NCMBInstallationService installationService = (NCMBInstallationService) NCMB.factory(NCMB.ServiceType.INSTALLATION); NCMBInstallation installation = installationService.fetchInstallation("7FrmPTBKSNtVjajm"); Assert.assertEquals("7FrmPTBKSNtVjajm", installation.getObjectId()); Assert.assertEquals(APP_NAME, installation.getApplicationName()); Assert.assertEquals(APP_VERSION, installation.getAppVersion()); Assert.assertEquals("xxxxxxxxxxxxxxxxxxx", installation.getLocalDeviceToken()); Assert.assertEquals("android", installation.getDeviceType()); Assert.assertEquals(NCMB.SDK_VERSION, installation.getSDKVersion()); Assert.assertEquals("Asia/Tokyo", installation.getTimeZone()); Assert.assertEquals(0, installation.getBadge()); JSONArray resultList = new JSONArray("[Ch1]"); Assert.assertEquals(resultList, installation.getChannels()); DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.JAPAN); format.setTimeZone(new SimpleTimeZone(0, "GMT")); Date resultDate = format.parse("2014-06-03T11:28:30.348Z"); Assert.assertEquals(resultDate, installation.getCreateDate()); Assert.assertEquals(resultDate, installation.getUpdateDate()); Assert.assertEquals("value", installation.getValue("key")); }