Search in sources :

Example 86 with SubscriptionPolicy

use of org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy in project carbon-apimgt by wso2.

the class TestMappingUtilTestCase method testSubscriptionToSubscriptionDTOMapping.

@Test(description = "Subscription to Subscription DTO mapping")
void testSubscriptionToSubscriptionDTOMapping() {
    Policy subscriptionPolicy = SampleTestObjectCreator.goldSubscriptionPolicy;
    API api = SampleTestObjectCreator.createDefaultAPI().build();
    Application application = SampleTestObjectCreator.createDefaultApplication();
    String uuid = UUID.randomUUID().toString();
    Subscription subscription = new Subscription(uuid, application, api, subscriptionPolicy);
    subscription.setStatus(APIMgtConstants.SubscriptionStatus.ACTIVE);
    SubscriptionDTO subscriptionDTO = MappingUtil.fromSubscription(subscription);
    assertEquals(subscription.getId(), subscriptionDTO.getSubscriptionId());
    assertEquals(subscription.getStatus().name(), subscriptionDTO.getSubscriptionStatus().name());
    assertEquals(subscription.getApplication().getId(), subscriptionDTO.getApplicationInfo().getApplicationId());
    assertEquals(subscription.getPolicy().getPolicyName(), subscriptionDTO.getPolicy());
}
Also used : Policy(org.wso2.carbon.apimgt.core.models.policy.Policy) API(org.wso2.carbon.apimgt.core.models.API) Subscription(org.wso2.carbon.apimgt.core.models.Subscription) Application(org.wso2.carbon.apimgt.core.models.Application) SubscriptionDTO(org.wso2.carbon.apimgt.rest.api.publisher.dto.SubscriptionDTO) Test(org.testng.annotations.Test)

Aggregations

SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)74 Test (org.testng.annotations.Test)41 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)33 API (org.wso2.carbon.apimgt.core.models.API)30 APIPolicy (org.wso2.carbon.apimgt.core.models.policy.APIPolicy)30 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)24 APIBuilder (org.wso2.carbon.apimgt.core.models.API.APIBuilder)21 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)19 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)16 APILifecycleManager (org.wso2.carbon.apimgt.core.api.APILifecycleManager)15 GatewaySourceGenerator (org.wso2.carbon.apimgt.core.api.GatewaySourceGenerator)15 Policy (org.wso2.carbon.apimgt.core.models.policy.Policy)15 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)14 ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)14 RequestCountLimit (org.wso2.carbon.apimgt.core.models.policy.RequestCountLimit)13 ArrayList (java.util.ArrayList)12 QuotaPolicy (org.wso2.carbon.apimgt.core.models.policy.QuotaPolicy)12 HashSet (java.util.HashSet)10 Application (org.wso2.carbon.apimgt.core.models.Application)9 SQLException (java.sql.SQLException)8