Java 类com.amazonaws.services.apigateway.model.Models 实例源码

项目:aws-apigateway-swagger-exporter    文件:APIGExporter.java   
private static Map<String, io.swagger.models.Model> getDefinitions(RestApi restApi)
        throws IOException, JsonParseException, JsonMappingException {
    Map<String, io.swagger.models.Model> result = new HashMap<String, io.swagger.models.Model>();
    for (Models models = restApi.getModels(); models != null; models = safeGetNext(models)) {
        for (Model modelItem : models.getItem()) {
            String content = modelItem.getSchema(); 
            io.swagger.models.Model model = 
                    Json.mapper().readValue(content, io.swagger.models.Model.class);
            if (model instanceof ModelImpl) {
                ((ModelImpl) model).setName(modelItem.getName());
            }
            model.setDescription(modelItem.getDescription());
            result.put(modelItem.getName(), model);
        }
    }
    return result;
}
项目:aws-apigateway-importer    文件:ApiGatewaySdkApiImporter.java   
protected List<Model> buildModelList(RestApi api) {
    List<Model> modelList = new ArrayList<>();

    Models models = api.getModels();
    modelList.addAll(models.getItem());

    while (models._isLinkAvailable("next")) {
        models = models.getNext();
        modelList.addAll(models.getItem());
    }

    return modelList;
}
项目:aws-api-gateway    文件:ApiGatewaySdkApiImporter.java   
protected List<Model> buildModelList(RestApi api) {
    List<Model> modelList = new ArrayList<>();

    Models models = api.getModels();
    modelList.addAll(models.getItem());

    while (models._isLinkAvailable("next")) {
        models = models.getNext();
        modelList.addAll(models.getItem());
    }

    return modelList;
}
项目:aws-apigateway-swagger-exporter    文件:APIGExporter.java   
private static Models safeGetNext(Models models) {
    try {
        return models.getNext();
    } catch (UnsupportedOperationException e) {
        return null;
    }
}
项目:aws-apigateway-importer    文件:ApiGatewaySwaggerFileImporterTest.java   
@Before
public void setUp() throws Exception {
    BasicConfigurator.configure();

    Injector injector = Guice.createInjector(new SwaggerApiImporterTestModule());

    client = injector.getInstance(ApiGateway.class);
    importer = injector.getInstance(SwaggerApiFileImporter.class);

    RestApis mockRestApis = mock(RestApis.class);
    Integration mockIntegration = Mockito.mock(Integration.class);

    Method mockMethod = Mockito.mock(Method.class);
    when(mockMethod.getHttpMethod()).thenReturn("GET");
    when(mockMethod.putIntegration(any())).thenReturn(mockIntegration);

    mockChildResource = Mockito.mock(Resource.class);
    when(mockChildResource.getPath()).thenReturn("/child");
    when(mockChildResource.putMethod(any(), any())).thenReturn(mockMethod);

    mockResource = Mockito.mock(Resource.class);
    when(mockResource.getPath()).thenReturn("/");
    when(mockResource.createResource(any())).thenReturn(mockChildResource);
    when(mockResource.putMethod(any(), any())).thenReturn(mockMethod);

    Resources mockResources = mock(Resources.class);
    when(mockResources.getItem()).thenReturn(Arrays.asList(mockResource));

    Model mockModel = Mockito.mock(Model.class);
    when(mockModel.getName()).thenReturn("test model");

    Models mockModels = mock(Models.class);
    when(mockModels.getItem()).thenReturn(Arrays.asList(mockModel));

    mockRestApi = mock(RestApi.class);
    when(mockRestApi.getResources()).thenReturn(mockResources);
    when(mockRestApi.getModels()).thenReturn(mockModels);
    when(mockRestApi.getResourceById(any())).thenReturn(mockResource);

    when(client.getRestApis()).thenReturn(mockRestApis);
    when(client.createRestApi(any())).thenReturn(mockRestApi);

    importer.importApi(getResourcePath(API_GATEWAY));
}
项目:aws-api-gateway    文件:ApiGatewaySwaggerFileImporterTest.java   
@Before
public void setUp() throws Exception {
    BasicConfigurator.configure();

    Injector injector = Guice.createInjector(new SwaggerApiImporterTestModule());

    client = injector.getInstance(ApiGateway.class);
    importer = injector.getInstance(SwaggerApiFileImporter.class);

    RestApis mockRestApis = mock(RestApis.class);
    Integration mockIntegration = Mockito.mock(Integration.class);

    Method mockMethod = Mockito.mock(Method.class);
    when(mockMethod.getHttpMethod()).thenReturn("GET");
    when(mockMethod.putIntegration(any())).thenReturn(mockIntegration);

    mockChildResource = Mockito.mock(Resource.class);
    when(mockChildResource.getPath()).thenReturn("/child");
    when(mockChildResource.putMethod(any(), any())).thenReturn(mockMethod);

    mockResource = Mockito.mock(Resource.class);
    when(mockResource.getPath()).thenReturn("/");
    when(mockResource.createResource(any())).thenReturn(mockChildResource);
    when(mockResource.putMethod(any(), any())).thenReturn(mockMethod);

    Resources mockResources = mock(Resources.class);
    when(mockResources.getItem()).thenReturn(Arrays.asList(mockResource));

    Model mockModel = Mockito.mock(Model.class);
    when(mockModel.getName()).thenReturn("test model");

    Models mockModels = mock(Models.class);
    when(mockModels.getItem()).thenReturn(Arrays.asList(mockModel));

    mockRestApi = mock(RestApi.class);
    when(mockRestApi.getResources()).thenReturn(mockResources);
    when(mockRestApi.getModels()).thenReturn(mockModels);
    when(mockRestApi.getResourceById(any())).thenReturn(mockResource);

    when(client.getRestApis()).thenReturn(mockRestApis);
    when(client.createRestApi(any())).thenReturn(mockRestApi);

    importer.importApi(getResourcePath(API_GATEWAY));
}