Search in sources :

Example 1 with TierNameComparator

use of org.wso2.carbon.apimgt.impl.utils.TierNameComparator in project carbon-apimgt by wso2.

the class AbstractAPIManager method getTiers.

/**
 * Returns a list of pre-defined # {@link org.wso2.carbon.apimgt.api.model.Tier} in the system.
 *
 * @return Set<Tier>
 */
public Set<Tier> getTiers() throws APIManagementException {
    Set<Tier> tiers = new TreeSet<Tier>(new TierNameComparator());
    Map<String, Tier> tierMap = APIUtil.getTiersFromPolicies(PolicyConstants.POLICY_LEVEL_SUB, tenantId);
    tiers.addAll(tierMap.values());
    return tiers;
}
Also used : Tier(org.wso2.carbon.apimgt.api.model.Tier) TreeSet(java.util.TreeSet) TierNameComparator(org.wso2.carbon.apimgt.impl.utils.TierNameComparator)

Example 2 with TierNameComparator

use of org.wso2.carbon.apimgt.impl.utils.TierNameComparator in project carbon-apimgt by wso2.

the class AbstractAPIManager method getAllTiers.

public Set<Tier> getAllTiers() throws APIManagementException {
    Set<Tier> tiers = new TreeSet<Tier>(new TierNameComparator());
    Map<String, Tier> tierMap;
    if (tenantId == MultitenantConstants.INVALID_TENANT_ID) {
        tierMap = APIUtil.getAllTiers();
    } else {
        boolean isTenantFlowStarted = false;
        try {
            if (tenantDomain != null && !MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
                startTenantFlow(tenantDomain);
                isTenantFlowStarted = true;
            }
            tierMap = APIUtil.getAllTiers(tenantId);
        } finally {
            if (isTenantFlowStarted) {
                endTenantFlow();
            }
        }
    }
    tiers.addAll(tierMap.values());
    return tiers;
}
Also used : Tier(org.wso2.carbon.apimgt.api.model.Tier) TreeSet(java.util.TreeSet) TierNameComparator(org.wso2.carbon.apimgt.impl.utils.TierNameComparator)

Example 3 with TierNameComparator

use of org.wso2.carbon.apimgt.impl.utils.TierNameComparator in project carbon-apimgt by wso2.

the class AbstractAPIManager method getTiers.

/**
 * Returns a list of pre-defined # {@link org.wso2.carbon.apimgt.api.model.Tier} in the system.
 *
 * @return Set<Tier>
 */
public Set<Tier> getTiers(String tenantDomain) throws APIManagementException {
    Set<Tier> tiers = new TreeSet<Tier>(new TierNameComparator());
    Map<String, Tier> tierMap = APIUtil.getTiersFromPolicies(PolicyConstants.POLICY_LEVEL_SUB, tenantId);
    tiers.addAll(tierMap.values());
    return tiers;
}
Also used : Tier(org.wso2.carbon.apimgt.api.model.Tier) TreeSet(java.util.TreeSet) TierNameComparator(org.wso2.carbon.apimgt.impl.utils.TierNameComparator)

Example 4 with TierNameComparator

use of org.wso2.carbon.apimgt.impl.utils.TierNameComparator in project carbon-apimgt by wso2.

the class TierNameComparatorTest method testCompareNotEquals.

@Test
public void testCompareNotEquals() {
    TierNameComparator tierNameComparator = new TierNameComparator();
    Tier tier1 = new Tier("GOLD");
    tier1.setDisplayName("GOLD");
    Tier tier2 = new Tier("SILVER");
    tier2.setDisplayName("SILVER");
    int result = tierNameComparator.compare(tier1, tier2);
    Assert.assertNotEquals(0, result);
}
Also used : Tier(org.wso2.carbon.apimgt.api.model.Tier) TierNameComparator(org.wso2.carbon.apimgt.impl.utils.TierNameComparator) Test(org.junit.Test)

Example 5 with TierNameComparator

use of org.wso2.carbon.apimgt.impl.utils.TierNameComparator in project carbon-apimgt by wso2.

the class TierNameComparatorTest method testCompareWhenDisplayNameNotSetEquals.

@Test
public void testCompareWhenDisplayNameNotSetEquals() {
    TierNameComparator tierNameComparator = new TierNameComparator();
    Tier tier1 = new Tier("GOLD");
    Tier tier2 = new Tier("GOLD");
    int result = tierNameComparator.compare(tier1, tier2);
    Assert.assertEquals(0, result);
}
Also used : Tier(org.wso2.carbon.apimgt.api.model.Tier) TierNameComparator(org.wso2.carbon.apimgt.impl.utils.TierNameComparator) Test(org.junit.Test)

Aggregations

Tier (org.wso2.carbon.apimgt.api.model.Tier)9 TierNameComparator (org.wso2.carbon.apimgt.impl.utils.TierNameComparator)9 TreeSet (java.util.TreeSet)5 Test (org.junit.Test)4 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1