List of usage examples for com.fasterxml.jackson.databind.util ISO8601Utils format
public static String format(Date date)
From source file:org.noorganization.instalistsynch.controller.local.dba.impl.SqliteGroupAccessDbControllerTest.java
License:asdf
public void testUpdate() throws Exception { Date currentDate = new Date(); SQLiteDatabase db = mDbHelper.getWritableDatabase(); ContentValues cv = new ContentValues(); cv.put(GroupAccess.COLUMN.GROUP_ID, 1); cv.put(GroupAccess.COLUMN.INTERRUPTED, false); cv.put(GroupAccess.COLUMN.SYNCHRONIZE, true); cv.put(GroupAccess.COLUMN.LAST_UPDATE_FROM_SERVER, ISO8601Utils.format(currentDate)); cv.put(GroupAccess.COLUMN.LAST_TOKEN_REQUEST, ISO8601Utils.format(currentDate)); cv.put(GroupAccess.COLUMN.TOKEN, "fdskhbvvkddscddueFSNDFSAdnandk3229df-dFSJDKMds."); assertTrue(db.insert(GroupAccess.TABLE_NAME, null, cv) >= 0); GroupAccess groupAccess = new GroupAccess(1, "fdskhbvvkddscddueasdfeSAdnandk3229df-dFSJDKMds."); groupAccess.setLastTokenRequest(currentDate); groupAccess.setLastUpdateFromServer(currentDate); groupAccess.setSynchronize(true);// ww w .ja v a2 s .co m groupAccess.setInterrupted(true); assertTrue(mGroupAuthAccessDbController.update(groupAccess)); Cursor cursor = db.query(GroupAccess.TABLE_NAME, GroupAccess.COLUMN.ALL_COLUMNS, GroupAccess.COLUMN.GROUP_ID + " = ? ", new String[] { String.valueOf(1) }, null, null, null); int count = cursor.getCount(); if (count == 0) cursor.close(); assertTrue(cursor.moveToFirst()); int groupId = cursor.getInt(cursor.getColumnIndex(GroupAccess.COLUMN.GROUP_ID)); boolean synchronize = cursor.getInt(cursor.getColumnIndex(GroupAccess.COLUMN.SYNCHRONIZE)) == 1; boolean interrupted = cursor.getInt(cursor.getColumnIndex(GroupAccess.COLUMN.INTERRUPTED)) == 1; Date lastTokenRequestDate = ISO8601Utils.parse( cursor.getString(cursor.getColumnIndex(GroupAccess.COLUMN.LAST_TOKEN_REQUEST)), new ParsePosition(0)); Date lastUpdateDate = ISO8601Utils.parse( cursor.getString(cursor.getColumnIndex(GroupAccess.COLUMN.LAST_UPDATE_FROM_SERVER)), new ParsePosition(0)); String token = cursor.getString(cursor.getColumnIndex(GroupAccess.COLUMN.TOKEN)); cursor.close(); assertEquals(1, groupId); assertEquals(true, synchronize); assertEquals(true, interrupted); assertEquals(ISO8601Utils.format(currentDate), ISO8601Utils.format(lastTokenRequestDate)); assertEquals(ISO8601Utils.format(currentDate), ISO8601Utils.format(lastUpdateDate)); assertEquals("fdskhbvvkddscddueasdfeSAdnandk3229df-dFSJDKMds.", token); }
From source file:com.unboundid.scim2.common.filters.Filter.java
/** * Create a new {@code not equal} filter. * * @param attributePath The path to the attribute to filter by. * @param filterValue The filter attribute value. * @return A new {@code not equal} filter. * @throws BadRequestException If the path could not be parsed. *///w w w . j a v a 2s . com public static Filter ne(final String attributePath, final Date filterValue) throws BadRequestException { return new NotEqualFilter(Path.fromString(attributePath), JsonUtils.getJsonNodeFactory().textNode(ISO8601Utils.format(filterValue))); }
From source file:org.noorganization.instalistsynch.controller.local.dba.impl.SqliteGroupAccessDbControllerTest.java
License:asdf
public void testUpdateToken() throws Exception { Date currentDate = new Date(); SQLiteDatabase db = mDbHelper.getWritableDatabase(); ContentValues cv = new ContentValues(); cv.put(GroupAccess.COLUMN.GROUP_ID, 1); cv.put(GroupAccess.COLUMN.INTERRUPTED, false); cv.put(GroupAccess.COLUMN.SYNCHRONIZE, true); cv.put(GroupAccess.COLUMN.LAST_UPDATE_FROM_SERVER, ISO8601Utils.format(currentDate)); cv.put(GroupAccess.COLUMN.LAST_TOKEN_REQUEST, ISO8601Utils.format(currentDate)); cv.put(GroupAccess.COLUMN.TOKEN, "fdskhbvvkddscddueFSNDFSAdnandk3229df-dFSJDKMds."); assertTrue(db.insert(GroupAccess.TABLE_NAME, null, cv) >= 0); assertTrue(mGroupAuthAccessDbController.updateToken(1, "fdskhbvvkddscddueasdfeSAdnandk3229df-dFSJDKMds.")); Cursor cursor = db.query(GroupAccess.TABLE_NAME, GroupAccess.COLUMN.ALL_COLUMNS, GroupAccess.COLUMN.GROUP_ID + " = ? ", new String[] { String.valueOf(1) }, null, null, null); int count = cursor.getCount(); if (count == 0) cursor.close();//from www . j ava2 s . c o m assertTrue(cursor.moveToFirst()); int groupId = cursor.getInt(cursor.getColumnIndex(GroupAccess.COLUMN.GROUP_ID)); boolean synchronize = cursor.getInt(cursor.getColumnIndex(GroupAccess.COLUMN.SYNCHRONIZE)) == 1; boolean interrupted = cursor.getInt(cursor.getColumnIndex(GroupAccess.COLUMN.INTERRUPTED)) == 1; Date lastTokenRequestDate = ISO8601Utils.parse( cursor.getString(cursor.getColumnIndex(GroupAccess.COLUMN.LAST_TOKEN_REQUEST)), new ParsePosition(0)); Date lastUpdateDate = ISO8601Utils.parse( cursor.getString(cursor.getColumnIndex(GroupAccess.COLUMN.LAST_UPDATE_FROM_SERVER)), new ParsePosition(0)); String token = cursor.getString(cursor.getColumnIndex(GroupAccess.COLUMN.TOKEN)); cursor.close(); assertEquals(1, groupId); assertEquals(true, synchronize); assertEquals(false, interrupted); assertEquals(ISO8601Utils.format(currentDate), ISO8601Utils.format(lastTokenRequestDate)); assertEquals(ISO8601Utils.format(currentDate), ISO8601Utils.format(lastUpdateDate)); assertEquals("fdskhbvvkddscddueasdfeSAdnandk3229df-dFSJDKMds.", token); }
From source file:org.noorganization.instalistsynch.controller.local.dba.impl.SqliteGroupAccessDbControllerTest.java
License:asdf
public void testHasIdInDatabase() throws Exception { Date currentDate = new Date(); SQLiteDatabase db = mDbHelper.getWritableDatabase(); ContentValues cv = new ContentValues(); cv.put(GroupAccess.COLUMN.GROUP_ID, 1); cv.put(GroupAccess.COLUMN.INTERRUPTED, false); cv.put(GroupAccess.COLUMN.SYNCHRONIZE, true); cv.put(GroupAccess.COLUMN.LAST_UPDATE_FROM_SERVER, ISO8601Utils.format(currentDate)); cv.put(GroupAccess.COLUMN.LAST_TOKEN_REQUEST, ISO8601Utils.format(currentDate)); cv.put(GroupAccess.COLUMN.TOKEN, "fdskhbvvkddscddueFSNDFSAdnandk3229df-dFSJDKMds."); assertTrue(db.insert(GroupAccess.TABLE_NAME, null, cv) >= 0); assertTrue(mGroupAuthAccessDbController.hasIdInDatabase(1)); assertFalse(mGroupAuthAccessDbController.hasIdInDatabase(2)); }
From source file:com.unboundid.scim2.common.filters.Filter.java
/** * Create a new {@code greater than} filter. * * @param attributePath The path to the attribute to filter by. * @param filterValue The filter attribute value. * @return A new {@code greater than} filter. * @throws BadRequestException If the path could not be parsed. *//*ww w. j a va 2 s . co m*/ public static Filter gt(final String attributePath, final Date filterValue) throws BadRequestException { return new GreaterThanFilter(Path.fromString(attributePath), JsonUtils.getJsonNodeFactory().textNode(ISO8601Utils.format(filterValue))); }
From source file:com.unboundid.scim2.common.filters.Filter.java
/** * Create a new {@code greater than or equal} filter. * * @param attributePath The path to the attribute to filter by. * @param filterValue The filter attribute value. * @return A new {@code greater than or equal} filter. * @throws BadRequestException If the path could not be parsed. *///from w ww . j av a 2s .c o m public static Filter ge(final String attributePath, final Date filterValue) throws BadRequestException { return new GreaterThanOrEqualFilter(Path.fromString(attributePath), JsonUtils.getJsonNodeFactory().textNode(ISO8601Utils.format(filterValue))); }
From source file:com.unboundid.scim2.common.filters.Filter.java
/** * Create a new {@code less than} filter. * * @param attributePath The path to the attribute to filter by. * @param filterValue The filter attribute value. * @return A new {@code greater than or equal} filter. * @throws BadRequestException If the path could not be parsed. *///from ww w . ja v a 2 s . c o m public static Filter lt(final String attributePath, final Date filterValue) throws BadRequestException { return new LessThanFilter(Path.fromString(attributePath), JsonUtils.getJsonNodeFactory().textNode(ISO8601Utils.format(filterValue))); }
From source file:com.unboundid.scim2.common.filters.Filter.java
/** * Create a {@code new less than or equal} filter. * * @param attributePath The path to the attribute to filter by. * @param filterValue The filter attribute value. * @return A {@code new less than or equal} filter. * @throws BadRequestException If the path could not be parsed. *//*from www .j a va 2 s .c om*/ public static Filter le(final String attributePath, final Date filterValue) throws BadRequestException { return new LessThanOrEqualFilter(Path.fromString(attributePath), JsonUtils.getJsonNodeFactory().textNode(ISO8601Utils.format(filterValue))); }