use of org.wso2.carbon.apimgt.rest.integration.tests.publisher.model.APIList in project carbon-apimgt by wso2.
the class MappingUtil method toAPIInfo.
/**
* Converts {@link API} List to an {@link APIInfoDTO} List.
*
* @param apiList
* @return
*/
private static List<APIInfoDTO> toAPIInfo(List<API> apiList) {
List<APIInfoDTO> apiInfoList = new ArrayList<APIInfoDTO>();
for (API api : apiList) {
APIInfoDTO apiInfo = new APIInfoDTO();
apiInfo.setId(api.getId());
apiInfo.setContext(api.getContext());
apiInfo.setName(api.getName());
apiInfo.setLifeCycleStatus(api.getLifeCycleStatus());
apiInfo.setVersion(api.getVersion());
apiInfo.setSecurityScheme(api.getSecurityScheme());
for (String threatProtectionPolicyId : api.getThreatProtectionPolicies()) {
apiInfo.addThreatProtectionPoliciesItem(threatProtectionPolicyId);
}
apiInfoList.add(apiInfo);
}
return apiInfoList;
}
use of org.wso2.carbon.apimgt.rest.integration.tests.publisher.model.APIList in project carbon-apimgt by wso2.
the class ApisApiServiceImplTestCase method apisGetTestCase.
@Test
public void apisGetTestCase() throws Exception {
String labels = "ZONE_ONE,ZONE_TWO";
String[] gatewayLabels = labels.split(",");
List<String> labelList = new ArrayList<String>(Arrays.asList(gatewayLabels));
APIMgtAdminServiceImpl apiMgtAdminService = Mockito.mock(APIMgtAdminServiceImpl.class);
PowerMockito.mockStatic(RestApiUtil.class);
PowerMockito.when(RestApiUtil.getAPIMgtAdminService()).thenReturn(apiMgtAdminService);
List<API> apiList = new ArrayList<>();
apiList.add(SampleTestObjectCreator.createUniqueAPI().build());
apiList.add(SampleTestObjectCreator.createUniqueAPI().build());
apiList.add(SampleTestObjectCreator.createUniqueAPI().build());
Mockito.when(apiMgtAdminService.getAPIsByStatus(labelList, "Published")).thenReturn(apiList);
ApisApiServiceImpl apisApiService = new ApisApiServiceImpl();
Response response = apisApiService.apisGet(labels, "Published", getRequest());
Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
Integer count = ((APIListDTO) response.getEntity()).getCount();
Assert.assertEquals(count.intValue(), 3);
}
use of org.wso2.carbon.apimgt.rest.integration.tests.publisher.model.APIList in project carbon-apimgt by wso2.
the class MappingUtilTestCase method toAPIListDTOTest.
@Test
public void toAPIListDTOTest() {
List<API> apiList = new ArrayList<>();
apiList.add(SampleTestObjectCreator.createUniqueAPI().build());
apiList.add(SampleTestObjectCreator.createUniqueAPI().build());
apiList.add(SampleTestObjectCreator.createUniqueAPI().build());
APIListDTO apDTOList = MappingUtil.toAPIListDTO(apiList);
Assert.assertEquals(apiList.size(), apDTOList.getList().size());
}
use of org.wso2.carbon.apimgt.rest.integration.tests.publisher.model.APIList in project carbon-apimgt by wso2.
the class ApiDAOImpl method getCompositeAPISummaryList.
private List<CompositeAPI> getCompositeAPISummaryList(Connection connection, PreparedStatement statement) throws SQLException, APIMgtDAOException {
List<CompositeAPI> apiList = new ArrayList<>();
try (ResultSet rs = statement.executeQuery()) {
while (rs.next()) {
String apiPrimaryKey = rs.getString("UUID");
CompositeAPI apiSummary = new CompositeAPI.Builder().id(apiPrimaryKey).provider(rs.getString("PROVIDER")).name(rs.getString("NAME")).version(rs.getString("VERSION")).context(rs.getString("CONTEXT")).description(rs.getString("DESCRIPTION")).applicationId(getCompositeAPIApplicationId(connection, apiPrimaryKey)).workflowStatus(rs.getString("LC_WORKFLOW_STATUS")).threatProtectionPolicies(getThreatProtectionPolicies(connection, apiPrimaryKey)).build();
apiList.add(apiSummary);
}
}
return apiList;
}
use of org.wso2.carbon.apimgt.rest.integration.tests.publisher.model.APIList in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method createMockAPIList.
public static List<API> createMockAPIList() {
List<API> apiList = new ArrayList<>();
API api1 = createDefaultAPI().build();
API api2 = createAlternativeAPI().build();
apiList.add(api1);
apiList.add(api2);
return apiList;
}
Aggregations