@Provides protected ApiGateway provideAmazonApiGateway(AWSCredentialsProvider credsProvider, RetryPolicy.BackoffStrategy backoffStrategy, @Named("region") String region) { final RetryPolicy retrypolicy = new RetryPolicy(PredefinedRetryPolicies.DEFAULT_RETRY_CONDITION, backoffStrategy, 5, true); final ClientConfiguration clientConfig = new ClientConfiguration().withUserAgent(USER_AGENT).withRetryPolicy(retrypolicy); return new AmazonApiGateway(getEndpoint(region)).with(credsProvider).with(clientConfig).getApiGateway(); }
public AmazonApiGateway(String endpoint, String regionId) { Map<Integer, Class<? extends AmazonServiceException>> exceptionClasses = new HashMap<>(); exceptionClasses.put(400, BadRequestException.class); exceptionClasses.put(401, UnauthorizedException.class); exceptionClasses.put(404, NotFoundException.class); exceptionClasses.put(409, ConflictException.class); exceptionClasses.put(429, TooManyRequestsException.class); exceptionClasses.put(503, ServiceUnavailableException.class); this.amazonApiGatewayService = new HalService<>(endpoint == null ? DEFAULT_ENDPOINT : endpoint, SERVICE_NAME, regionId, ApiGateway.class, new StatusCodeErrorResponseHandler(exceptionClasses)); }
@Override protected void configure() { bind(SwaggerApiFileImporter.class).to(ApiGatewaySwaggerFileImporter.class); bind(SwaggerApiImporter.class).to(ApiGatewaySdkSwaggerApiImporter.class); bind(ApiGateway.class).toInstance(Mockito.mock(ApiGateway.class)); }
@Override protected void configure() { bind(RamlApiFileImporter.class).to(ApiGatewayRamlFileImporter.class); bind(RamlApiImporter.class).to(ApiGatewaySdkRamlApiImporter.class); bind(ApiGateway.class).toInstance(Mockito.mock(ApiGateway.class)); }
@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)); }
public ApiGateway getApiGateway() { return amazonApiGatewayService.getRootResource(); }