Example usage for java.util List containsAll

List of usage examples for java.util List containsAll

Introduction

In this page you can find the example usage for java.util List containsAll.

Prototype

boolean containsAll(Collection<?> c);

Source Link

Document

Returns true if this list contains all of the elements of the specified collection.

Usage

From source file:org.finra.herd.service.JobServiceTest.java

@Test
public void testCreateJob() throws Exception {
    // Create the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);

    // Create a job definition create request using hard coded test values.
    JobDefinitionCreateRequest jobDefinitionCreateRequest = jobDefinitionServiceTestHelper
            .createJobDefinitionCreateRequest();

    // Create the job definition.
    jobDefinitionService.createJobDefinition(jobDefinitionCreateRequest, false);

    // Create a job create request using hard coded test values.
    JobCreateRequest jobCreateRequest = jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD,
            TEST_ACTIVITI_JOB_NAME);/*from  ww  w .  j  a  v  a2 s . co  m*/

    // Create the job.
    Job resultJob = jobService.createAndStartJob(jobCreateRequest);

    // Validate the results.
    assertNotNull(resultJob);
    assertNotNull(resultJob.getId());
    assertTrue(!resultJob.getId().isEmpty());
    assertEquals(TEST_ACTIVITI_NAMESPACE_CD, resultJob.getNamespace());
    assertEquals(TEST_ACTIVITI_JOB_NAME, resultJob.getJobName());
    assertEquals(
            jobDefinitionCreateRequest.getParameters().size() + jobCreateRequest.getParameters().size() + 1,
            resultJob.getParameters().size());
    List<String> expectedParameters = new ArrayList<>();
    expectedParameters.addAll(parametersToStringList(jobDefinitionCreateRequest.getParameters()));
    expectedParameters.addAll(parametersToStringList(jobCreateRequest.getParameters()));
    expectedParameters.addAll(parametersToStringList(Arrays.asList(new Parameter(HERD_WORKFLOW_ENVIRONMENT,
            configurationHelper.getProperty(ConfigurationValue.HERD_ENVIRONMENT)))));
    List<String> resultParameters = parametersToStringList(resultJob.getParameters());
    assertTrue(expectedParameters.containsAll(resultParameters));
    assertTrue(resultParameters.containsAll(expectedParameters));
}

From source file:org.finra.herd.service.JobServiceTest.java

@Test
public void testCreateJobNoParams() throws Exception {
    // Create the namespace entity.
    namespaceDaoTestHelper.createNamespaceEntity(TEST_ACTIVITI_NAMESPACE_CD);

    // Create a job definition create request using hard coded test values.
    JobDefinitionCreateRequest jobDefinitionCreateRequest = jobDefinitionServiceTestHelper
            .createJobDefinitionCreateRequest();
    jobDefinitionCreateRequest.setParameters(null);

    // Create the job definition.
    jobDefinitionService.createJobDefinition(jobDefinitionCreateRequest, false);

    // Create a job create request using hard coded test values.
    JobCreateRequest jobCreateRequest = jobServiceTestHelper.createJobCreateRequest(TEST_ACTIVITI_NAMESPACE_CD,
            TEST_ACTIVITI_JOB_NAME);/*ww  w .j av a 2 s  .c o m*/
    jobCreateRequest.setParameters(null);

    // Create the job.
    Job resultJob = jobService.createAndStartJob(jobCreateRequest);

    //expected default parameter
    List<Parameter> expectedParameters = Arrays.asList(new Parameter(HERD_WORKFLOW_ENVIRONMENT,
            configurationHelper.getProperty(ConfigurationValue.HERD_ENVIRONMENT)));

    // Validate the results.
    assertNotNull(resultJob);
    assertNotNull(resultJob.getId());
    assertTrue(!resultJob.getId().isEmpty());
    assertEquals(TEST_ACTIVITI_NAMESPACE_CD, resultJob.getNamespace());
    assertEquals(TEST_ACTIVITI_JOB_NAME, resultJob.getJobName());
    assertTrue(resultJob.getParameters().size() == 1);
    assertTrue(expectedParameters.containsAll(resultJob.getParameters()));
}

From source file:oracle.kv.hadoop.hive.table.TableHiveRecordReader.java

/**
 * Assumes the columns in the given search conditions correspond to the
 * fields of a <em>valid</em> <code>PrimaryKey</code> of the given table,
 * and uses that information to construct and return a partial key
 * that can be "pushed" to the store for scanning and filtering the
 * table in the backen server; or returns <code>null</code> (or an
 * "empty" key) if those search conditions do not satisfy the necessary
 * criteria for constructing the key. The criteria used when constructing
 * the key is as follows:/*from  ww w.  jav  a  2s .c  o m*/
 *
 * For the set of columns in the search conditions that are associated
 * with the '=' operation, if those columns form a valid key (that is,
 * the first 'N' fields of the table's key, with no "gaps"), then those
 * fields are used to construct the key to return. Additionally, if the
 * search conditions reference the 'N+1st' field of the table's key as
 * a <code>FieldRange</code>, then that field is <em>not</em> included
 * in the returned key; so that the <code>FieldRange</code> can be
 * handled ("pushed") separately.
 */
private PrimaryKey primaryKeyFromSearchConditionsNoRange(final List<IndexSearchCondition> searchConditions,
        final Table table) {

    if (searchConditions == null || table == null) {
        return null;
    }

    final List<String> tableFields = TableHiveInputFormat.getPrimaryColumnsLower(table);

    if (tableFields == null || tableFields.isEmpty()) {
        return null;
    }

    /*
     * If there is a column in the search conditions that is associated
     * with a field range, than exclude it from the key construction
     * process; so that the field range can be handled separately.
     */
    final Map<String, IndexSearchCondition> searchCondMap = new HashMap<String, IndexSearchCondition>();
    for (IndexSearchCondition cond : searchConditions) {
        final String colName = cond.getColumnDesc().getColumn().toLowerCase();
        if ((GenericUDFOPEqual.class.getName()).equals(cond.getComparisonOp())) {
            searchCondMap.put(colName, cond);
        }
    }

    /*
     * Because this method is called only after the search conditions
     * have been validated, there is no need to check for a valid
     * PrimaryKey. Additionally, if the search conditions contain
     * no '=' operators (searchCondMap.size == 0), then those search
     * conditions must represent a FieldRange on the first field of
     * the PrimaryKey; in which case, this method returns an empty
     * PrimaryKey (so that filtering will be performed on that range,
     * and all remaining fields are 'wildcarded').
     */
    final PrimaryKey primaryKey = table.createPrimaryKey();

    if (searchCondMap.isEmpty()) {
        return primaryKey;
    }

    /*
     * Reaching this point means that there must be at least one column
     * (field) in the search conditions corresponding to the '=' operator.
     * In that case, return the partial PrimaryKey containing the fields
     * corresponding to the '=' operators.
     */
    if (tableFields.containsAll(searchCondMap.keySet())) {

        final List<String> fieldNames = primaryKey.getFields();

        for (String fieldName : fieldNames) {
            final IndexSearchCondition searchCond = searchCondMap.get(fieldName.toLowerCase());

            if (searchCond == null) {
                /* null ==> no more elements in searchCondMap. Done. */
                return primaryKey;
            }
            TableHiveInputFormat.populateKey(fieldName, searchCond.getConstantDesc(), primaryKey);
        }
    }
    return primaryKey;
}

From source file:rhsm.cli.tests.RHELPersonalTests.java

@Test(description = "subscription-manager-cli: Ensure system autosubscribe consumes subpool RHEL Personal Bits", groups = {
        "EnsureSystemAutosubscribeConsumesSubPool_Test", "blockedByBug-637937", "blockedByBug-737762" },
        //         dependsOnGroups={"EnsureSubPoolIsNotDeletedAfterAllOtherSystemsUnsubscribeFromSubPool_Test"},
        priority = 200, dependsOnMethods = {
                "EnsureSubPoolIsConsumableAfterRegisteredPersonSubscribesToRHELPersonal_Test" }, enabled = true)
//@ImplementsTCMS(id="")
public void EnsureSystemAutosubscribeConsumesSubPool_Test() throws JSONException {
    if (client2tasks == null)
        throw new SkipException("A second client system is required for this test.");
    //      unsubscribeAndUnregisterMultipleSystemsAfterGroups();

    for (int j = 0; j < sm_personSubscriptionPoolProductData.length(); j++) {
        JSONObject poolProductDataAsJSONObject = (JSONObject) sm_personSubscriptionPoolProductData.get(j);
        String personProductId = poolProductDataAsJSONObject.getString("personProductId");
        JSONObject subpoolProductDataAsJSONObject = poolProductDataAsJSONObject
                .getJSONObject("subPoolProductData");
        String systemProductId = subpoolProductDataAsJSONObject.getString("systemProductId");
        JSONArray bundledProductData = subpoolProductDataAsJSONObject.getJSONArray("bundledProductData");

        log.info("Register client1 under username '" + username + "' as a person and subscribe to the '"
                + personProductId + "' subscription pool...");
        personConsumerId = client1tasks.getCurrentConsumerId(
                client1tasks.register(username, password, owner, null, ConsumerType.person, null, null, null,
                        null, null, (String) null, null, null, null, Boolean.TRUE, false, null, null, null));
        SubscriptionPool personalPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId",
                personProductId, client1tasks.getCurrentlyAllAvailableSubscriptionPools());
        Assert.assertNotNull(personalPool, "Personal subscription with ProductId '" + personProductId
                + "' is available to user '" + username + "' registered as a person.");
        List<File> beforeEntitlementCertFiles = client1tasks.getCurrentEntitlementCertFiles();
        client1tasks.subscribeToSubscriptionPool(personalPool);

        log.info("Now register client2 under username '" + username
                + "' as a system with autosubscribe to assert that subpools bundled products gets consumed...");
        client2tasks.unregister(null, null, null);
        client2tasks.register(username, password, owner, null, ConsumerType.system, null, null, Boolean.TRUE,
                null, null, (String) null, null, null, null, null, false, null, null, null);
        List<ProductSubscription> client2ConsumedProductSubscriptions = client2tasks
                .getCurrentlyConsumedProductSubscriptions();

        /* OLD ASSERTION BEFORE IMPLEMENTATION OF Bug 801187 - collapse list of provided products for subscription-manager list --consumed
        for (int k=0; k<bundledProductData.length(); k++) {
           JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
           String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
                   //from  w  w w.  j a v  a2s  .  c  o m
           ProductSubscription consumedProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName",systemConsumedProductName,client2ConsumedProductSubscriptions);
           Assert.assertNotNull(consumedProductSubscription,systemConsumedProductName+" has been autosubscribed by client2 '"+client2.getConnection().getHostname()+"' (registered as a system under username '"+username+"')");
                
        }
        */
        List<String> systemConsumedProductNames = new ArrayList<String>();
        for (int k = 0; k < bundledProductData.length(); k++) {
            JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
            String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
            systemConsumedProductNames.add(systemConsumedProductName);
        }
        ProductSubscription systemProductSubscription = ProductSubscription
                .findFirstInstanceWithMatchingFieldFromList("productName", personSubscriptionName,
                        client2ConsumedProductSubscriptions);
        Assert.assertNotNull(systemProductSubscription,
                personSubscriptionName + " has been autosubscribed by client2 '"
                        + client2.getConnection().getHostname() + "' (registered as a system under username '"
                        + username + "')");
        Assert.assertTrue(
                systemProductSubscription.provides.containsAll(systemConsumedProductNames)
                        && systemConsumedProductNames.containsAll(systemProductSubscription.provides),
                "All of the expected bundled products " + systemConsumedProductNames
                        + " are now being provided for on client2 system '"
                        + client2.getConnection().getHostname() + "' after having autosubscribed.");

        client2tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
        client1tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    }

    // unregister the last person consumer from client1
    client1tasks.unregister(null, null, null);
}

From source file:rhsm.cli.tests.RHELPersonalTests.java

@Test(description = "subscription-manager-cli: Ensure RHEL Personal Bits are available and unlimited after a person has subscribed to RHEL Personal", groups = {
        "EnsureSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal_Test", "RHELPersonal",
        "blockedByBug-624816", "blockedByBug-641155", "blockedByBug-643405",
        "blockedByBug-967160" }, priority = 100, enabled = true)
@ImplementsNitrateTest(caseId = 55702)//from w  w  w  .j av a  2  s .c om
//   @ImplementsNitrateTest(caseId={55702,55718})
public void EnsureSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal_Test() throws JSONException {
    if (true)
        throw new SkipException(
                "Support for the RHELPersonalTests was yanked in favor of new DataCenter SKUs.  These RHELPersonalTests are obsolete.  Reference: CLOSED WONTFIX Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=967160#c1");
    //      if (!isServerOnPremises) throw new SkipException("Currently this test is designed only for on-premises.");   //TODO Make this work for IT too.  jsefler 8/12/2010 
    if (client2tasks == null)
        throw new SkipException("These tests are designed to use a second client.");
    if (username.equals(sm_serverAdminUsername))
        throw new SkipException(
                "This test requires that the client user (" + username + ") is NOT " + sm_serverAdminUsername);

    // TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=624423 - jsefler 8/16/2010
    Boolean invokeWorkaroundWhileBugIsOpen = false;
    try {
        String bugId = "624423";
        if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
            log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString()
                    + " Bugzilla " + bugId + ".  (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
            SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
        } else {
            invokeWorkaroundWhileBugIsOpen = false;
        }
    } catch (XmlRpcException xre) {
        /* ignore exception */} catch (RuntimeException re) {
        /* ignore exception */}
    if (invokeWorkaroundWhileBugIsOpen) {
        servertasks.restartTomcat();
    } // END OF WORKAROUND

    client2tasks.unregister(null, null, null);
    client1tasks.unregister(null, null, null); // just in case client1 is still registered as the person consumer

    for (int j = 0; j < sm_personSubscriptionPoolProductData.length(); j++) {
        JSONObject poolProductDataAsJSONObject = (JSONObject) sm_personSubscriptionPoolProductData.get(j);
        String personProductId = poolProductDataAsJSONObject.getString("personProductId");
        JSONObject subpoolProductDataAsJSONObject = poolProductDataAsJSONObject
                .getJSONObject("subPoolProductData");
        String systemProductId = subpoolProductDataAsJSONObject.getString("systemProductId");

        SubscriptionPool pool = null;

        log.info("Register client2 under username '" + username + "' as a system and assert that ProductId '"
                + systemProductId + "' is NOT yet available...");

        client2tasks.register(username, password, owner, null, ConsumerType.system, null, null, null, null,
                null, (String) null, null, null, null, null, false, null, null, null);
        List<SubscriptionPool> client2BeforeSubscriptionPools = client2tasks
                .getCurrentlyAvailableSubscriptionPools();
        pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", systemProductId,
                client2BeforeSubscriptionPools);
        Assert.assertNull(pool, "ProductId '" + systemProductId + "' is NOT yet available to client2 system '"
                + client2.getConnection().getHostname() + "' registered under user '" + username + "'.");

        //      log.info("Now register client1 under username '"+consumerUsername+"' as a person and subscribe to the '"+personSubscriptionName+"' subscription pool...");
        log.info("Now register client1 under username '" + username
                + "' as a person and subscribe to the personal subscription pool with ProductId '"
                + personProductId + "'...");
        //client1tasks.unregister(null, null, null);
        client1tasks.register(username, password, owner, null, ConsumerType.person, null, null, null, null,
                null, (String) null, null, null, null, null, false, null, null, null);
        personConsumerId = client1tasks.getCurrentConsumerId();
        //      pool = client1tasks.findSubscriptionPoolWithMatchingFieldFromList("subscriptionName",personSubscriptionName,client1tasks.getCurrentlyAllAvailableSubscriptionPools());
        pool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId", personProductId,
                client1tasks.getCurrentlyAvailableSubscriptionPools());
        personSubscriptionName = pool.subscriptionName;
        Assert.assertNotNull(pool, "Personal Subscription with ProductId '" + personProductId
                + "' is available to user '" + username + "' registered as a person.");
        client1tasks.subscribeToSubscriptionPool(pool);

        log.info("Now client2 (already registered as a system under username '" + username
                + "') should now have ProductId '" + systemProductId + "' available with a quantity if '"
                + systemSubscriptionQuantity + "'...");
        List<SubscriptionPool> client2AfterSubscriptionPools = client2tasks
                .getCurrentlyAvailableSubscriptionPools();
        SubscriptionPool systemSubscriptionPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList(
                "productId", systemProductId, client2AfterSubscriptionPools);
        Assert.assertNotNull(systemSubscriptionPool,
                "ProductId '" + systemProductId + "' is now available to client2 '"
                        + client2.getConnection().getHostname() + "' (registered as a system under username '"
                        + username + "')");
        Assert.assertEquals(systemSubscriptionPool.quantity.toLowerCase(), systemSubscriptionQuantity,
                "A quantity of '" + systemSubscriptionQuantity
                        + "' entitlements is available to the subscription for " + systemProductId + ".");

        log.info(
                "Verifying that the available subscription pools available to client2 has increased by only the '"
                        + systemProductId + "' pool...");
        Assert.assertTrue(
                client2AfterSubscriptionPools.containsAll(client2BeforeSubscriptionPools)
                        && client2AfterSubscriptionPools.contains(systemSubscriptionPool)
                        && client2AfterSubscriptionPools.size() == client2BeforeSubscriptionPools.size() + 1,
                "The list of available subscription pools seen by client2 increases only by '" + systemProductId
                        + "' pool: " + systemSubscriptionPool);
    }
}

From source file:org.openmrs.module.camerwa.db.hibernate.HibernateCamerwaDAO.java

public boolean getPatientsOnAll(List<Integer> drugSelected, List<Integer> regimenDrugs) {
    boolean found = false;

    if (regimenDrugs.size() >= drugSelected.size() && regimenDrugs.containsAll(drugSelected)) {
        for (Integer r : regimenDrugs) {
            if (drugSelected.contains(r)) {
                found = true;//from ww  w .  ja  va  2 s .c  om
            } else {
                found = false;
                break;
            }
        }
    }

    return found;
}

From source file:rhsm.cli.tests.RHELPersonalTests.java

@Test(description = "subscription-manager-cli: Ensure RHEL Personal Bits are consumable after a person has subscribed to RHEL Personal", groups = {
        "EnsureSubPoolIsConsumableAfterRegisteredPersonSubscribesToRHELPersonal_Test",
        "RHELPersonal" }, priority = 110, //dependsOnGroups={"EnsureSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal_Test"},
        dependsOnMethods = {//from  w ww.j a  v  a 2 s  .  c o  m
                "EnsureSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal_Test" }, enabled = true)
@ImplementsNitrateTest(caseId = 55702)
//   @ImplementsNitrateTest(caseId={55702,55718})
public void EnsureSubPoolIsConsumableAfterRegisteredPersonSubscribesToRHELPersonal_Test() throws JSONException {

    for (int j = 0; j < sm_personSubscriptionPoolProductData.length(); j++) {
        JSONObject poolProductDataAsJSONObject = (JSONObject) sm_personSubscriptionPoolProductData.get(j);
        String personProductId = poolProductDataAsJSONObject.getString("personProductId");
        JSONObject subpoolProductDataAsJSONObject = poolProductDataAsJSONObject
                .getJSONObject("subPoolProductData");
        String systemProductId = subpoolProductDataAsJSONObject.getString("systemProductId");
        JSONArray bundledProductData = subpoolProductDataAsJSONObject.getJSONArray("bundledProductData");

        log.info("Now client2 (already registered as a system under username '" + username
                + "') can now consume '" + systemProductId + "'...");
        SubscriptionPool systemSubscriptionPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList(
                "productId", systemProductId, client2tasks.getCurrentlyAvailableSubscriptionPools());
        client2tasks.subscribeToSubscriptionPool(systemSubscriptionPool);

        /* OLD ASSERTION BEFORE IMPLEMENTATION OF Bug 801187 - collapse list of provided products for subscription-manager list --consumed
        for (int k=0; k<bundledProductData.length(); k++) {
           JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
           String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
                
           log.info("Now client2 should be consuming the product '"+systemConsumedProductName+"'...");
           ProductSubscription systemProductSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName",systemConsumedProductName,client2tasks.getCurrentlyConsumedProductSubscriptions());
           Assert.assertNotNull(systemProductSubscription,systemConsumedProductName+" is now consumed on client2 system '"+client2.getConnection().getHostname()+"' registered under user '"+username+"'.");
        }
        */
        List<String> systemConsumedProductNames = new ArrayList<String>();
        for (int k = 0; k < bundledProductData.length(); k++) {
            JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
            String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
            systemConsumedProductNames.add(systemConsumedProductName);
        }
        log.info("Now client2 should be consuming the subscription '" + personSubscriptionName
                + "' that provides '" + systemConsumedProductNames + "'...");
        ProductSubscription systemProductSubscription = ProductSubscription
                .findFirstInstanceWithMatchingFieldFromList("productName", personSubscriptionName,
                        client2tasks.getCurrentlyConsumedProductSubscriptions());
        Assert.assertNotNull(systemProductSubscription,
                personSubscriptionName + " is now consumed on client2 system '"
                        + client2.getConnection().getHostname() + "' registered under user '" + username
                        + "'.");
        Assert.assertTrue(
                systemProductSubscription.provides.containsAll(systemConsumedProductNames)
                        && systemConsumedProductNames.containsAll(systemProductSubscription.provides),
                "All of the expected bundled products " + systemConsumedProductNames
                        + " are now being provided for on client2 system '"
                        + client2.getConnection().getHostname() + "' registered under user '" + username
                        + "'.");
    }
}

From source file:rhsm.cli.tests.RHELPersonalTests.java

@Test(description = "subscription-manager-cli: Ensure that multiple (unlimited) systems can subscribe to subpool", groups = {
        "SubscribeMultipleSystemsToSubPool_Test", "RHELPersonal"/*, "blockedByBug-661130"*/ }, priority = 130, //dependsOnGroups={"EnsureAvailabilityOfSubPoolIsRevokedOncePersonUnsubscribesFromRHELPersonal_Test"},
        dependsOnMethods = {/* w w  w .  j av  a  2s  . c om*/
                "EnsureSubPoolIsAvailableAfterRegisteredPersonSubscribesToRHELPersonal_Test" }, enabled = true)
//@ImplementsTCMS(id="")
public void SubscribeMultipleSystemsToSubPool_Test() throws JSONException {
    log.info("Making sure the clients are not subscribed to anything...");
    //      client2tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    //      client2tasks.unregister();
    //      client1tasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
    unsubscribeAndUnregisterMultipleSystemsAfterGroups();
    client1tasks.register(username, password, owner, null, ConsumerType.person,
            /*"blockedByBug-661130" "ME"*/null, null, null, null, null, (String) null, null, null, null, null,
            false, null, null, null);
    personConsumerId = client1tasks.getCurrentConsumerId();

    for (int j = 0; j < sm_personSubscriptionPoolProductData.length(); j++) {
        JSONObject poolProductDataAsJSONObject = (JSONObject) sm_personSubscriptionPoolProductData.get(j);
        String personProductId = poolProductDataAsJSONObject.getString("personProductId");
        JSONObject subpoolProductDataAsJSONObject = poolProductDataAsJSONObject
                .getJSONObject("subPoolProductData");
        String systemProductId = subpoolProductDataAsJSONObject.getString("systemProductId");
        JSONArray bundledProductData = subpoolProductDataAsJSONObject.getJSONArray("bundledProductData");

        log.info("Subscribe client1 (already registered as a person under username '" + username
                + "') to subscription pool with ProductId'" + personProductId + "'...");
        personSubscriptionPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId",
                personProductId, client1tasks.getCurrentlyAllAvailableSubscriptionPools());
        Assert.assertNotNull(personSubscriptionPool, "Personal subscription with ProductId '" + personProductId
                + "' is available to user '" + username + "' registered as a person.");
        //client1tasks.subscribe(personSubscriptionPool.poolId, null, null, null, null);
        //personalEntitlementCert = client1tasks.getEntitlementCertFromEntitlementCertFile(client1tasks.subscribeToSubscriptionPool(personSubscriptionPool));
        personEntitlementCert = client1tasks.getEntitlementCertFromEntitlementCertFile(
                client1tasks.subscribeToSubscriptionPool(personSubscriptionPool,
                        /*sm_serverAdminUsername*/username, /*sm_serverAdminPassword*/password, sm_serverUrl));

        log.info("Register " + multipleSystems + " new systems under username '" + username
                + "' and subscribe to sub productId '" + systemProductId + "'...");
        systemConsumerIds = new ArrayList<String>();
        for (int systemNum = 1; systemNum <= multipleSystems; systemNum++) {
            // simulate a clean system
            client2tasks.removeAllCerts(true, true, false);

            String consumerId = client2tasks.getCurrentConsumerId(client2tasks.register(username, password,
                    owner, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null,
                    null, Boolean.TRUE, false, null, null, null));
            systemConsumerIds.add(consumerId);
            SubscriptionPool subPool = SubscriptionPool.findFirstInstanceWithMatchingFieldFromList("productId",
                    systemProductId, client2tasks.getCurrentlyAvailableSubscriptionPools());
            log.info("Subscribing system '" + systemNum + "' ('" + consumerId + "' under username '" + username
                    + "') to sub pool for productId '" + systemProductId + "'...");
            client2tasks.subscribeToSubscriptionPool(subPool);

            /* OLD ASSERTION BEFORE IMPLEMENTATION OF Bug 801187 - collapse list of provided products for subscription-manager list --consumed
            for (int k=0; k<bundledProductData.length(); k++) {
               JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
               String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
                    
               ProductSubscription productSubscription = ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName",systemConsumedProductName,client2tasks.getCurrentlyConsumedProductSubscriptions());
               Assert.assertNotNull(productSubscription,systemConsumedProductName+" is now consumed by consumer '"+consumerId+"' (registered as a system under username '"+username+"')");
            }
            */
            List<String> systemConsumedProductNames = new ArrayList<String>();
            for (int k = 0; k < bundledProductData.length(); k++) {
                JSONObject bundledProductAsJSONObject = (JSONObject) bundledProductData.get(k);
                String systemConsumedProductName = bundledProductAsJSONObject.getString("productName");
                systemConsumedProductNames.add(systemConsumedProductName);
            }
            log.info("Now client2 should be consuming the subscription '" + personSubscriptionName
                    + "' that provides '" + systemConsumedProductNames + "'...");
            ProductSubscription systemProductSubscription = ProductSubscription
                    .findFirstInstanceWithMatchingFieldFromList("productName", personSubscriptionName,
                            client2tasks.getCurrentlyConsumedProductSubscriptions());
            Assert.assertNotNull(systemProductSubscription,
                    personSubscriptionName + " is now consumed by consumer '" + consumerId
                            + "' (registered as a system under username '" + username + "')");
            Assert.assertTrue(
                    systemProductSubscription.provides.containsAll(systemConsumedProductNames)
                            && systemConsumedProductNames.containsAll(systemProductSubscription.provides),
                    "All of the expected bundled products " + systemConsumedProductNames
                            + " are now being provided for on client2 system '"
                            + client2.getConnection().getHostname() + "' consumed by consumer '" + consumerId
                            + "'.");
        }
    }
}

From source file:org.alfresco.rest.api.tests.TestCMIS.java

private void checkSecondaryTypes(Document doc, Set<String> expectedSecondaryTypes,
        Set<String> expectedMissingSecondaryTypes) {
    final List<SecondaryType> secondaryTypesList = doc.getSecondaryTypes();
    assertNotNull(secondaryTypesList);/*from  w w  w  .j a v a  2 s.c om*/
    List<String> secondaryTypes = new AbstractList<String>() {
        @Override
        public String get(int index) {
            SecondaryType type = secondaryTypesList.get(index);
            return type.getId();
        }

        @Override
        public int size() {
            return secondaryTypesList.size();
        }
    };
    if (expectedSecondaryTypes != null) {
        assertTrue("Missing secondary types: " + secondaryTypes,
                secondaryTypes.containsAll(expectedSecondaryTypes));
    }
    if (expectedMissingSecondaryTypes != null) {
        assertTrue("Expected missing secondary types but at least one is still present: " + secondaryTypes,
                !secondaryTypes.containsAll(expectedMissingSecondaryTypes));
    }
}

From source file:org.sonatype.flexmojos.compiler.AbstractCompilerMojo.java

public void rslsSort(List<Artifact> rslArtifacts) throws MojoExecutionException {
    Map<Artifact, List<Artifact>> dependencies = getDependencies(rslArtifacts);

    List<Artifact> ordered = new ArrayList<Artifact>();
    for (Artifact a : rslArtifacts) {
        if (dependencies.get(a) == null || dependencies.get(a).isEmpty()) {
            ordered.add(a);//  w  ww . java2  s  .  c om
        }
    }
    rslArtifacts.removeAll(ordered);

    while (!rslArtifacts.isEmpty()) {
        int original = rslArtifacts.size();
        for (Artifact a : rslArtifacts) {
            List<Artifact> deps = dependencies.get(a);
            if (ordered.containsAll(deps)) {
                ordered.add(a);
            }
        }
        rslArtifacts.removeAll(ordered);
        if (original == rslArtifacts.size()) {
            throw new MojoExecutionException("Unable to resolve " + rslArtifacts);
        }
    }

    rslArtifacts.addAll(ordered);
}