public Service(Cursor cursor) { int idColumn = cursor.getColumnIndex(ID); int serviceProviderColumn = cursor.getColumnIndex(SERVICE_PROVIDER); int serviceIdColumn = cursor.getColumnIndex(SERVICE_ID); int accountIDColumn = cursor.getColumnIndex(ACCOUNT_ID); int updateColumn = cursor.getColumnIndex(UPDATED); int statusColumn = cursor.getColumnIndex(STATUS); int dataColumn = cursor.getColumnIndex(DATA); id = cursor.getInt(idColumn); identifier = new ServiceIdentifier( cursor.getString(serviceProviderColumn), cursor.getString(serviceIdColumn)); accountID = cursor.getInt(accountIDColumn); long l = cursor.getLong(updateColumn); lastUpdate = l == -1 ? null : new Date(l); updateStatus = UpdateStatus.values()[cursor.getInt(statusColumn)]; // Plan, serviceType and metricGroups come from Data try { readFrom(new JSONObject(cursor.getString(dataColumn))); } catch (JSONException e) { Log.e("service", "Error procesisng JSON", e); throw new IllegalArgumentException("Error JSON processing"); } }
public static UpdateStatus statusFromString(String stringStatus) { for (UpdateStatus status : UpdateStatus.values()) { if (status.name().equalsIgnoreCase(stringStatus)) { return status; } } return null; }
@Test public void getStatus() { for (final UpdateStatus updateStatus : UpdateStatus.values()) { assertNotNull(updateStatus.getStatus()); } }