Java Code Examples for java.util.ArrayList#containsAll()

The following examples show how to use java.util.ArrayList#containsAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractWorkflowRestApiTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void checkTasksPresent(String url, boolean mustBePresent, String... ids) throws Exception 
{
    List<String> taskIds = Arrays.asList(ids);
    JSONObject json = getDataFromRequest(url);
    JSONArray result = json.getJSONArray("data");
    assertNotNull(result);

    ArrayList<String> resultIds = new ArrayList<String>(result.length());
    for (int i=0; i<result.length(); i++)
    {
        JSONObject taskObject = result.getJSONObject(i);
        String taskId = taskObject.getString("id");
        resultIds.add(taskId);
        if (mustBePresent == false && taskIds.contains(taskId))
        {
            fail("The results should not contain id: "+taskId);
        }
    }
    if (mustBePresent && resultIds.containsAll(taskIds) == false)
    {
        fail("Not all task Ids were present!\nExpected: "+taskIds +"\nActual: "+resultIds); 
    }
}
 
Example 2
Source File: ParRegColocation.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
protected void verifyPRListenerInvocation(PartitionedRegion aRegion) {
  UpdateBBPartitionListener listener = (UpdateBBPartitionListener)aRegion
      .getPartitionListeners()[1];
  ArrayList listenerInvocationIdsForNode = (ArrayList)listener
      .getBucketIdsList();
  ArrayList primaryBucketListForNode = (ArrayList)aRegion
      .getLocalPrimaryBucketsListTestOnly();
  if (listenerInvocationIdsForNode.size() != primaryBucketListForNode.size()) {
    throw new TestException("PRListener invocation for the region "
        + aRegion.getName() + " was for bucket ids "
        + listenerInvocationIdsForNode + " on this node "
        + " but primary buckets on this node are" + primaryBucketListForNode);
  }

  if (!listenerInvocationIdsForNode.containsAll(primaryBucketListForNode)) {
    throw new TestException("PRListener invocation for the region "
        + aRegion.getName() + " was for bucket ids "
        + listenerInvocationIdsForNode + " on this node "
        + " but primary buckets on this node are" + primaryBucketListForNode);
  }

}
 
Example 3
Source File: doRandomGivenPercentMutants.java    From muJava with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the minimal tests.
 * 
 * @param testSets
 *            the test sets
 * @return the minimal tests
 */
private static CopyOnWriteArrayList<ArrayList<String>> getMinimalTests(CopyOnWriteArrayList<ArrayList<String>> testSets) {
	CopyOnWriteArrayList<ArrayList<String>> result = new CopyOnWriteArrayList<>();
	List<ArrayList<String>> testSets2 = new CopyOnWriteArrayList<ArrayList<String>>();
	List<ArrayList<String>> testSets3 = new CopyOnWriteArrayList<ArrayList<String>>();
	testSets2.addAll(testSets);
	testSets3.addAll(testSets);
	for (ArrayList<String> test : testSets3) {
		for (ArrayList<String> test2 : testSets2) {
			if (test.containsAll(test2) && !test2.containsAll(test)) {
				testSets.remove(test);
				testSets2.remove(test);
				testSets3.remove(test);
				System.out.println("remove test "+test);
				break;
			}
		}
	}
	result.addAll(testSets);
	return result;
}
 
Example 4
Source File: ParRegColocation.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
protected void verifyPRListenerInvocation(PartitionedRegion aRegion) {
  UpdateBBPartitionListener listener = (UpdateBBPartitionListener)aRegion
      .getPartitionListeners()[1];
  ArrayList listenerInvocationIdsForNode = (ArrayList)listener
      .getBucketIdsList();
  ArrayList primaryBucketListForNode = (ArrayList)aRegion
      .getLocalPrimaryBucketsListTestOnly();
  if (listenerInvocationIdsForNode.size() != primaryBucketListForNode.size()) {
    throw new TestException("PRListener invocation for the region "
        + aRegion.getName() + " was for bucket ids "
        + listenerInvocationIdsForNode + " on this node "
        + " but primary buckets on this node are" + primaryBucketListForNode);
  }

  if (!listenerInvocationIdsForNode.containsAll(primaryBucketListForNode)) {
    throw new TestException("PRListener invocation for the region "
        + aRegion.getName() + " was for bucket ids "
        + listenerInvocationIdsForNode + " on this node "
        + " but primary buckets on this node are" + primaryBucketListForNode);
  }

}
 
Example 5
Source File: GetTokenLoginMethodHandler.java    From kognitivo with Apache License 2.0 5 votes vote down vote up
void getTokenCompleted(LoginClient.Request request, Bundle result) {
    if (getTokenClient != null) {
        getTokenClient.setCompletedListener(null);
    }
    getTokenClient = null;

    loginClient.notifyBackgroundProcessingStop();

    if (result != null) {
        ArrayList<String> currentPermissions =
                result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
        Set<String> permissions = request.getPermissions();
        if ((currentPermissions != null) &&
                ((permissions == null) || currentPermissions.containsAll(permissions))) {
            // We got all the permissions we needed, so we can complete the auth now.
            complete(request, result);
            return;
        }

        // We didn't get all the permissions we wanted, so update the request with just the
        // permissions we still need.
        Set<String> newPermissions = new HashSet<String>();
        for (String permission : permissions) {
            if (!currentPermissions.contains(permission)) {
                newPermissions.add(permission);
            }
        }
        if (!newPermissions.isEmpty()) {
            addLoggingExtra(
                LoginLogger.EVENT_EXTRAS_NEW_PERMISSIONS,
                TextUtils.join(",", newPermissions)
            );
        }

        request.setPermissions(newPermissions);
    }

    loginClient.tryNextHandler();
}
 
Example 6
Source File: SchemaModifier.java    From requery with Apache License 2.0 5 votes vote down vote up
private ArrayList<Type<?>> sortTypes() {
    // sort the types in table creation order to avoid referencing not created table via a
    // reference (could also add constraints at the end but SQLite doesn't support that)
    ArrayDeque<Type<?>> queue = new ArrayDeque<>(model.getTypes());
    ArrayList<Type<?>> sorted = new ArrayList<>();
    while (!queue.isEmpty()) {
        Type<?> type = queue.poll();

        if (type.isView()) {
            continue;
        }

        Set<Type<?>> referencing = referencedTypesOf(type);
        for (Type<?> referenced : referencing) {
            Set<Type<?>> backReferences = referencedTypesOf(referenced);
            if (backReferences.contains(type)) {
                throw new CircularReferenceException("circular reference detected between "
                    + type.getName() + " and " + referenced.getName());
            }
        }
        if (referencing.isEmpty() || sorted.containsAll(referencing)) {
            sorted.add(type);
            queue.remove(type);
        } else {
            queue.offer(type); // put back
        }
    }
    return sorted;
}
 
Example 7
Source File: KSAllowedSeqs.java    From OSPREY3 with GNU General Public License v2.0 5 votes vote down vote up
public static void deleteFromSet( ArrayList<String> item, HashSet<ArrayList<String>> set ) {
	// delete item from any matching element of set
	for( Iterator<ArrayList<String>> iterator = set.iterator(); iterator.hasNext(); ) {
		
		ArrayList<String> element = iterator.next();
		
		if(element.containsAll(item))
			iterator.remove();
	}
}
 
Example 8
Source File: AuthorizationClient.java    From aws-mobile-self-paced-labs-samples with Apache License 2.0 5 votes vote down vote up
void getTokenCompleted(AuthorizationRequest request, Bundle result) {
    getTokenClient = null;

    notifyBackgroundProcessingStop();

    if (result != null) {
        ArrayList<String> currentPermissions = result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
        List<String> permissions = request.getPermissions();
        if ((currentPermissions != null) &&
                ((permissions == null) || currentPermissions.containsAll(permissions))) {
            // We got all the permissions we needed, so we can complete the auth now.
            AccessToken token = AccessToken
                    .createFromNativeLogin(result, AccessTokenSource.FACEBOOK_APPLICATION_SERVICE);
            Result outcome = Result.createTokenResult(token);
            completeAndValidate(outcome);
            return;
        }

        // We didn't get all the permissions we wanted, so update the request with just the permissions
        // we still need.
        ArrayList<String> newPermissions = new ArrayList<String>();
        for (String permission : permissions) {
            if (!currentPermissions.contains(permission)) {
                newPermissions.add(permission);
            }
        }
        request.setPermissions(newPermissions);
    }

    tryNextHandler();
}
 
Example 9
Source File: AuthorizationClient.java    From Abelana-Android with Apache License 2.0 5 votes vote down vote up
void getTokenCompleted(AuthorizationRequest request, Bundle result) {
    getTokenClient = null;

    notifyBackgroundProcessingStop();

    if (result != null) {
        ArrayList<String> currentPermissions = result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
        List<String> permissions = request.getPermissions();
        if ((currentPermissions != null) &&
                ((permissions == null) || currentPermissions.containsAll(permissions))) {
            // We got all the permissions we needed, so we can complete the auth now.
            AccessToken token = AccessToken
                    .createFromNativeLogin(result, AccessTokenSource.FACEBOOK_APPLICATION_SERVICE);
            Result outcome = Result.createTokenResult(pendingRequest, token);
            completeAndValidate(outcome);
            return;
        }

        // We didn't get all the permissions we wanted, so update the request with just the permissions
        // we still need.
        List<String> newPermissions = new ArrayList<String>();
        for (String permission : permissions) {
            if (!currentPermissions.contains(permission)) {
                newPermissions.add(permission);
            }
        }
        if (!newPermissions.isEmpty()) {
            addLoggingExtra(EVENT_EXTRAS_NEW_PERMISSIONS, TextUtils.join(",", newPermissions));
        }

        request.setPermissions(newPermissions);
    }

    tryNextHandler();
}
 
Example 10
Source File: AuthorizationClient.java    From facebook-api-android-maven with Apache License 2.0 5 votes vote down vote up
void getTokenCompleted(AuthorizationRequest request, Bundle result) {
    getTokenClient = null;

    notifyBackgroundProcessingStop();

    if (result != null) {
        ArrayList<String> currentPermissions = result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
        List<String> permissions = request.getPermissions();
        if ((currentPermissions != null) &&
                ((permissions == null) || currentPermissions.containsAll(permissions))) {
            // We got all the permissions we needed, so we can complete the auth now.
            AccessToken token = AccessToken
                    .createFromNativeLogin(result, AccessTokenSource.FACEBOOK_APPLICATION_SERVICE);
            Result outcome = Result.createTokenResult(pendingRequest, token);
            completeAndValidate(outcome);
            return;
        }

        // We didn't get all the permissions we wanted, so update the request with just the permissions
        // we still need.
        List<String> newPermissions = new ArrayList<String>();
        for (String permission : permissions) {
            if (!currentPermissions.contains(permission)) {
                newPermissions.add(permission);
            }
        }
        if (!newPermissions.isEmpty()) {
            addLoggingExtra(EVENT_EXTRAS_NEW_PERMISSIONS, TextUtils.join(",", newPermissions));
        }

        request.setPermissions(newPermissions);
    }

    tryNextHandler();
}
 
Example 11
Source File: AuthorizationClient.java    From HypFacebook with BSD 2-Clause "Simplified" License 5 votes vote down vote up
void getTokenCompleted(AuthorizationRequest request, Bundle result) {
    getTokenClient = null;

    notifyBackgroundProcessingStop();

    if (result != null) {
        ArrayList<String> currentPermissions = result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
        List<String> permissions = request.getPermissions();
        if ((currentPermissions != null) &&
                ((permissions == null) || currentPermissions.containsAll(permissions))) {
            // We got all the permissions we needed, so we can complete the auth now.
            AccessToken token = AccessToken
                    .createFromNativeLogin(result, AccessTokenSource.FACEBOOK_APPLICATION_SERVICE);
            Result outcome = Result.createTokenResult(token);
            completeAndValidate(outcome);
            return;
        }

        // We didn't get all the permissions we wanted, so update the request with just the permissions
        // we still need.
        ArrayList<String> newPermissions = new ArrayList<String>();
        for (String permission : permissions) {
            if (!currentPermissions.contains(permission)) {
                newPermissions.add(permission);
            }
        }
        request.setPermissions(newPermissions);
    }

    tryNextHandler();
}
 
Example 12
Source File: AuthorizationClient.java    From FacebookNewsfeedSample-Android with Apache License 2.0 5 votes vote down vote up
void getTokenCompleted(AuthorizationRequest request, Bundle result) {
    getTokenClient = null;

    notifyBackgroundProcessingStop();

    if (result != null) {
        ArrayList<String> currentPermissions = result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
        List<String> permissions = request.getPermissions();
        if ((currentPermissions != null) &&
                ((permissions == null) || currentPermissions.containsAll(permissions))) {
            // We got all the permissions we needed, so we can complete the auth now.
            AccessToken token = AccessToken
                    .createFromNativeLogin(result, AccessTokenSource.FACEBOOK_APPLICATION_SERVICE);
            Result outcome = Result.createTokenResult(token);
            completeAndValidate(outcome);
            return;
        }

        // We didn't get all the permissions we wanted, so update the request with just the permissions
        // we still need.
        ArrayList<String> newPermissions = new ArrayList<String>();
        for (String permission : permissions) {
            if (!currentPermissions.contains(permission)) {
                newPermissions.add(permission);
            }
        }
        request.setPermissions(newPermissions);
    }

    tryNextHandler();
}
 
Example 13
Source File: CounterHierarchyBelowTest.java    From floodlight_with_topoguard with Apache License 2.0 4 votes vote down vote up
private void isEqual(ArrayList<Integer> a, ArrayList<Integer> b) {
    if (a.size() != b.size() || !b.containsAll(a)) assertTrue(false);
}