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;
}
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;
}
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;
}
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);
}
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);
}
Aggregations