@Test public void should_test_observable_interval() { TestScheduler scheduler = new TestScheduler(); final List<Long> result = new ArrayList<>(); Observable.interval(1, TimeUnit.SECONDS, scheduler) .take(5) .subscribe(new Action1<Long>() { @Override public void call(Long aLong) { result.add(aLong); } }); assertTrue(result.isEmpty()); scheduler.advanceTimeBy(2, TimeUnit.SECONDS); assertEquals(2, result.size()); scheduler.advanceTimeBy(10, TimeUnit.SECONDS); assertEquals(5, result.size()); }
/** * 判断缓存的byte数据是否到期 * * @param data * @return true:到期了 false:还没有到期 */ private static boolean isDue(byte[] data) { String[] strs = getDateInfoFromDate(data); if (strs != null && strs.length == 2) { String saveTimeStr = strs[0]; while (saveTimeStr.startsWith("0")) { saveTimeStr = saveTimeStr.substring(1, saveTimeStr.length()); } long saveTime = Long.parseLong(saveTimeStr); long deleteAfter = Long.parseLong(strs[1]); if (System.currentTimeMillis() > saveTime + deleteAfter * 1000) { return true; } } return false; }
public BgReadingMessage(Long timestamp, Double time_since_sensor_started, Double raw_data, Double filtered_data, Double age_adjusted_raw_value, Boolean calibration_flag, Double calculated_value, Double filtered_calculated_value, Double calculated_value_slope, Double a, Double b, Double c, Double ra, Double rb, Double rc, String uuid, String calibration_uuid, String sensor_uuid, Boolean ignoreforstats, Double raw_calculated, Boolean hide_slope, String noise, ByteString unknownFields) { super(ADAPTER, unknownFields); this.timestamp = timestamp; this.time_since_sensor_started = time_since_sensor_started; this.raw_data = raw_data; this.filtered_data = filtered_data; this.age_adjusted_raw_value = age_adjusted_raw_value; this.calibration_flag = calibration_flag; this.calculated_value = calculated_value; this.filtered_calculated_value = filtered_calculated_value; this.calculated_value_slope = calculated_value_slope; this.a = a; this.b = b; this.c = c; this.ra = ra; this.rb = rb; this.rc = rc; this.uuid = uuid; this.calibration_uuid = calibration_uuid; this.sensor_uuid = sensor_uuid; this.ignoreforstats = ignoreforstats; this.raw_calculated = raw_calculated; this.hide_slope = hide_slope; this.noise = noise; }
ReviewInput(long stars, Input<Long> nullableIntFieldWithDefaultValue, Input<String> commentary, @Nonnull ColorInput favoriteColor, Input<Episode> enumWithDefaultValue, Input<Episode> nullableEnum, Input<List<Object>> listOfCustomScalar, Input<Object> customScalar, Input<List<Episode>> listOfEnums, Input<List<Long>> listOfInt, Input<List<String>> listOfString, Input<Boolean> booleanWithDefaultValue) { this.stars = stars; this.nullableIntFieldWithDefaultValue = nullableIntFieldWithDefaultValue; this.commentary = commentary; this.favoriteColor = favoriteColor; this.enumWithDefaultValue = enumWithDefaultValue; this.nullableEnum = nullableEnum; this.listOfCustomScalar = listOfCustomScalar; this.customScalar = customScalar; this.listOfEnums = listOfEnums; this.listOfInt = listOfInt; this.listOfString = listOfString; this.booleanWithDefaultValue = booleanWithDefaultValue; }
ReviewInput(long stars, Input<Long> nullableIntFieldWithDefaultValue, Input<String> commentary, @Nonnull ColorInput favoriteColor, Input<Episode> enumWithDefaultValue, Input<Episode> nullableEnum, Input<List<Date>> listOfCustomScalar, Input<Date> customScalar, Input<List<Episode>> listOfEnums, Input<List<Long>> listOfInt, Input<List<String>> listOfString, Input<Boolean> booleanWithDefaultValue) { this.stars = stars; this.nullableIntFieldWithDefaultValue = nullableIntFieldWithDefaultValue; this.commentary = commentary; this.favoriteColor = favoriteColor; this.enumWithDefaultValue = enumWithDefaultValue; this.nullableEnum = nullableEnum; this.listOfCustomScalar = listOfCustomScalar; this.customScalar = customScalar; this.listOfEnums = listOfEnums; this.listOfInt = listOfInt; this.listOfString = listOfString; this.booleanWithDefaultValue = booleanWithDefaultValue; }
public Data(@Nullable String graphQlString, @Nullable String graphQlIdNullable, @Nonnull String graphQlIdNonNullable, @Nullable Long graphQlIntNullable, long graphQlIntNonNullable, @Nullable Double graphQlFloatNullable, double graphQlFloatNonNullable, @Nullable Boolean graphQlBooleanNullable, boolean graphQlBooleanNonNullable, @Nullable List<Long> graphQlListOfInt, @Nullable List<GraphQlListOfObject> graphQlListOfObjects) { this.graphQlString = Optional.fromNullable(graphQlString); this.graphQlIdNullable = Optional.fromNullable(graphQlIdNullable); this.graphQlIdNonNullable = Utils.checkNotNull(graphQlIdNonNullable, "graphQlIdNonNullable == null"); this.graphQlIntNullable = Optional.fromNullable(graphQlIntNullable); this.graphQlIntNonNullable = graphQlIntNonNullable; this.graphQlFloatNullable = Optional.fromNullable(graphQlFloatNullable); this.graphQlFloatNonNullable = graphQlFloatNonNullable; this.graphQlBooleanNullable = Optional.fromNullable(graphQlBooleanNullable); this.graphQlBooleanNonNullable = graphQlBooleanNonNullable; this.graphQlListOfInt = Optional.fromNullable(graphQlListOfInt); this.graphQlListOfObjects = Optional.fromNullable(graphQlListOfObjects); }
@Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { switch(code) { case TRANSACT_methodWithLongParameter: { data.enforceInterface(this.getInterfaceDescriptor()); final Long longParameterTmp; if (data.readByte() == -1) { longParameterTmp = null; } else { longParameterTmp = data.readLong(); } delegate.methodWithLongParameter(longParameterTmp); reply.writeNoException(); return true; } } return super.onTransact(code, data, reply, flags); }
@Override public void methodWithLongParameter(Long longParameter) throws RemoteException { Parcel data = Parcel.obtain(); Parcel reply = Parcel.obtain(); try { data.writeInterfaceToken(LongTest$$AidlServerImpl.DESCRIPTOR); if (longParameter == null) { data.writeByte((byte) -1); } else { data.writeByte((byte) 0); data.writeLong(longParameter); } delegate.transact(LongTest$$AidlServerImpl.TRANSACT_methodWithLongParameter, data, reply, 0); reply.readException(); } finally { data.recycle(); reply.recycle(); } }
/** * Performs a query for a trinityprocessortest.full.MyEntity with given id. * If no such instance is found, null is returned. * * @param id The id of the instance to find. * @return The trinityprocessortest.full.MyEntity with given id, or null if it doesn't exist. */ @Override public MyEntity findById(final Long id) { if (id == null) { return null; } MyEntity result = null; Cursor cursor = mDatabase.query("entities", null, "id=?", new String[] {String.valueOf(id)}, null, null, null, "1"); try { if (cursor.moveToFirst()) { result = read(cursor); } } finally{ cursor.close(); } return result; }
@Test public void changeKeyComboCode() { String keyNavigateNext = mContext.getString(R.string.keycombo_shortcut_navigate_next); // Check default key combo code. long defaultKeyComboCode = mDefaultKeyComboModel.getDefaultKeyComboCode(keyNavigateNext); assertEquals(defaultKeyComboCode, mDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext)); // Change key combo code. long newKeyComboCode = KeyComboManager.getKeyComboCode( KeyComboModel.NO_MODIFIER, KeyEvent.KEYCODE_X); mDefaultKeyComboModel.saveKeyComboCode(keyNavigateNext, newKeyComboCode); Map<String, Long> keyComboCodeMap = mDefaultKeyComboModel.getKeyComboCodeMap(); assertEquals(newKeyComboCode, keyComboCodeMap.get(keyNavigateNext).longValue()); assertEquals(newKeyComboCode, mDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext)); assertEquals(newKeyComboCode, mPref.getLong(PREF_KEY_PREFIX + keyNavigateNext, -1)); // Create new DefaultKeyComboModel model and confirm it's loaded. DefaultKeyComboModel newDefaultKeyComboModel = new DefaultKeyComboModel(mContext); assertEquals(newKeyComboCode, newDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext)); }
@Test public void clearKeyComboCode() { String keyNavigateNext = mContext.getString(R.string.keycombo_shortcut_navigate_next); // Check default key combo code. long defaultKeyComboCode = mDefaultKeyComboModel.getDefaultKeyComboCode(keyNavigateNext); assertEquals(defaultKeyComboCode, mDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext)); // Clear key combo code. mDefaultKeyComboModel.clearKeyComboCode(keyNavigateNext); Map<String, Long> keyComboCodeMap = mDefaultKeyComboModel.getKeyComboCodeMap(); assertEquals(KeyComboModel.KEY_COMBO_CODE_UNASSIGNED, keyComboCodeMap.get(keyNavigateNext).longValue()); assertEquals(KeyComboModel.KEY_COMBO_CODE_UNASSIGNED, mDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext)); assertEquals(KeyComboModel.KEY_COMBO_CODE_UNASSIGNED, mPref.getLong(PREF_KEY_PREFIX + keyNavigateNext, -1)); // Create new DefaultKeyComboModel and confirm it's loaded. DefaultKeyComboModel newDefaultKeyComboModel = new DefaultKeyComboModel(mContext); assertEquals(KeyComboModel.KEY_COMBO_CODE_UNASSIGNED, newDefaultKeyComboModel.getKeyComboCodeForKey(keyNavigateNext)); }
public void testFloatNarrowing() { float fmin = Float.NEGATIVE_INFINITY; float fmax = Float.POSITIVE_INFINITY; assertEquals("fmin as long failed", Long.MIN_VALUE, (long) fmin); assertEquals("fmax as long failed", Long.MAX_VALUE, (long) fmax); assertEquals("fmin as int failed", Integer.MIN_VALUE, (int) fmin); assertEquals("fmax as int failed", Integer.MAX_VALUE, (int) fmax); assertEquals("fmin as char failed", Character.MIN_VALUE, (char) fmin); assertEquals("fmax as char failed", Character.MAX_VALUE, (char) fmax); // Surprising values for shorts and bytes, but that's what's specified. assertEquals("fmin as short failed", 0, (short) fmin); assertEquals("fmax as short failed", -1, (short) fmax); assertEquals("fmin as byte failed", 0, (byte) fmin); assertEquals("fmax as byte failed", -1, (byte) fmax); }
void updateGM( long value, String name ) { mApp.mDData.updateGMName( mCIDid, mApp.mCID, name ); String id = Long.toString(mCIDid); // CalibCBlock blk = mApp.mDData.selectGM( mCIDid, mApp.mCID ); mSaveCBlock.setGroup( value ); // if ( mApp.mListRefresh ) { // mDataAdapter.notifyDataSetChanged(); // } else { mSaveTextView.setText( id + " <" + name + "> " + mSaveData ); mSaveTextView.setTextColor( mSaveCBlock.color() ); // mSaveTextView.invalidate(); // updateDisplay( ); // FIXME // } }
@Override public boolean equals(Object obj) { if (obj instanceof TimeDuration) { return milisecond == ((TimeDuration) obj).getMilisecond(); } if (obj instanceof Integer) { return milisecond == ((Integer) obj).intValue(); } if (obj instanceof java.lang.Long) { return milisecond == ((Long) obj).longValue(); } if (obj instanceof Int) { return milisecond == ((Int) obj).getValue(); } return false; }
public HarvestWatcher(Context _context){ Log.d("HarvestWatcher", "created"); journal = new HarvestJournal(_context); reporter = new HarvestReporter(_context); handler = new Handler(); context = _context; // discard initial values because we can not make any // assumptions regarding whether or not these values // were accounted before. Only measure traffic since // the service started. HarvestTrafficStats stats = new HarvestTrafficStats(); Long initialRx = stats.getTotalRxBytes(); Long initialTx = stats.getTotalTxBytes(); trafficJournal = new HarvestTrafficJournal(_context, initialRx, initialTx); }
private void processTraffic() { Log.d("HarvestWatcher", "processTraffic"); if (!trafficJournal.canStore()) { return; } HarvestTrafficStats stats = new HarvestTrafficStats(); Long rx = stats.getTotalRxBytes(); Long tx = stats.getTotalTxBytes(); Log.d("HarvestWatcher", rx.toString()); Log.d("HarvestWatcher", tx.toString()); if (rx == -1L || tx == -1L) { Log.e("HarvestWatcher", "processTraffic: cannot get stats"); return; } trafficJournal.store(rx, tx); }
public void persist(Long started, Long received, Long transmitted) { Log.d(TAG, "persist"); SQLiteDatabase db = this.getWritableDatabase(); Long previousReceived = 0L; Long previousTransmitted = 0L; Cursor cursor = db.rawQuery(QUERY_FIND, new String[] {started.toString()}); if (cursor.moveToFirst()) { previousReceived = Long.parseLong(cursor.getString(1), 10); previousTransmitted = Long.parseLong(cursor.getString(2), 10); } cursor.close(); ContentValues values = new ContentValues(); values.put(COLUMN_STARTED, started); values.put(COLUMN_RECEIVED, received + previousReceived); values.put(COLUMN_TRANSMITTED, transmitted + previousTransmitted); db.replace(TABLE_NAME, null, values); db.close(); }
public List<HarvestTrafficEntry> retrieve(Long started) { Log.d(TAG, "retrieve"); List<HarvestTrafficEntry> entries = new ArrayList<HarvestTrafficEntry>(); SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(QUERY_SELECT, new String[] {started.toString()}); if (cursor.moveToFirst()) { do { HarvestTrafficEntry entry = new HarvestTrafficEntry(); entry.started = Long.parseLong(cursor.getString(0), 10); entry.received = Long.parseLong(cursor.getString(1), 10); entry.transmitted = Long.parseLong(cursor.getString(2), 10); Log.d(TAG, String.format("retrieve: %d %d %d", entry.started, entry.received, entry.transmitted)); entries.add(entry); } while (cursor.moveToNext()); } cursor.close(); db.close(); return entries; }
public void store(Long currentRx, Long currentTx) { Log.d(TAG, "store"); if (currentRx < lastRx || currentTx < lastTx) { Log.d(TAG, "store: Rx or Tx has reset"); currentDeltaRx += currentRx; currentDeltaTx += currentTx; } else { currentDeltaRx += currentRx - lastRx; currentDeltaTx += currentTx - lastTx; } lastRx = currentRx; lastTx = currentTx; lastStored = settings.getRealNowSeconds(); Log.d(TAG, currentDeltaRx.toString()); Log.d(TAG, currentDeltaTx.toString()); }
public void persist(HarvestEntry entry) { Log.d("HarvestStore", "persist"); SQLiteDatabase db = this.getWritableDatabase(); Long previousDuration = 0L; Cursor cursor = db.rawQuery(QUERY_FIND, new String[] {entry.packageName, entry.started.toString()}); if (cursor.moveToFirst()) { previousDuration = Long.parseLong(cursor.getString(2), 10); } cursor.close(); ContentValues values = new ContentValues(); values.put(COLUMN_PACKAGE, entry.packageName); values.put(COLUMN_STARTED, entry.started); values.put(COLUMN_DURATION, entry.duration + previousDuration); db.replace(TABLE_NAME, null, values); db.close(); }
public List<HarvestEntry> retrieve(Long started) { Log.d("HarvestStore", "retrieve"); List<HarvestEntry> entries = new ArrayList<HarvestEntry>(); SQLiteDatabase db = this.getWritableDatabase(); Cursor cursor = db.rawQuery(QUERY_SELECT, new String[] {started.toString()}); if (cursor.moveToFirst()) { do { HarvestEntry entry = new HarvestEntry(cursor.getString(0)); entry.started = Long.parseLong(cursor.getString(1), 10); entry.duration = Long.parseLong(cursor.getString(2), 10); entries.add(entry); } while (cursor.moveToNext()); } cursor.close(); db.close(); return entries; }
@Override @Transactional public Long getOrCreateRunningExecutionPlan(ExecutionPlan executionPlan) { List<RunningExecutionPlan> existingRunningPlans = readByFlowId(executionPlan.getFlowUuid()); //If no running execution plan existsByUuid for this UUID - create new if (CollectionUtils.isEmpty(existingRunningPlans)) { return createNewRunningExecutionPlan(executionPlan); } //If existsByUuid - check if the plans are equal else { for (RunningExecutionPlan existingRunningPlan : existingRunningPlans) { if (existingRunningPlan.getExecutionPlan().getExecutionPlanUuid().equals(executionPlan.getExecutionPlanUuid())){ return existingRunningPlan.getId(); } } return createNewRunningExecutionPlan(executionPlan); } }
private File get(String key) { File file = newFile(key); Long currentTime = System.currentTimeMillis(); //noinspection ResultOfMethodCallIgnored file.setLastModified(currentTime); lastUsageDates.put(file, currentTime); return file; }
private static String createDateInfo(int second) { String currentTime = Long.toString(System.currentTimeMillis()); while (currentTime.length() < 13) { currentTime = "0" + currentTime; } return currentTime + "-" + second + mSeparator; }
private WritableMap serializeLocation(IALocation location) { WritableMap serialized = Arguments.createMap(); serialized.putDouble("latitude", location.getLatitude()); serialized.putDouble("longitude", location.getLongitude()); serialized.putDouble("altitude", location.getAltitude()); serialized.putDouble("bearing", (double) location.getBearing()); serialized.putDouble("accuracy", (double) location.getAccuracy()); serialized.putMap("region", this.serializeRegion(location.getRegion())); serialized.putInt("timestamp", new Long(location.getTime()).intValue()); serialized.putBoolean("hasFloorLevel", location.hasFloorLevel()); serialized.putInt("floorLevel", location.getFloorLevel()); return serialized; }
public BloodTestMessage(Long timestamp, Double mgdl, Long created_timestamp, Long state, String source, String uuid, ByteString unknownFields) { super(ADAPTER, unknownFields); this.timestamp = timestamp; this.mgdl = mgdl; this.created_timestamp = created_timestamp; this.state = state; this.source = source; this.uuid = uuid; }
public long getPreviousIndex() { current --; if (current<0) return 0; Long number = (Long)index.get(current); return number.longValue(); }
public FriendsConnection1(@Nonnull String __typename, @Nullable Long totalCount, @Nullable List<Edge1> edges, @Nonnull PageInfo1 pageInfo) { this.__typename = Utils.checkNotNull(__typename, "__typename == null"); this.totalCount = Optional.fromNullable(totalCount); this.edges = Optional.fromNullable(edges); this.pageInfo = Utils.checkNotNull(pageInfo, "pageInfo == null"); }
@Override public void method(final int i, final Long l) { executor.execute(new Runnable() { @Override() public void run() { decorated.method(i, l); } }); }
public void execute(DelegateExecution execution) throws Exception { Long number1 = (Long) execution.getVariable("number1"); Long number2 = (Long) execution.getVariable("number2"); Long result = number1 + number2; execution.setVariable("result", "" + result); }
public String remove(Object key) { String val = null; val = this.get(key); if(val!=null) { deleteKeys.add((Long)key); this.mostRecentlyUsed.remove((Long)key); this.mostRecentlyUsedMap.remove((Long)key); } /*}*/ return val; }
private void checkRows(List<Row> actual, long expected[][]) { List<List<Long>> actualList = new ArrayList<>(); for (Row row : actual) actualList.add(Arrays.asList(getLong(row, ID1), getLong(row, ID2))); List<List<Long>> expectedList = new ArrayList<>(); for (long idPair[] : expected) expectedList.add(Arrays.asList(idPair[0], idPair[1])); assertEquals(expectedList, actualList); }
public PrimitiveWrappersActivityScreen(Character field1, Integer field2, Double field3, Float field4, Boolean field5, Short field6, Byte field7, Long field8) { this.field1 = field1; this.field2 = field2; this.field3 = field3; this.field4 = field4; this.field5 = field5; this.field6 = field6; this.field7 = field7; this.field8 = field8; }
/** * Executes an insert statement to persist given trinityprocessortest.full.MyEntity in the database. * When successful, the id of the trinityprocessortest.full.MyEntity will be set to the id of the created row. * * @param entity The trinityprocessortest.full.MyEntity to insert. * * @return The created row id, or null if an error occurred. */ @Override public Long create(final MyEntity entity) { Long result = null; ContentValues contentValues = createContentValues(entity); long id = mDatabase.insert("entities", null, contentValues); if (id != -1) { result = id; } return result; }