├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── NOTICE
├── README.md
├── analytics
├── README.md
├── buildspec-integ-test.yaml
├── buildspec.yaml
├── pom.xml
├── sam
│ ├── app
│ │ └── template.yaml
│ └── cicd
│ │ └── template.yaml
└── src
│ └── test
│ ├── java
│ └── software
│ │ └── amazon
│ │ └── serverless
│ │ └── apprepo
│ │ ├── api
│ │ └── client
│ │ │ ├── AWSServerlessApplicationRepository.java
│ │ │ ├── AWSServerlessApplicationRepositoryClient.java
│ │ │ ├── AWSServerlessApplicationRepositoryClientBuilder.java
│ │ │ ├── AbstractAWSServerlessApplicationRepository.java
│ │ │ ├── auth
│ │ │ └── CognitoAuthorizer.java
│ │ │ ├── model
│ │ │ ├── AWSServerlessApplicationRepositoryException.java
│ │ │ ├── Application.java
│ │ │ ├── ApplicationList.java
│ │ │ ├── ApplicationSummary.java
│ │ │ ├── BadRequestException.java
│ │ │ ├── ConflictException.java
│ │ │ ├── CreateApplicationInput.java
│ │ │ ├── CreateApplicationRequest.java
│ │ │ ├── CreateApplicationResult.java
│ │ │ ├── DeleteApplicationRequest.java
│ │ │ ├── DeleteApplicationResult.java
│ │ │ ├── GetApplicationRequest.java
│ │ │ ├── GetApplicationResult.java
│ │ │ ├── InternalServerErrorException.java
│ │ │ ├── ListApplicationsRequest.java
│ │ │ ├── ListApplicationsResult.java
│ │ │ ├── NotFoundException.java
│ │ │ ├── TooManyRequestsException.java
│ │ │ ├── UnauthorizedException.java
│ │ │ ├── UpdateApplicationInput.java
│ │ │ ├── UpdateApplicationRequest.java
│ │ │ ├── UpdateApplicationResult.java
│ │ │ └── transform
│ │ │ │ ├── ApplicationJsonUnmarshaller.java
│ │ │ │ ├── ApplicationListJsonUnmarshaller.java
│ │ │ │ ├── ApplicationListMarshaller.java
│ │ │ │ ├── ApplicationMarshaller.java
│ │ │ │ ├── ApplicationSummaryJsonUnmarshaller.java
│ │ │ │ ├── ApplicationSummaryMarshaller.java
│ │ │ │ ├── CreateApplicationInputJsonUnmarshaller.java
│ │ │ │ ├── CreateApplicationInputMarshaller.java
│ │ │ │ ├── CreateApplicationRequestMarshaller.java
│ │ │ │ ├── CreateApplicationRequestProtocolMarshaller.java
│ │ │ │ ├── CreateApplicationResultJsonUnmarshaller.java
│ │ │ │ ├── DeleteApplicationRequestMarshaller.java
│ │ │ │ ├── DeleteApplicationRequestProtocolMarshaller.java
│ │ │ │ ├── DeleteApplicationResultJsonUnmarshaller.java
│ │ │ │ ├── GetApplicationRequestMarshaller.java
│ │ │ │ ├── GetApplicationRequestProtocolMarshaller.java
│ │ │ │ ├── GetApplicationResultJsonUnmarshaller.java
│ │ │ │ ├── ListApplicationsRequestMarshaller.java
│ │ │ │ ├── ListApplicationsRequestProtocolMarshaller.java
│ │ │ │ ├── ListApplicationsResultJsonUnmarshaller.java
│ │ │ │ ├── UpdateApplicationInputJsonUnmarshaller.java
│ │ │ │ ├── UpdateApplicationInputMarshaller.java
│ │ │ │ ├── UpdateApplicationRequestMarshaller.java
│ │ │ │ ├── UpdateApplicationRequestProtocolMarshaller.java
│ │ │ │ └── UpdateApplicationResultJsonUnmarshaller.java
│ │ │ └── package-info.java
│ │ └── cucumber
│ │ ├── ApplicationsService_IT.java
│ │ ├── features
│ │ └── AthenaQuery.feature
│ │ ├── guice
│ │ ├── ApplicationModule.java
│ │ ├── CognitoAuthorizerImpl.java
│ │ └── CukeInjectorSource.java
│ │ └── steps
│ │ ├── AWSServerlessApplicationRepositoryRecordingClient.java
│ │ ├── AthenaQuerySteps.java
│ │ ├── CognitoUserManager.java
│ │ ├── S3Helper.java
│ │ ├── SetupAndTeardownSteps.java
│ │ └── TestEnv.java
│ └── resources
│ ├── cucumber.properties
│ ├── integ-test-env.template.yaml
│ └── log4j2.properties
├── backend
├── README.md
├── buildspec-integ-test.yaml
├── buildspec.yaml
├── images
│ └── back_end_diagram.png
├── pom.xml
├── sam
│ ├── app
│ │ ├── api.template.yaml
│ │ ├── database.template.yaml
│ │ └── template.yaml
│ └── cicd
│ │ └── template.yaml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── software
│ │ │ │ └── amazon
│ │ │ │ └── serverless
│ │ │ │ └── apprepo
│ │ │ │ ├── api
│ │ │ │ ├── exception
│ │ │ │ │ ├── ApiException.java
│ │ │ │ │ ├── ApiExceptionMapper.java
│ │ │ │ │ ├── BadRequestApiException.java
│ │ │ │ │ ├── ConflictApiException.java
│ │ │ │ │ ├── InternalServerApiException.java
│ │ │ │ │ └── NotFoundApiException.java
│ │ │ │ └── impl
│ │ │ │ │ ├── ApplicationRecord.java
│ │ │ │ │ ├── ApplicationsService.java
│ │ │ │ │ └── pagination
│ │ │ │ │ ├── DynamoDbStartKeySerializer.java
│ │ │ │ │ ├── EncryptedTokenSerializer.java
│ │ │ │ │ ├── InvalidTokenException.java
│ │ │ │ │ ├── PaginationTokenSerializer.java
│ │ │ │ │ ├── TimeBasedTokenSerializer.java
│ │ │ │ │ ├── TokenSerializer.java
│ │ │ │ │ └── jackson
│ │ │ │ │ ├── AttributeValueDeserializer.java
│ │ │ │ │ ├── AttributeValueSerializer.java
│ │ │ │ │ ├── SdkBytesDeserializer.java
│ │ │ │ │ └── SdkBytesSerializer.java
│ │ │ │ └── container
│ │ │ │ ├── ApiLambdaHandler.java
│ │ │ │ ├── CorsHeadersResponseFilter.java
│ │ │ │ ├── config
│ │ │ │ ├── ConfigProvider.java
│ │ │ │ ├── Env.java
│ │ │ │ └── SsmConfigProvider.java
│ │ │ │ └── factory
│ │ │ │ ├── DynamoDbClientFactory.java
│ │ │ │ ├── KmsClientFactory.java
│ │ │ │ └── SsmConfigProviderFactory.java
│ │ └── resources
│ │ │ └── log4j.properties
│ └── test
│ │ ├── java
│ │ └── software
│ │ │ └── amazon
│ │ │ └── serverless
│ │ │ └── apprepo
│ │ │ ├── api
│ │ │ ├── client
│ │ │ │ ├── AWSServerlessApplicationRepository.java
│ │ │ │ ├── AWSServerlessApplicationRepositoryClient.java
│ │ │ │ ├── AWSServerlessApplicationRepositoryClientBuilder.java
│ │ │ │ ├── AbstractAWSServerlessApplicationRepository.java
│ │ │ │ ├── auth
│ │ │ │ │ └── CognitoAuthorizer.java
│ │ │ │ ├── model
│ │ │ │ │ ├── AWSServerlessApplicationRepositoryException.java
│ │ │ │ │ ├── Application.java
│ │ │ │ │ ├── ApplicationList.java
│ │ │ │ │ ├── ApplicationSummary.java
│ │ │ │ │ ├── BadRequestException.java
│ │ │ │ │ ├── ConflictException.java
│ │ │ │ │ ├── CreateApplicationInput.java
│ │ │ │ │ ├── CreateApplicationRequest.java
│ │ │ │ │ ├── CreateApplicationResult.java
│ │ │ │ │ ├── DeleteApplicationRequest.java
│ │ │ │ │ ├── DeleteApplicationResult.java
│ │ │ │ │ ├── GetApplicationRequest.java
│ │ │ │ │ ├── GetApplicationResult.java
│ │ │ │ │ ├── InternalServerErrorException.java
│ │ │ │ │ ├── ListApplicationsRequest.java
│ │ │ │ │ ├── ListApplicationsResult.java
│ │ │ │ │ ├── NotFoundException.java
│ │ │ │ │ ├── TooManyRequestsException.java
│ │ │ │ │ ├── UnauthorizedException.java
│ │ │ │ │ ├── UpdateApplicationInput.java
│ │ │ │ │ ├── UpdateApplicationRequest.java
│ │ │ │ │ ├── UpdateApplicationResult.java
│ │ │ │ │ └── transform
│ │ │ │ │ │ ├── ApplicationJsonUnmarshaller.java
│ │ │ │ │ │ ├── ApplicationListJsonUnmarshaller.java
│ │ │ │ │ │ ├── ApplicationListMarshaller.java
│ │ │ │ │ │ ├── ApplicationMarshaller.java
│ │ │ │ │ │ ├── ApplicationSummaryJsonUnmarshaller.java
│ │ │ │ │ │ ├── ApplicationSummaryMarshaller.java
│ │ │ │ │ │ ├── CreateApplicationInputJsonUnmarshaller.java
│ │ │ │ │ │ ├── CreateApplicationInputMarshaller.java
│ │ │ │ │ │ ├── CreateApplicationRequestMarshaller.java
│ │ │ │ │ │ ├── CreateApplicationRequestProtocolMarshaller.java
│ │ │ │ │ │ ├── CreateApplicationResultJsonUnmarshaller.java
│ │ │ │ │ │ ├── DeleteApplicationRequestMarshaller.java
│ │ │ │ │ │ ├── DeleteApplicationRequestProtocolMarshaller.java
│ │ │ │ │ │ ├── DeleteApplicationResultJsonUnmarshaller.java
│ │ │ │ │ │ ├── GetApplicationRequestMarshaller.java
│ │ │ │ │ │ ├── GetApplicationRequestProtocolMarshaller.java
│ │ │ │ │ │ ├── GetApplicationResultJsonUnmarshaller.java
│ │ │ │ │ │ ├── ListApplicationsRequestMarshaller.java
│ │ │ │ │ │ ├── ListApplicationsRequestProtocolMarshaller.java
│ │ │ │ │ │ ├── ListApplicationsResultJsonUnmarshaller.java
│ │ │ │ │ │ ├── UpdateApplicationInputJsonUnmarshaller.java
│ │ │ │ │ │ ├── UpdateApplicationInputMarshaller.java
│ │ │ │ │ │ ├── UpdateApplicationRequestMarshaller.java
│ │ │ │ │ │ ├── UpdateApplicationRequestProtocolMarshaller.java
│ │ │ │ │ │ └── UpdateApplicationResultJsonUnmarshaller.java
│ │ │ │ └── package-info.java
│ │ │ ├── exception
│ │ │ │ └── ApiExceptionMapperTest.java
│ │ │ └── impl
│ │ │ │ ├── ApplicationsServiceTest.java
│ │ │ │ └── pagination
│ │ │ │ ├── DynamoDbStartKeySerializerTest.java
│ │ │ │ ├── EncryptedTokenSerializerTest.java
│ │ │ │ └── TimeBasedTokenSerializerTest.java
│ │ │ └── cucumber
│ │ │ ├── ApplicationsService_IT.java
│ │ │ ├── features
│ │ │ ├── CreateApplication.feature
│ │ │ ├── DeleteApplication.feature
│ │ │ ├── GetApplication.feature
│ │ │ ├── ListApplications.feature
│ │ │ └── UpdateApplication.feature
│ │ │ ├── guice
│ │ │ ├── ApplicationModule.java
│ │ │ ├── CognitoAuthorizerImpl.java
│ │ │ └── CukeInjectorSource.java
│ │ │ └── steps
│ │ │ ├── AWSServerlessApplicationRepositoryRecordingClient.java
│ │ │ ├── CognitoUserManager.java
│ │ │ ├── CommonSteps.java
│ │ │ ├── CreateApplicationSteps.java
│ │ │ ├── DeleteApplicationSteps.java
│ │ │ ├── GetApplicationSteps.java
│ │ │ ├── ListApplicationsSteps.java
│ │ │ ├── SetupAndTeardownSteps.java
│ │ │ ├── TestEnv.java
│ │ │ └── UpdateApplicationSteps.java
│ │ └── resources
│ │ ├── cucumber.properties
│ │ └── integ-test-env.template.yaml
└── swagger
│ └── api.yaml
├── bin
├── delete-stack.sh
├── deploy.sh
├── generate-sdk.sh
└── package.sh
├── buildspec.yaml
├── images
└── architecture_diagram.png
├── ops
├── README.md
├── buildspec.yaml
├── images
│ ├── alarm-email.png
│ ├── alarms.png
│ └── dashboard.png
└── sam
│ ├── app
│ ├── alarm.template.yaml
│ ├── dashboard.template.yaml
│ └── template.yaml
│ └── cicd
│ └── template.yaml
├── pom.xml
├── sam
└── app
│ └── template.yaml
└── static-website
├── .browserslistrc
├── .editorconfig
├── .eslintrc.js
├── .gitignore
├── README.md
├── babel.config.js
├── bin
└── package-static-website.sh
├── buildspec-integ-test.yaml
├── buildspec.yaml
├── images
└── sign-in.png
├── nightwatch.conf.js
├── package-lock.json
├── package.json
├── postcss.config.js
├── public
├── favicon.ico
└── index.html
├── sam
├── app
│ └── template.yaml
└── cicd
│ └── template.yaml
├── src
├── App.vue
├── assets
│ └── logo.png
├── components
│ ├── Breadcrumb.vue
│ ├── ErrorAlert.vue
│ └── Nav.vue
├── config.js
├── main.js
├── plugins
│ └── bootstrap-vue.js
├── router.js
├── services
│ └── sar-api.js
├── store
│ ├── actions.type.js
│ ├── auth.module.js
│ ├── index.js
│ ├── mutations.type.js
│ └── sar.module.js
└── views
│ ├── Applications.vue
│ ├── EditApplication.vue
│ ├── Home.vue
│ ├── NewApplication.vue
│ ├── SignIn.vue
│ └── ViewApplication.vue
├── tests
├── e2e
│ ├── custom-assertions
│ │ └── elementCount.js
│ ├── page-objects
│ │ ├── appDetails.js
│ │ ├── editApp.js
│ │ ├── myApps.js
│ │ ├── publishApp.js
│ │ ├── signIn.js
│ │ └── welcome.js
│ ├── specs
│ │ └── applications.js
│ └── utils
│ │ └── cognitoAdmin.js
├── setup.js
└── unit
│ ├── .eslintrc.js
│ ├── components
│ └── Nav.spec.js
│ └── views
│ ├── Applications.spec.js
│ ├── EditApplication.spec.js
│ ├── Home.spec.js
│ ├── NewApplication.spec.js
│ └── ViewApplication.spec.js
└── vue.config.js
/.gitignore:
--------------------------------------------------------------------------------
1 | /eclipse-bin/
2 | *.iml
3 | .classpath
4 | .settings
5 | .project
6 | build
7 | .*.sw[op]
8 | */.DS_Store
9 | .idea/
10 | *target/
11 |
12 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
5 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## realworld-serverless-application 
2 |
3 | This project is an adaptation of the [AWS Serverless Application Repository](https://aws.amazon.com/serverless/serverlessrepo/). Its primary objective is to serve as a case study of how to build a real world application using a combination of serverless technologies and approaches. The project captures key architectural components, code structure, deployment techniques, testing approaches, and operational practices of the AWS Serverless Application Repository - a production-grade AWS service, written in Java and built using serverless technologies. It is comprised of 4 components.
4 |
5 | 
6 |
7 | To get started, see the [Quick Start](https://github.com/awslabs/realworld-serverless-application/wiki/Quick-Start) guide. For more details, read our [blog post](https://aws.amazon.com/blogs/opensource/real-world-serverless-application) and see our [project wiki](https://github.com/awslabs/realworld-serverless-application/wiki).
8 |
9 | ## License
10 |
11 | This project is licensed under the Apache-2.0 License.
12 |
--------------------------------------------------------------------------------
/analytics/README.md:
--------------------------------------------------------------------------------
1 | # realworld-serverless-application-analytics
2 |
3 | realworld-serverless-application-analytics is the analytics component of a larger project providing business intelligence queries via Amazon Athena for the application. It can be deployed together with the other system components to produce an example serverless application demonstrating real world patterns and best practices for serverless applications.
4 |
5 | To get started with the full project, follow the [Quick Start](https://github.com/awslabs/realworld-serverless-application/wiki/Quick-Start) guide.
6 |
7 | ## License
8 |
9 | This project is licensed under the Apache-2.0 License.
10 |
--------------------------------------------------------------------------------
/analytics/buildspec-integ-test.yaml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | java: openjdk8
7 | build:
8 | commands:
9 | - TEST_STAGE=integtests`date +%s`
10 | - cd backend
11 | - mvn clean package -DpackageBucket=${PACKAGE_BUCKET}
12 | - cd ..
13 | - ./bin/deploy.sh -n $TEST_STAGE-backend -t backend/target/sam/app/packaged-template.yaml -o "Stage=$TEST_STAGE"
14 | - cd analytics
15 | - mvn clean verify -Dintegtests.stage=${TEST_STAGE} -DpackageBucket=${PACKAGE_BUCKET}
16 | finally:
17 | - cd $CODEBUILD_SRC_DIR
18 | # Cleanup commands end with "|| true" to ensure that all of them are executed. It's ok if they fail trying to delete a resource that was never created due to a build phase error.
19 | - ./bin/delete-stack.sh -n $TEST_STAGE-backend || true
--------------------------------------------------------------------------------
/analytics/buildspec.yaml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | java: openjdk8 # Runtime version is required in the build spec even though this module does not use java
7 | build:
8 | commands:
9 | - bin/package.sh -n analytics
10 | artifacts:
11 | files:
12 | - analytics/target/sam/app/packaged-template.yaml
13 | discard-paths: yes
14 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/AbstractAWSServerlessApplicationRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client;
5 |
6 | import javax.annotation.Generated;
7 | import software.amazon.serverless.apprepo.api.client.model.*;
8 | import com.amazonaws.*;
9 | import com.amazonaws.opensdk.*;
10 | import com.amazonaws.opensdk.model.*;
11 |
12 | /**
13 | * Abstract implementation of {@code AWSServerlessApplicationRepository}.
14 | */
15 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
16 | public class AbstractAWSServerlessApplicationRepository implements AWSServerlessApplicationRepository {
17 |
18 | protected AbstractAWSServerlessApplicationRepository() {
19 | }
20 |
21 | @Override
22 | public CreateApplicationResult createApplication(CreateApplicationRequest request) {
23 | throw new java.lang.UnsupportedOperationException();
24 | }
25 |
26 | @Override
27 | public DeleteApplicationResult deleteApplication(DeleteApplicationRequest request) {
28 | throw new java.lang.UnsupportedOperationException();
29 | }
30 |
31 | @Override
32 | public GetApplicationResult getApplication(GetApplicationRequest request) {
33 | throw new java.lang.UnsupportedOperationException();
34 | }
35 |
36 | @Override
37 | public ListApplicationsResult listApplications(ListApplicationsRequest request) {
38 | throw new java.lang.UnsupportedOperationException();
39 | }
40 |
41 | @Override
42 | public UpdateApplicationResult updateApplication(UpdateApplicationRequest request) {
43 | throw new java.lang.UnsupportedOperationException();
44 | }
45 |
46 | @Override
47 | public void shutdown() {
48 | throw new java.lang.UnsupportedOperationException();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/auth/CognitoAuthorizer.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.auth;
5 |
6 | import javax.annotation.Generated;
7 | import com.amazonaws.ImmutableRequest;
8 | import com.amazonaws.SignableRequest;
9 | import com.amazonaws.auth.RequestSigner;
10 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository;
11 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepositoryClientBuilder;
12 |
13 | /**
14 | * A default implementation of {@link RequestSigner} that puts a generated token into the header. An implementation of
15 | * this can to be supplied during construction of a {@link AWSServerlessApplicationRepository} via
16 | * {@link AWSServerlessApplicationRepositoryClientBuilder#signer(CognitoAuthorizer)} like so
17 | *
18 | *
19 | *
20 | * AWSServerlessApplicationRepository client = AWSServerlessApplicationRepository.builder().signer((CognitoAuthorizer) request -> "some token").build();
21 | *
22 | *
23 | */
24 | @FunctionalInterface
25 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
26 | public interface CognitoAuthorizer extends RequestSigner {
27 |
28 | /**
29 | * Generate a token that will be added to Authorization in the header of the request during signing
30 | *
31 | * @param request
32 | * an immutable view of the request for which to generate a token
33 | * @return the token to use for signing
34 | */
35 | String generateToken(ImmutableRequest> request);
36 |
37 | /**
38 | * @see RequestSigner#sign(SignableRequest)
39 | */
40 | @Override
41 | default void sign(SignableRequest> request) {
42 | request.addHeader("Authorization", generateToken(request));
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/AWSServerlessApplicationRepositoryException.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import com.amazonaws.opensdk.SdkErrorHttpMetadata;
7 | import com.amazonaws.opensdk.internal.BaseException;
8 | import com.amazonaws.annotation.SdkInternalApi;
9 | import javax.annotation.Generated;
10 |
11 | /**
12 | * Base exception for all service exceptions thrown by realworld-serverless-application-backend-dev
13 | */
14 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
15 | public class AWSServerlessApplicationRepositoryException extends com.amazonaws.SdkBaseException implements BaseException {
16 |
17 | private static final long serialVersionUID = 1L;
18 |
19 | private SdkErrorHttpMetadata sdkHttpMetadata;
20 |
21 | private String message;
22 |
23 | /**
24 | * Constructs a new AWSServerlessApplicationRepositoryException with the specified error message.
25 | *
26 | * @param message
27 | * Describes the error encountered.
28 | */
29 | public AWSServerlessApplicationRepositoryException(String message) {
30 | super(message);
31 | this.message = message;
32 | }
33 |
34 | @Override
35 | public AWSServerlessApplicationRepositoryException sdkHttpMetadata(SdkErrorHttpMetadata sdkHttpMetadata) {
36 | this.sdkHttpMetadata = sdkHttpMetadata;
37 | return this;
38 | }
39 |
40 | @Override
41 | public SdkErrorHttpMetadata sdkHttpMetadata() {
42 | return sdkHttpMetadata;
43 | }
44 |
45 | @SdkInternalApi
46 | @Override
47 | public void setMessage(String message) {
48 | this.message = message;
49 | }
50 |
51 | @Override
52 | public String getMessage() {
53 | return message;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class BadRequestException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new BadRequestException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public BadRequestException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public BadRequestException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/ConflictException.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class ConflictException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new ConflictException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public ConflictException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public ConflictException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/DeleteApplicationResult.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import java.io.Serializable;
7 | import javax.annotation.Generated;
8 |
9 | /**
10 | *
11 | * @see AWS
12 | * API Documentation
13 | */
14 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
15 | public class DeleteApplicationResult extends com.amazonaws.opensdk.BaseResult implements Serializable, Cloneable {
16 |
17 | /**
18 | * Returns a string representation of this object; useful for testing and debugging.
19 | *
20 | * @return A string representation of this object.
21 | *
22 | * @see java.lang.Object#toString()
23 | */
24 | @Override
25 | public String toString() {
26 | StringBuilder sb = new StringBuilder();
27 | sb.append("{");
28 | sb.append("}");
29 | return sb.toString();
30 | }
31 |
32 | @Override
33 | public boolean equals(Object obj) {
34 | if (this == obj)
35 | return true;
36 | if (obj == null)
37 | return false;
38 |
39 | if (obj instanceof DeleteApplicationResult == false)
40 | return false;
41 | DeleteApplicationResult other = (DeleteApplicationResult) obj;
42 | return true;
43 | }
44 |
45 | @Override
46 | public int hashCode() {
47 | final int prime = 31;
48 | int hashCode = 1;
49 |
50 | return hashCode;
51 | }
52 |
53 | @Override
54 | public DeleteApplicationResult clone() {
55 | try {
56 | return (DeleteApplicationResult) super.clone();
57 | } catch (CloneNotSupportedException e) {
58 | throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
59 | }
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/InternalServerErrorException.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class InternalServerErrorException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new InternalServerErrorException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public InternalServerErrorException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public InternalServerErrorException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class NotFoundException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new NotFoundException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public NotFoundException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public NotFoundException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/TooManyRequestsException.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class TooManyRequestsException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new TooManyRequestsException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public TooManyRequestsException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public TooManyRequestsException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/UnauthorizedException.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class UnauthorizedException extends software.amazon.serverless.apprepo.api.client.model.AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new UnauthorizedException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public UnauthorizedException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public UnauthorizedException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ApplicationListMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import java.util.List;
7 | import javax.annotation.Generated;
8 |
9 | import com.amazonaws.SdkClientException;
10 | import software.amazon.serverless.apprepo.api.client.model.*;
11 |
12 | import com.amazonaws.protocol.*;
13 | import com.amazonaws.annotation.SdkInternalApi;
14 |
15 | /**
16 | * ApplicationListMarshaller
17 | */
18 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
19 | @SdkInternalApi
20 | public class ApplicationListMarshaller {
21 |
22 | private static final MarshallingInfo APPLICATIONS_BINDING = MarshallingInfo.builder(MarshallingType.LIST).marshallLocation(MarshallLocation.PAYLOAD)
23 | .marshallLocationName("applications").build();
24 | private static final MarshallingInfo NEXTTOKEN_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
25 | .marshallLocationName("nextToken").build();
26 |
27 | private static final ApplicationListMarshaller instance = new ApplicationListMarshaller();
28 |
29 | public static ApplicationListMarshaller getInstance() {
30 | return instance;
31 | }
32 |
33 | /**
34 | * Marshall the given parameter object.
35 | */
36 | public void marshall(ApplicationList applicationList, ProtocolMarshaller protocolMarshaller) {
37 |
38 | if (applicationList == null) {
39 | throw new SdkClientException("Invalid argument passed to marshall(...)");
40 | }
41 |
42 | try {
43 | protocolMarshaller.marshall(applicationList.getApplications(), APPLICATIONS_BINDING);
44 | protocolMarshaller.marshall(applicationList.getNextToken(), NEXTTOKEN_BINDING);
45 | } catch (Exception e) {
46 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ApplicationSummaryMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import software.amazon.serverless.apprepo.api.client.model.*;
10 |
11 | import com.amazonaws.protocol.*;
12 | import com.amazonaws.annotation.SdkInternalApi;
13 |
14 | /**
15 | * ApplicationSummaryMarshaller
16 | */
17 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
18 | @SdkInternalApi
19 | public class ApplicationSummaryMarshaller {
20 |
21 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
22 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("applicationId").build();
23 | private static final MarshallingInfo CREATIONTIME_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
24 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("creationTime").build();
25 | private static final MarshallingInfo DESCRIPTION_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
26 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("description").build();
27 |
28 | private static final ApplicationSummaryMarshaller instance = new ApplicationSummaryMarshaller();
29 |
30 | public static ApplicationSummaryMarshaller getInstance() {
31 | return instance;
32 | }
33 |
34 | /**
35 | * Marshall the given parameter object.
36 | */
37 | public void marshall(ApplicationSummary applicationSummary, ProtocolMarshaller protocolMarshaller) {
38 |
39 | if (applicationSummary == null) {
40 | throw new SdkClientException("Invalid argument passed to marshall(...)");
41 | }
42 |
43 | try {
44 | protocolMarshaller.marshall(applicationSummary.getApplicationId(), APPLICATIONID_BINDING);
45 | protocolMarshaller.marshall(applicationSummary.getCreationTime(), CREATIONTIME_BINDING);
46 | protocolMarshaller.marshall(applicationSummary.getDescription(), DESCRIPTION_BINDING);
47 | } catch (Exception e) {
48 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import software.amazon.serverless.apprepo.api.client.model.*;
10 |
11 | import com.amazonaws.protocol.*;
12 | import com.amazonaws.annotation.SdkInternalApi;
13 |
14 | /**
15 | * CreateApplicationRequestMarshaller
16 | */
17 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
18 | @SdkInternalApi
19 | public class CreateApplicationRequestMarshaller {
20 |
21 | private static final MarshallingInfo CREATEAPPLICATIONINPUT_BINDING = MarshallingInfo.builder(MarshallingType.STRUCTURED)
22 | .marshallLocation(MarshallLocation.PAYLOAD).isExplicitPayloadMember(true).build();
23 |
24 | private static final CreateApplicationRequestMarshaller instance = new CreateApplicationRequestMarshaller();
25 |
26 | public static CreateApplicationRequestMarshaller getInstance() {
27 | return instance;
28 | }
29 |
30 | /**
31 | * Marshall the given parameter object.
32 | */
33 | public void marshall(CreateApplicationRequest createApplicationRequest, ProtocolMarshaller protocolMarshaller) {
34 |
35 | if (createApplicationRequest == null) {
36 | throw new SdkClientException("Invalid argument passed to marshall(...)");
37 | }
38 |
39 | try {
40 | protocolMarshaller.marshall(createApplicationRequest.getCreateApplicationInput(), CREATEAPPLICATIONINPUT_BINDING);
41 | } catch (Exception e) {
42 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import com.amazonaws.Request;
10 |
11 | import com.amazonaws.http.HttpMethodName;
12 | import software.amazon.serverless.apprepo.api.client.model.*;
13 | import com.amazonaws.transform.Marshaller;
14 |
15 | import com.amazonaws.protocol.*;
16 | import com.amazonaws.annotation.SdkInternalApi;
17 |
18 | /**
19 | * CreateApplicationRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class CreateApplicationRequestProtocolMarshaller implements Marshaller, CreateApplicationRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY).requestUri("/Prod/applications")
26 | .httpMethodName(HttpMethodName.POST).hasExplicitPayloadMember(true).hasPayloadMembers(true).serviceName("AWSServerlessApplicationRepository")
27 | .build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public CreateApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(CreateApplicationRequest createApplicationRequest) {
36 |
37 | if (createApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | createApplicationRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | CreateApplicationRequestMarshaller.getInstance().marshall(createApplicationRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import java.math.*;
7 |
8 | import javax.annotation.Generated;
9 |
10 | import software.amazon.serverless.apprepo.api.client.model.*;
11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
12 | import com.amazonaws.transform.*;
13 |
14 | import com.fasterxml.jackson.core.JsonToken;
15 | import static com.fasterxml.jackson.core.JsonToken.*;
16 |
17 | /**
18 | * CreateApplicationResult JSON Unmarshaller
19 | */
20 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
21 | public class CreateApplicationResultJsonUnmarshaller implements Unmarshaller {
22 |
23 | public CreateApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception {
24 | CreateApplicationResult createApplicationResult = new CreateApplicationResult();
25 |
26 | int originalDepth = context.getCurrentDepth();
27 | String currentParentElement = context.getCurrentParentElement();
28 | int targetDepth = originalDepth + 1;
29 |
30 | JsonToken token = context.getCurrentToken();
31 | if (token == null)
32 | token = context.nextToken();
33 | if (token == VALUE_NULL) {
34 | return createApplicationResult;
35 | }
36 |
37 | while (true) {
38 | if (token == null)
39 | break;
40 |
41 | createApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context));
42 | token = context.nextToken();
43 | }
44 |
45 | return createApplicationResult;
46 | }
47 |
48 | private static CreateApplicationResultJsonUnmarshaller instance;
49 |
50 | public static CreateApplicationResultJsonUnmarshaller getInstance() {
51 | if (instance == null)
52 | instance = new CreateApplicationResultJsonUnmarshaller();
53 | return instance;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import software.amazon.serverless.apprepo.api.client.model.*;
10 |
11 | import com.amazonaws.protocol.*;
12 | import com.amazonaws.annotation.SdkInternalApi;
13 |
14 | /**
15 | * DeleteApplicationRequestMarshaller
16 | */
17 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
18 | @SdkInternalApi
19 | public class DeleteApplicationRequestMarshaller {
20 |
21 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
22 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build();
23 |
24 | private static final DeleteApplicationRequestMarshaller instance = new DeleteApplicationRequestMarshaller();
25 |
26 | public static DeleteApplicationRequestMarshaller getInstance() {
27 | return instance;
28 | }
29 |
30 | /**
31 | * Marshall the given parameter object.
32 | */
33 | public void marshall(DeleteApplicationRequest deleteApplicationRequest, ProtocolMarshaller protocolMarshaller) {
34 |
35 | if (deleteApplicationRequest == null) {
36 | throw new SdkClientException("Invalid argument passed to marshall(...)");
37 | }
38 |
39 | try {
40 | protocolMarshaller.marshall(deleteApplicationRequest.getApplicationId(), APPLICATIONID_BINDING);
41 | } catch (Exception e) {
42 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import com.amazonaws.Request;
10 |
11 | import com.amazonaws.http.HttpMethodName;
12 | import software.amazon.serverless.apprepo.api.client.model.*;
13 | import com.amazonaws.transform.Marshaller;
14 |
15 | import com.amazonaws.protocol.*;
16 | import com.amazonaws.annotation.SdkInternalApi;
17 |
18 | /**
19 | * DeleteApplicationRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class DeleteApplicationRequestProtocolMarshaller implements Marshaller, DeleteApplicationRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY)
26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.DELETE).hasExplicitPayloadMember(false).hasPayloadMembers(false)
27 | .serviceName("AWSServerlessApplicationRepository").build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public DeleteApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(DeleteApplicationRequest deleteApplicationRequest) {
36 |
37 | if (deleteApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | deleteApplicationRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | DeleteApplicationRequestMarshaller.getInstance().marshall(deleteApplicationRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import java.math.*;
7 |
8 | import javax.annotation.Generated;
9 |
10 | import software.amazon.serverless.apprepo.api.client.model.*;
11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
12 | import com.amazonaws.transform.*;
13 |
14 | import static com.fasterxml.jackson.core.JsonToken.*;
15 |
16 | /**
17 | * DeleteApplicationResult JSON Unmarshaller
18 | */
19 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
20 | public class DeleteApplicationResultJsonUnmarshaller implements Unmarshaller {
21 |
22 | public DeleteApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception {
23 | DeleteApplicationResult deleteApplicationResult = new DeleteApplicationResult();
24 |
25 | return deleteApplicationResult;
26 | }
27 |
28 | private static DeleteApplicationResultJsonUnmarshaller instance;
29 |
30 | public static DeleteApplicationResultJsonUnmarshaller getInstance() {
31 | if (instance == null)
32 | instance = new DeleteApplicationResultJsonUnmarshaller();
33 | return instance;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import software.amazon.serverless.apprepo.api.client.model.*;
10 |
11 | import com.amazonaws.protocol.*;
12 | import com.amazonaws.annotation.SdkInternalApi;
13 |
14 | /**
15 | * GetApplicationRequestMarshaller
16 | */
17 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
18 | @SdkInternalApi
19 | public class GetApplicationRequestMarshaller {
20 |
21 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
22 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build();
23 |
24 | private static final GetApplicationRequestMarshaller instance = new GetApplicationRequestMarshaller();
25 |
26 | public static GetApplicationRequestMarshaller getInstance() {
27 | return instance;
28 | }
29 |
30 | /**
31 | * Marshall the given parameter object.
32 | */
33 | public void marshall(GetApplicationRequest getApplicationRequest, ProtocolMarshaller protocolMarshaller) {
34 |
35 | if (getApplicationRequest == null) {
36 | throw new SdkClientException("Invalid argument passed to marshall(...)");
37 | }
38 |
39 | try {
40 | protocolMarshaller.marshall(getApplicationRequest.getApplicationId(), APPLICATIONID_BINDING);
41 | } catch (Exception e) {
42 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import com.amazonaws.Request;
10 |
11 | import com.amazonaws.http.HttpMethodName;
12 | import software.amazon.serverless.apprepo.api.client.model.*;
13 | import com.amazonaws.transform.Marshaller;
14 |
15 | import com.amazonaws.protocol.*;
16 | import com.amazonaws.annotation.SdkInternalApi;
17 |
18 | /**
19 | * GetApplicationRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class GetApplicationRequestProtocolMarshaller implements Marshaller, GetApplicationRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY)
26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.GET).hasExplicitPayloadMember(false).hasPayloadMembers(false)
27 | .serviceName("AWSServerlessApplicationRepository").build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public GetApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(GetApplicationRequest getApplicationRequest) {
36 |
37 | if (getApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | getApplicationRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | GetApplicationRequestMarshaller.getInstance().marshall(getApplicationRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import java.math.*;
7 |
8 | import javax.annotation.Generated;
9 |
10 | import software.amazon.serverless.apprepo.api.client.model.*;
11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
12 | import com.amazonaws.transform.*;
13 |
14 | import com.fasterxml.jackson.core.JsonToken;
15 | import static com.fasterxml.jackson.core.JsonToken.*;
16 |
17 | /**
18 | * GetApplicationResult JSON Unmarshaller
19 | */
20 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
21 | public class GetApplicationResultJsonUnmarshaller implements Unmarshaller {
22 |
23 | public GetApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception {
24 | GetApplicationResult getApplicationResult = new GetApplicationResult();
25 |
26 | int originalDepth = context.getCurrentDepth();
27 | String currentParentElement = context.getCurrentParentElement();
28 | int targetDepth = originalDepth + 1;
29 |
30 | JsonToken token = context.getCurrentToken();
31 | if (token == null)
32 | token = context.nextToken();
33 | if (token == VALUE_NULL) {
34 | return getApplicationResult;
35 | }
36 |
37 | while (true) {
38 | if (token == null)
39 | break;
40 |
41 | getApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context));
42 | token = context.nextToken();
43 | }
44 |
45 | return getApplicationResult;
46 | }
47 |
48 | private static GetApplicationResultJsonUnmarshaller instance;
49 |
50 | public static GetApplicationResultJsonUnmarshaller getInstance() {
51 | if (instance == null)
52 | instance = new GetApplicationResultJsonUnmarshaller();
53 | return instance;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import software.amazon.serverless.apprepo.api.client.model.*;
10 |
11 | import com.amazonaws.protocol.*;
12 | import com.amazonaws.annotation.SdkInternalApi;
13 |
14 | /**
15 | * ListApplicationsRequestMarshaller
16 | */
17 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
18 | @SdkInternalApi
19 | public class ListApplicationsRequestMarshaller {
20 |
21 | private static final MarshallingInfo MAXITEMS_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
22 | .marshallLocation(MarshallLocation.QUERY_PARAM).marshallLocationName("maxItems").build();
23 | private static final MarshallingInfo NEXTTOKEN_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
24 | .marshallLocation(MarshallLocation.QUERY_PARAM).marshallLocationName("nextToken").build();
25 |
26 | private static final ListApplicationsRequestMarshaller instance = new ListApplicationsRequestMarshaller();
27 |
28 | public static ListApplicationsRequestMarshaller getInstance() {
29 | return instance;
30 | }
31 |
32 | /**
33 | * Marshall the given parameter object.
34 | */
35 | public void marshall(ListApplicationsRequest listApplicationsRequest, ProtocolMarshaller protocolMarshaller) {
36 |
37 | if (listApplicationsRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | protocolMarshaller.marshall(listApplicationsRequest.getMaxItems(), MAXITEMS_BINDING);
43 | protocolMarshaller.marshall(listApplicationsRequest.getNextToken(), NEXTTOKEN_BINDING);
44 | } catch (Exception e) {
45 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import com.amazonaws.Request;
10 |
11 | import com.amazonaws.http.HttpMethodName;
12 | import software.amazon.serverless.apprepo.api.client.model.*;
13 | import com.amazonaws.transform.Marshaller;
14 |
15 | import com.amazonaws.protocol.*;
16 | import com.amazonaws.annotation.SdkInternalApi;
17 |
18 | /**
19 | * ListApplicationsRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class ListApplicationsRequestProtocolMarshaller implements Marshaller, ListApplicationsRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY).requestUri("/Prod/applications")
26 | .httpMethodName(HttpMethodName.GET).hasExplicitPayloadMember(false).hasPayloadMembers(false).serviceName("AWSServerlessApplicationRepository")
27 | .build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public ListApplicationsRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(ListApplicationsRequest listApplicationsRequest) {
36 |
37 | if (listApplicationsRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | listApplicationsRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | ListApplicationsRequestMarshaller.getInstance().marshall(listApplicationsRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import java.math.*;
7 |
8 | import javax.annotation.Generated;
9 |
10 | import software.amazon.serverless.apprepo.api.client.model.*;
11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
12 | import com.amazonaws.transform.*;
13 |
14 | import com.fasterxml.jackson.core.JsonToken;
15 | import static com.fasterxml.jackson.core.JsonToken.*;
16 |
17 | /**
18 | * ListApplicationsResult JSON Unmarshaller
19 | */
20 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
21 | public class ListApplicationsResultJsonUnmarshaller implements Unmarshaller {
22 |
23 | public ListApplicationsResult unmarshall(JsonUnmarshallerContext context) throws Exception {
24 | ListApplicationsResult listApplicationsResult = new ListApplicationsResult();
25 |
26 | int originalDepth = context.getCurrentDepth();
27 | String currentParentElement = context.getCurrentParentElement();
28 | int targetDepth = originalDepth + 1;
29 |
30 | JsonToken token = context.getCurrentToken();
31 | if (token == null)
32 | token = context.nextToken();
33 | if (token == VALUE_NULL) {
34 | return listApplicationsResult;
35 | }
36 |
37 | while (true) {
38 | if (token == null)
39 | break;
40 |
41 | listApplicationsResult.setApplicationList(ApplicationListJsonUnmarshaller.getInstance().unmarshall(context));
42 | token = context.nextToken();
43 | }
44 |
45 | return listApplicationsResult;
46 | }
47 |
48 | private static ListApplicationsResultJsonUnmarshaller instance;
49 |
50 | public static ListApplicationsResultJsonUnmarshaller getInstance() {
51 | if (instance == null)
52 | instance = new ListApplicationsResultJsonUnmarshaller();
53 | return instance;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationInputMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import software.amazon.serverless.apprepo.api.client.model.*;
10 |
11 | import com.amazonaws.protocol.*;
12 | import com.amazonaws.annotation.SdkInternalApi;
13 |
14 | /**
15 | * UpdateApplicationInputMarshaller
16 | */
17 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
18 | @SdkInternalApi
19 | public class UpdateApplicationInputMarshaller {
20 |
21 | private static final MarshallingInfo AUTHOR_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
22 | .marshallLocationName("author").build();
23 | private static final MarshallingInfo DESCRIPTION_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
24 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("description").build();
25 | private static final MarshallingInfo HOMEPAGEURL_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
26 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("homePageUrl").build();
27 |
28 | private static final UpdateApplicationInputMarshaller instance = new UpdateApplicationInputMarshaller();
29 |
30 | public static UpdateApplicationInputMarshaller getInstance() {
31 | return instance;
32 | }
33 |
34 | /**
35 | * Marshall the given parameter object.
36 | */
37 | public void marshall(UpdateApplicationInput updateApplicationInput, ProtocolMarshaller protocolMarshaller) {
38 |
39 | if (updateApplicationInput == null) {
40 | throw new SdkClientException("Invalid argument passed to marshall(...)");
41 | }
42 |
43 | try {
44 | protocolMarshaller.marshall(updateApplicationInput.getAuthor(), AUTHOR_BINDING);
45 | protocolMarshaller.marshall(updateApplicationInput.getDescription(), DESCRIPTION_BINDING);
46 | protocolMarshaller.marshall(updateApplicationInput.getHomePageUrl(), HOMEPAGEURL_BINDING);
47 | } catch (Exception e) {
48 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import software.amazon.serverless.apprepo.api.client.model.*;
10 |
11 | import com.amazonaws.protocol.*;
12 | import com.amazonaws.annotation.SdkInternalApi;
13 |
14 | /**
15 | * UpdateApplicationRequestMarshaller
16 | */
17 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
18 | @SdkInternalApi
19 | public class UpdateApplicationRequestMarshaller {
20 |
21 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
22 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build();
23 | private static final MarshallingInfo UPDATEAPPLICATIONINPUT_BINDING = MarshallingInfo.builder(MarshallingType.STRUCTURED)
24 | .marshallLocation(MarshallLocation.PAYLOAD).isExplicitPayloadMember(true).build();
25 |
26 | private static final UpdateApplicationRequestMarshaller instance = new UpdateApplicationRequestMarshaller();
27 |
28 | public static UpdateApplicationRequestMarshaller getInstance() {
29 | return instance;
30 | }
31 |
32 | /**
33 | * Marshall the given parameter object.
34 | */
35 | public void marshall(UpdateApplicationRequest updateApplicationRequest, ProtocolMarshaller protocolMarshaller) {
36 |
37 | if (updateApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | protocolMarshaller.marshall(updateApplicationRequest.getApplicationId(), APPLICATIONID_BINDING);
43 | protocolMarshaller.marshall(updateApplicationRequest.getUpdateApplicationInput(), UPDATEAPPLICATIONINPUT_BINDING);
44 | } catch (Exception e) {
45 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import javax.annotation.Generated;
7 |
8 | import com.amazonaws.SdkClientException;
9 | import com.amazonaws.Request;
10 |
11 | import com.amazonaws.http.HttpMethodName;
12 | import software.amazon.serverless.apprepo.api.client.model.*;
13 | import com.amazonaws.transform.Marshaller;
14 |
15 | import com.amazonaws.protocol.*;
16 | import com.amazonaws.annotation.SdkInternalApi;
17 |
18 | /**
19 | * UpdateApplicationRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class UpdateApplicationRequestProtocolMarshaller implements Marshaller, UpdateApplicationRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY)
26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.PATCH).hasExplicitPayloadMember(true).hasPayloadMembers(true)
27 | .serviceName("AWSServerlessApplicationRepository").build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public UpdateApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(UpdateApplicationRequest updateApplicationRequest) {
36 |
37 | if (updateApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | updateApplicationRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | UpdateApplicationRequestMarshaller.getInstance().marshall(updateApplicationRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import java.math.*;
7 |
8 | import javax.annotation.Generated;
9 |
10 | import software.amazon.serverless.apprepo.api.client.model.*;
11 | import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
12 | import com.amazonaws.transform.*;
13 |
14 | import com.fasterxml.jackson.core.JsonToken;
15 | import static com.fasterxml.jackson.core.JsonToken.*;
16 |
17 | /**
18 | * UpdateApplicationResult JSON Unmarshaller
19 | */
20 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
21 | public class UpdateApplicationResultJsonUnmarshaller implements Unmarshaller {
22 |
23 | public UpdateApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception {
24 | UpdateApplicationResult updateApplicationResult = new UpdateApplicationResult();
25 |
26 | int originalDepth = context.getCurrentDepth();
27 | String currentParentElement = context.getCurrentParentElement();
28 | int targetDepth = originalDepth + 1;
29 |
30 | JsonToken token = context.getCurrentToken();
31 | if (token == null)
32 | token = context.nextToken();
33 | if (token == VALUE_NULL) {
34 | return updateApplicationResult;
35 | }
36 |
37 | while (true) {
38 | if (token == null)
39 | break;
40 |
41 | updateApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context));
42 | token = context.nextToken();
43 | }
44 |
45 | return updateApplicationResult;
46 | }
47 |
48 | private static UpdateApplicationResultJsonUnmarshaller instance;
49 |
50 | public static UpdateApplicationResultJsonUnmarshaller getInstance() {
51 | if (instance == null)
52 | instance = new UpdateApplicationResultJsonUnmarshaller();
53 | return instance;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/api/client/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 |
3 | */
4 |
5 | /**
6 | *
7 | */
8 | package software.amazon.serverless.apprepo.api.client;
9 |
10 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/ApplicationsService_IT.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber;
2 |
3 | import io.cucumber.junit.Cucumber;
4 | import io.cucumber.junit.CucumberOptions;
5 | import org.junit.runner.RunWith;
6 |
7 | /**
8 | * Junit entry point for cucumber tests.
9 | */
10 | @RunWith(Cucumber.class)
11 | @CucumberOptions(features = "src/test/java/software/amazon/serverless/apprepo/cucumber/features",
12 | glue = "software.amazon.serverless.apprepo.cucumber.steps",
13 | tags = {"not @NotImplemented"},// Use @NotImplemented tag for scenarios that have not been implemented
14 | plugin = {"pretty"})
15 | public class ApplicationsService_IT {
16 | }
17 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/features/AthenaQuery.feature:
--------------------------------------------------------------------------------
1 | Feature: Analyze Data
2 | As an administrator, I would like to analyze the customer usage of the service
3 |
4 | Scenario: User creates an application
5 | When a user creates an application
6 | Then a new application should be created
7 | And the administrator can analyze the data with Athena queries
8 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/guice/CognitoAuthorizerImpl.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber.guice;
2 |
3 | import com.amazonaws.ImmutableRequest;
4 | import software.amazon.serverless.apprepo.api.client.auth.CognitoAuthorizer;
5 | import software.amazon.serverless.apprepo.cucumber.steps.CognitoUserManager;
6 |
7 | import java.util.UUID;
8 |
9 | import lombok.RequiredArgsConstructor;
10 | import lombok.extern.slf4j.Slf4j;
11 |
12 | /**
13 | * Implementation of {@link CognitoAuthorizer} to provide signer for API requests.
14 | */
15 | @Slf4j
16 | @RequiredArgsConstructor
17 | public class CognitoAuthorizerImpl implements CognitoAuthorizer {
18 | private final CognitoUserManager cognitoUserManager;
19 |
20 | @Override
21 | public String generateToken(ImmutableRequest> request) {
22 | try {
23 | return cognitoUserManager.generateIdToken();
24 | } catch (Throwable t) {
25 | log.warn("Exception thrown when generating token", t);
26 | return UUID.randomUUID().toString();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/guice/CukeInjectorSource.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber.guice;
2 |
3 | import com.google.common.collect.Lists;
4 | import com.google.inject.Guice;
5 | import com.google.inject.Injector;
6 |
7 | import cucumber.runtime.java.guice.InjectorSource;
8 |
9 | /**
10 | * Guice injector source for Cucumber.
11 | */
12 | public class CukeInjectorSource implements InjectorSource {
13 | @Override
14 | public Injector getInjector() {
15 | return Guice.createInjector(Lists.newArrayList(new ApplicationModule()));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/analytics/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/S3Helper.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber.steps;
2 |
3 |
4 | import lombok.RequiredArgsConstructor;
5 | import lombok.extern.slf4j.Slf4j;
6 | import software.amazon.awssdk.services.s3.S3Client;
7 | import software.amazon.awssdk.services.s3.model.DeleteObjectRequest;
8 | import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
9 | import software.amazon.awssdk.services.s3.paginators.ListObjectsV2Iterable;
10 |
11 | @RequiredArgsConstructor
12 | @Slf4j
13 | public class S3Helper {
14 | private final S3Client s3Client;
15 |
16 | public void emptyBucket(String bucketName){
17 | log.info("Emptying bucket {}", bucketName);
18 |
19 | ListObjectsV2Iterable listObjectsV2Responses = s3Client.listObjectsV2Paginator(ListObjectsV2Request.builder()
20 | .bucket(bucketName)
21 | .build());
22 |
23 | listObjectsV2Responses.stream()
24 | .flatMap(r -> r.contents().stream())
25 | .forEach(s3Object -> {
26 | log.info("deleting {}", s3Object.key());
27 | s3Client.deleteObject(DeleteObjectRequest.builder()
28 | .bucket(bucketName)
29 | .key(s3Object.key())
30 | .build());
31 | });
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/analytics/src/test/resources/cucumber.properties:
--------------------------------------------------------------------------------
1 | guice.injector-source=software.amazon.serverless.apprepo.cucumber.guice.CukeInjectorSource
2 |
--------------------------------------------------------------------------------
/analytics/src/test/resources/integ-test-env.template.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Description: >-
3 | This template creates the resources for integration tests.
4 |
5 | Parameters:
6 | Stage:
7 | Type: String
8 | Description: The stage where the application is running in, e.g., dev, prod.
9 | Resources:
10 | IntegTestClient:
11 | Type: AWS::Cognito::UserPoolClient
12 | Properties:
13 | UserPoolId: !Sub '{{resolve:ssm:/applications/apprepo/${Stage}/cognito/userpool/ApplicationsApi/Id:1}}'
14 | GenerateSecret: false
15 | ExplicitAuthFlows:
16 | - ADMIN_NO_SRP_AUTH
17 |
18 | AthenaQueryResultsBucket:
19 | Type: AWS::S3::Bucket
20 |
21 | IntegTestClientId:
22 | Type: "AWS::SSM::Parameter"
23 | Properties:
24 | Name: !Sub "/applications/apprepo/${Stage}/cognito/userpoolclient/IntegTest/Id"
25 | Type: "String"
26 | Value: !Ref IntegTestClient
27 | Description: "Integration test Cognito User Pool Client ID."
28 |
29 | AthenaQueryResultsBucketName:
30 | Type: "AWS::SSM::Parameter"
31 | Properties:
32 | Name: !Sub "/applications/apprepo/${Stage}/s3/AthenaQueryResultsBucketName/IntegTest/Name"
33 | Type: "String"
34 | Value: !Ref AthenaQueryResultsBucket
35 | Description: "Integration test Cognito User Pool Client ID."
--------------------------------------------------------------------------------
/analytics/src/test/resources/log4j2.properties:
--------------------------------------------------------------------------------
1 | name=config
2 | appenders=console
3 | appender.console.type=Console
4 | appender.console.name=STDOUT
5 | appender.console.layout.type=PatternLayout
6 | appender.console.layout.pattern=%d{dd-MM-yyyy HH:mm:ss} [%-5p] (%F:%L) - %m%n
7 | rootLogger.level=info
8 | rootLogger.appenderRefs=stdout
9 | rootLogger.appenderRef.stdout.ref=STDOUT
--------------------------------------------------------------------------------
/backend/README.md:
--------------------------------------------------------------------------------
1 | # realworld-serverless-application-backend
2 |
3 | realworld-serverless-application-backend is the backend component of a larger project providing a REST API for the application. It can be deployed together with the other system components to produce an example serverless application demonstrating real world patterns and best practices for serverless applications.
4 |
5 | To get started with the full project, follow the [Quick Start](https://github.com/awslabs/realworld-serverless-application/wiki/Quick-Start) guide.
6 |
7 | ## License
8 |
9 | This project is licensed under the Apache-2.0 License.
10 |
--------------------------------------------------------------------------------
/backend/buildspec-integ-test.yaml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | java: openjdk8
7 | build:
8 | commands:
9 | - cd backend
10 | - STAGE=integ-tests-`date +%s`
11 | - mvn clean verify -Dintegtests.stage=${STAGE} -DpackageBucket=${PACKAGE_BUCKET}
12 |
13 |
--------------------------------------------------------------------------------
/backend/buildspec.yaml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | java: openjdk8
7 | build:
8 | commands:
9 | - cd backend
10 | - mvn clean package -DpackageBucket=${PACKAGE_BUCKET}
11 | artifacts:
12 | files:
13 | - backend/target/sam/app/packaged-template.yaml
14 | discard-paths: yes
15 |
--------------------------------------------------------------------------------
/backend/images/back_end_diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amazon-archives/realworld-serverless-application/effdb9643b778fa78280bfb5da9e6db371f5b09e/backend/images/back_end_diagram.png
--------------------------------------------------------------------------------
/backend/sam/app/template.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Transform: 'AWS::Serverless-2016-10-31'
3 | Description: >-
4 | This application creates a backend service using serverless technologies such as API Gateway, Lambda etc.
5 |
6 | Metadata:
7 | AWS::ServerlessRepo::Application:
8 | Name: realworld-serverless-application-backend
9 | Description: >-
10 | This application creates a backend service using serverless technologies such as API Gateway, Lambda etc.
11 | Author: AWS Serverless Application Repository
12 | SpdxLicenseId: Apache-2.0
13 | Labels: [github, serverless, sam]
14 | HomePageUrl: https://github.com/awslabs/realworld-serverless-application
15 | SemanticVersion: 1.0.1
16 | SourceCodeUrl: https://github.com/awslabs/realworld-serverless-application/tree/1.0.1
17 | LicenseUrl: ../../../LICENSE
18 | ReadmeUrl: ../../README.md
19 |
20 | Parameters:
21 | Stage:
22 | Type: String
23 | Description: The stage where the application is running in, e.g., dev, prod.
24 | Default: 'test'
25 |
26 | Resources:
27 | Api:
28 | Type: 'AWS::Serverless::Application'
29 | Properties:
30 | Location: 'api.template.yaml'
31 | Parameters:
32 | Stage: !Ref Stage
33 | DependsOn: Database
34 | Database:
35 | Type: 'AWS::Serverless::Application'
36 | Properties:
37 | Location: 'database.template.yaml'
38 | Parameters:
39 | Stage: !Ref Stage
40 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/exception/ApiException.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.exception;
2 |
3 | import javax.ws.rs.WebApplicationException;
4 | import javax.ws.rs.core.MediaType;
5 | import javax.ws.rs.core.Response;
6 |
7 | import lombok.extern.slf4j.Slf4j;
8 |
9 | /**
10 | * API exception that can be converted to JAX-RS {@link Response}.
11 | */
12 | @Slf4j
13 | public class ApiException extends WebApplicationException {
14 | /**
15 | * Construct an ApiException with body object and status code.
16 | *
17 | * @param exception the exception object that will be deserialized to JSON string
18 | * as the response body.
19 | * @param statusCode response status code.
20 | */
21 | public ApiException(final Object exception, final Response.Status statusCode) {
22 | super(Response.status(statusCode)
23 | .entity(exception)
24 | .type(MediaType.APPLICATION_JSON)
25 | .build());
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/exception/ApiExceptionMapper.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.exception;
2 |
3 | import javax.ws.rs.core.Response;
4 | import javax.ws.rs.ext.ExceptionMapper;
5 | import javax.ws.rs.ext.Provider;
6 |
7 | import lombok.extern.slf4j.Slf4j;
8 |
9 | /**
10 | * Exception mapper that maps throwables that are not {@link ApiException}
11 | * to {@link InternalServerApiException}.
12 | */
13 | @Provider
14 | @Slf4j
15 | public class ApiExceptionMapper implements ExceptionMapper {
16 | @Override
17 | public Response toResponse(final Throwable throwable) {
18 | if (throwable instanceof ApiException) {
19 | log.info("4xx exception is thrown", throwable);
20 | ApiException apiException = (ApiException) throwable;
21 | return apiException.getResponse();
22 | } else {
23 | log.error("5xx exception is thrown", throwable);
24 | return new InternalServerApiException().getResponse();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/exception/BadRequestApiException.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.exception;
2 |
3 | import io.swagger.model.BadRequestException;
4 |
5 | import javax.ws.rs.core.Response;
6 |
7 | /**
8 | * Bad Request Api exception.
9 | */
10 | public class BadRequestApiException extends ApiException {
11 | public BadRequestApiException(final BadRequestException exception) {
12 | super(exception, Response.Status.BAD_REQUEST);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/exception/ConflictApiException.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.exception;
2 |
3 | import io.swagger.model.ConflictException;
4 |
5 | import javax.ws.rs.core.Response;
6 |
7 | /**
8 | * Conflict Api exception.
9 | */
10 | public class ConflictApiException extends ApiException {
11 | public ConflictApiException(final ConflictException exception) {
12 | super(exception, Response.Status.CONFLICT);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/exception/InternalServerApiException.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.exception;
2 |
3 | import io.swagger.model.InternalServerErrorException;
4 |
5 | import javax.ws.rs.core.Response;
6 |
7 | /**
8 | * Internal Server Api Exception.
9 | */
10 | public class InternalServerApiException extends ApiException {
11 | /**
12 | * Construct an InternalServerApiException that converts
13 | * to 500 Interal Server Error response.
14 | */
15 | public InternalServerApiException() {
16 | super(new InternalServerErrorException()
17 | .errorCode("InternalError")
18 | .message("Internal Server Error."),
19 | Response.Status.INTERNAL_SERVER_ERROR);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/exception/NotFoundApiException.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.exception;
2 |
3 | import io.swagger.model.NotFoundException;
4 |
5 | import javax.ws.rs.core.Response;
6 |
7 | /**
8 | * Not Found Api exception.
9 | */
10 | public class NotFoundApiException extends ApiException {
11 | public NotFoundApiException(final NotFoundException exception) {
12 | super(exception, Response.Status.NOT_FOUND);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/InvalidTokenException.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.impl.pagination;
2 |
3 | /**
4 | * Exception for invalid token.
5 | */
6 | public class InvalidTokenException extends Exception {
7 | public InvalidTokenException(final String message) {
8 | super(message);
9 | }
10 |
11 | public InvalidTokenException(final String message, final Exception exception) {
12 | super(message, exception);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/TimeBasedTokenSerializer.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.impl.pagination;
2 |
3 | import java.time.Duration;
4 | import java.time.Instant;
5 | import java.time.format.DateTimeParseException;
6 |
7 | import lombok.RequiredArgsConstructor;
8 | import org.apache.commons.lang3.StringUtils;
9 |
10 | /**
11 | * Implementation of {@link TokenSerializer} that adds time information
12 | * to ensure the token will expire.
13 | */
14 | @RequiredArgsConstructor
15 | public class TimeBasedTokenSerializer implements TokenSerializer {
16 | static final String TIMESTAMP_DEMILITER = "&";
17 |
18 | private final Duration ttl;
19 |
20 | @Override
21 | public String deserialize(final String token) throws InvalidTokenException {
22 | validateTimestamp(token);
23 | String decodedToken = StringUtils.substringBeforeLast(token, TIMESTAMP_DEMILITER);
24 | if (StringUtils.isBlank(decodedToken)) {
25 | throw new InvalidTokenException("The token is blank.");
26 | }
27 | return decodedToken;
28 | }
29 |
30 | @Override
31 | public String serialize(final String token) {
32 | StringBuilder tokenBuilder = new StringBuilder(token);
33 | tokenBuilder.append(TIMESTAMP_DEMILITER);
34 | tokenBuilder.append(Instant.now().toString());
35 | return tokenBuilder.toString();
36 | }
37 |
38 | private void validateTimestamp(final String tokenString) throws InvalidTokenException {
39 | String timestampString = StringUtils.substringAfterLast(tokenString, TIMESTAMP_DEMILITER);
40 | Instant timestamp;
41 | try {
42 | timestamp = Instant.parse(timestampString);
43 | } catch (DateTimeParseException e) {
44 | throw new InvalidTokenException(
45 | String.format("Invalid timestamp string %s in token.", timestampString), e);
46 | }
47 |
48 | if (timestamp.plus(ttl).isBefore(Instant.now())) {
49 | throw new InvalidTokenException(
50 | String.format("Token %s has expired after timeout limit %s.", timestamp, ttl));
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/TokenSerializer.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.impl.pagination;
2 |
3 | /**
4 | * Serialize/deserialize a token to/from a String.
5 | *
6 | * @param type of the token
7 | */
8 | public interface TokenSerializer {
9 | /**
10 | * Deserialize the token into type T.
11 | *
12 | * @param tokenString token in String.
13 | * @return deserialized token.
14 | * @throws InvalidTokenException throws when the token in String is invalid.
15 | */
16 | T deserialize(String tokenString) throws InvalidTokenException;
17 |
18 | /**
19 | * Serialize the token into a String.
20 | *
21 | * @param token the token to be serialized.
22 | * @return serialized token in String.
23 | */
24 | String serialize(T token);
25 | }
26 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/jackson/SdkBytesDeserializer.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.impl.pagination.jackson;
2 |
3 | import com.fasterxml.jackson.core.JsonParser;
4 | import com.fasterxml.jackson.core.JsonProcessingException;
5 | import com.fasterxml.jackson.databind.DeserializationContext;
6 | import com.fasterxml.jackson.databind.JsonDeserializer;
7 |
8 | import java.io.IOException;
9 | import java.nio.charset.Charset;
10 |
11 | import lombok.RequiredArgsConstructor;
12 | import software.amazon.awssdk.core.SdkBytes;
13 |
14 | /**
15 | * Jackson Json Deserializer for {@link SdkBytes}.
16 | */
17 | @RequiredArgsConstructor
18 | public class SdkBytesDeserializer extends JsonDeserializer {
19 | private final Charset charset;
20 |
21 | /**
22 | * Construct SdkBytesDeserializer using default charset.
23 | */
24 | public SdkBytesDeserializer() {
25 | this(Charset.defaultCharset());
26 | }
27 |
28 | @Override
29 | public SdkBytes deserialize(JsonParser jsonParser,
30 | DeserializationContext deserializationContext)
31 | throws IOException, JsonProcessingException {
32 | return SdkBytes.fromString(jsonParser.getValueAsString(), charset);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/api/impl/pagination/jackson/SdkBytesSerializer.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.impl.pagination.jackson;
2 |
3 | import com.fasterxml.jackson.core.JsonGenerator;
4 | import com.fasterxml.jackson.databind.JsonSerializer;
5 | import com.fasterxml.jackson.databind.SerializerProvider;
6 |
7 | import java.io.IOException;
8 | import java.nio.charset.Charset;
9 |
10 | import lombok.RequiredArgsConstructor;
11 | import software.amazon.awssdk.core.SdkBytes;
12 |
13 | /**
14 | * Jackson Json Serializer for {@link SdkBytes}.
15 | */
16 | @RequiredArgsConstructor
17 | public class SdkBytesSerializer extends JsonSerializer {
18 | private final Charset charset;
19 |
20 | /**
21 | * Construct SdkBytesSerializer using default charset.
22 | */
23 | public SdkBytesSerializer() {
24 | this(Charset.defaultCharset());
25 | }
26 |
27 | @Override
28 | public void serialize(SdkBytes sdkBytes, JsonGenerator jsonGenerator,
29 | SerializerProvider serializerProvider) throws IOException {
30 | jsonGenerator.writeString(sdkBytes.asString(charset));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/container/CorsHeadersResponseFilter.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.container;
2 |
3 | import javax.ws.rs.container.ContainerRequestContext;
4 | import javax.ws.rs.container.ContainerResponseContext;
5 | import javax.ws.rs.container.ContainerResponseFilter;
6 | import javax.ws.rs.ext.Provider;
7 |
8 | import lombok.extern.slf4j.Slf4j;
9 |
10 | /**
11 | * Request filter to support CORS.
12 | */
13 | @Provider
14 | @Slf4j
15 | public class CorsHeadersResponseFilter implements ContainerResponseFilter {
16 | @Override
17 | public void filter(ContainerRequestContext requestContext,
18 | ContainerResponseContext responseContext) {
19 | String origin = "*";
20 | log.info("Set CORS header to allow request from {}", origin);
21 | responseContext.getHeaders().add("Access-Control-Allow-Origin", origin);
22 | }
23 | }
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/container/config/ConfigProvider.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.container.config;
2 |
3 | import java.time.Duration;
4 |
5 | /**
6 | * Provides configuration value based on name.
7 | */
8 | public interface ConfigProvider {
9 | /**
10 | * Get Applications DynamoDB Table name.
11 | *
12 | * @return String
13 | */
14 | String getApplicationsTableName();
15 |
16 | /**
17 | * Get KMS key id.
18 | *
19 | * @return key id String.
20 | */
21 | String getKmsKeyId();
22 |
23 | /**
24 | * Get pagination token ttl.
25 | *
26 | * @return ttl duration.
27 | */
28 | Duration getPaginationTokenTtl();
29 | }
30 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/container/config/Env.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.container.config;
2 |
3 | /**
4 | * System environment variable helper class.
5 | */
6 | public final class Env {
7 | private static String getEnv(final String key) {
8 | return System.getenv(key);
9 | }
10 |
11 | private static String getStage() {
12 | return getEnv("STAGE");
13 | }
14 |
15 | public static String getSsmConfigKeyPrefix() {
16 | return String.format("/applications/apprepo/%s/", getStage());
17 | }
18 |
19 | public static String getRegion() {
20 | return getEnv("AWS_REGION");
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/container/config/SsmConfigProvider.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.container.config;
2 |
3 | import java.time.Duration;
4 |
5 | import lombok.RequiredArgsConstructor;
6 | import software.amazon.awssdk.services.ssm.model.ParameterNotFoundException;
7 | import software.amazon.serverless.ssmcachingclient.SsmParameterCachingClient;
8 |
9 | /**
10 | * Provide config value from AWS SSM.
11 | */
12 | @RequiredArgsConstructor
13 | public class SsmConfigProvider implements ConfigProvider {
14 | private static final Duration DEFAULT_PAGINATION_TOKEN_TTL = Duration.ofHours(1);
15 | private static final String APPLICATIONS_TABLE_NAME_CONFIG_KEY = "ddb/Applications/TableName";
16 | private static final String KMS_KEY_ID_CONFIG_KEY = "kms/pagination/KeyId";
17 | private static final String PAGINATION_TOKEN_TTL_IN_SECONDS_CONFIG_KEY =
18 | "configuration/pagination/TtlInSeconds";
19 |
20 | private final SsmParameterCachingClient ssm;
21 |
22 | @Override
23 | public String getApplicationsTableName() {
24 | return ssm.getAsString(APPLICATIONS_TABLE_NAME_CONFIG_KEY);
25 | }
26 |
27 | @Override
28 | public String getKmsKeyId() {
29 | return ssm.getAsString(KMS_KEY_ID_CONFIG_KEY);
30 | }
31 |
32 | @Override
33 | public Duration getPaginationTokenTtl() {
34 | try {
35 | String ttlString = ssm.getAsString(PAGINATION_TOKEN_TTL_IN_SECONDS_CONFIG_KEY);
36 | return Duration.ofSeconds(Long.parseLong(ttlString));
37 | } catch (ParameterNotFoundException e) {
38 | return DEFAULT_PAGINATION_TOKEN_TTL;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/container/factory/DynamoDbClientFactory.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.container.factory;
2 |
3 | import java.time.Duration;
4 |
5 | import org.glassfish.hk2.api.Factory;
6 |
7 | import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
8 | import software.amazon.awssdk.core.client.config.ClientOverrideConfiguration;
9 | import software.amazon.awssdk.core.retry.RetryPolicy;
10 | import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
11 | import software.amazon.awssdk.regions.Region;
12 | import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
13 |
14 | import software.amazon.serverless.apprepo.container.config.Env;
15 |
16 | /**
17 | * Factory for {@link DynamoDbClient} for HK2 DI wiring.
18 | */
19 | public class DynamoDbClientFactory implements Factory {
20 | // Creating the DynamoDB client followed AWS SDK v2 best practice to improve Lambda performance:
21 | // https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/client-configuration-starttime.html
22 | private static final DynamoDbClient dynamoDbClient = DynamoDbClient.builder()
23 | .region(Region.of(Env.getRegion()))
24 | .credentialsProvider(EnvironmentVariableCredentialsProvider.create())
25 | .overrideConfiguration(ClientOverrideConfiguration.builder()
26 | .apiCallAttemptTimeout(Duration.ofSeconds(1))
27 | .retryPolicy(RetryPolicy.builder().numRetries(10).build())
28 | .build())
29 | .httpClientBuilder(UrlConnectionHttpClient.builder()).build();
30 |
31 | @Override
32 | public DynamoDbClient provide() {
33 | return dynamoDbClient;
34 | }
35 |
36 | @Override
37 | public void dispose(DynamoDbClient dynamoDbClient) {
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/container/factory/KmsClientFactory.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.container.factory;
2 |
3 | import org.glassfish.hk2.api.Factory;
4 |
5 | import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
6 | import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
7 | import software.amazon.awssdk.regions.Region;
8 | import software.amazon.awssdk.services.kms.KmsClient;
9 |
10 | import software.amazon.serverless.apprepo.container.config.Env;
11 |
12 | /**
13 | * Factory for {@link KmsClient} for HK2 DI wiring.
14 | */
15 | public class KmsClientFactory implements Factory {
16 | // Creating the DynamoDB client followed AWS SDK v2 best practice to improve Lambda performance:
17 | // https://docs.aws.amazon.com/sdk-for-java/v2/developer-guide/client-configuration-starttime.html
18 | private static final KmsClient kmsClient = KmsClient.builder()
19 | .region(Region.of(Env.getRegion()))
20 | .credentialsProvider(EnvironmentVariableCredentialsProvider.create())
21 | .httpClientBuilder(UrlConnectionHttpClient.builder()).build();
22 |
23 | @Override
24 | public KmsClient provide() {
25 | return kmsClient;
26 | }
27 |
28 | @Override
29 | public void dispose(KmsClient kmsClient) {
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/backend/src/main/java/software/amazon/serverless/apprepo/container/factory/SsmConfigProviderFactory.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.container.factory;
2 |
3 | import java.time.Duration;
4 |
5 | import org.glassfish.hk2.api.Factory;
6 |
7 | import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
8 | import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
9 | import software.amazon.awssdk.regions.Region;
10 | import software.amazon.awssdk.services.ssm.SsmClient;
11 |
12 | import software.amazon.serverless.apprepo.container.config.ConfigProvider;
13 | import software.amazon.serverless.apprepo.container.config.Env;
14 | import software.amazon.serverless.apprepo.container.config.SsmConfigProvider;
15 | import software.amazon.serverless.ssmcachingclient.SsmParameterCachingClient;
16 |
17 | /**
18 | * Factory for {@link SsmConfigProvider} for HK2 DI wiring.
19 | */
20 | public class SsmConfigProviderFactory implements Factory {
21 | private static final ConfigProvider configProvider;
22 |
23 | static {
24 | SsmClient ssm = SsmClient.builder()
25 | .region(Region.of(Env.getRegion()))
26 | .credentialsProvider(EnvironmentVariableCredentialsProvider.create())
27 | .httpClientBuilder(UrlConnectionHttpClient.builder())
28 | .build();
29 | configProvider = new SsmConfigProvider(new SsmParameterCachingClient(ssm,
30 | Duration.ofMinutes(5), Env.getSsmConfigKeyPrefix()));
31 | }
32 |
33 | @Override
34 | public ConfigProvider provide() {
35 | return configProvider;
36 | }
37 |
38 | @Override
39 | public void dispose(ConfigProvider configProvider) {
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/backend/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | log=.
2 | log4j.rootLogger=INFO, LAMBDA
3 | #Define the LAMBDA appender
4 | log4j.appender.LAMBDA=com.amazonaws.services.lambda.runtime.log4j.LambdaAppender
5 | log4j.appender.LAMBDA.layout=org.apache.log4j.PatternLayout
6 | log4j.appender.LAMBDA.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} <%X{AWSRequestId}> [%t] %-5p %c{1}:%L - %m%n
7 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/AbstractAWSServerlessApplicationRepository.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client;
5 |
6 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationRequest;
7 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationResult;
8 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest;
9 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationResult;
10 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationRequest;
11 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationResult;
12 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsRequest;
13 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsResult;
14 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationRequest;
15 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationResult;
16 |
17 | import javax.annotation.Generated;
18 |
19 | /**
20 | * Abstract implementation of {@code AWSServerlessApplicationRepository}.
21 | */
22 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
23 | public class AbstractAWSServerlessApplicationRepository implements AWSServerlessApplicationRepository {
24 |
25 | protected AbstractAWSServerlessApplicationRepository() {
26 | }
27 |
28 | @Override
29 | public CreateApplicationResult createApplication(CreateApplicationRequest request) {
30 | throw new java.lang.UnsupportedOperationException();
31 | }
32 |
33 | @Override
34 | public DeleteApplicationResult deleteApplication(DeleteApplicationRequest request) {
35 | throw new java.lang.UnsupportedOperationException();
36 | }
37 |
38 | @Override
39 | public GetApplicationResult getApplication(GetApplicationRequest request) {
40 | throw new java.lang.UnsupportedOperationException();
41 | }
42 |
43 | @Override
44 | public ListApplicationsResult listApplications(ListApplicationsRequest request) {
45 | throw new java.lang.UnsupportedOperationException();
46 | }
47 |
48 | @Override
49 | public UpdateApplicationResult updateApplication(UpdateApplicationRequest request) {
50 | throw new java.lang.UnsupportedOperationException();
51 | }
52 |
53 | @Override
54 | public void shutdown() {
55 | throw new java.lang.UnsupportedOperationException();
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/auth/CognitoAuthorizer.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.auth;
5 |
6 | import com.amazonaws.ImmutableRequest;
7 | import com.amazonaws.SignableRequest;
8 | import com.amazonaws.auth.RequestSigner;
9 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository;
10 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepositoryClientBuilder;
11 |
12 | import javax.annotation.Generated;
13 |
14 | /**
15 | * A default implementation of {@link RequestSigner} that puts a generated token into the header. An implementation of
16 | * this can to be supplied during construction of a {@link AWSServerlessApplicationRepository} via
17 | * {@link AWSServerlessApplicationRepositoryClientBuilder#signer(CognitoAuthorizer)} like so
18 | *
19 | *
20 | *
21 | * AWSServerlessApplicationRepository client = AWSServerlessApplicationRepository.builder().signer((CognitoAuthorizer) request -> "some token").build();
22 | *
23 | *
24 | */
25 | @FunctionalInterface
26 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
27 | public interface CognitoAuthorizer extends RequestSigner {
28 |
29 | /**
30 | * Generate a token that will be added to Authorization in the header of the request during signing
31 | *
32 | * @param request
33 | * an immutable view of the request for which to generate a token
34 | * @return the token to use for signing
35 | */
36 | String generateToken(ImmutableRequest> request);
37 |
38 | /**
39 | * @see RequestSigner#sign(SignableRequest)
40 | */
41 | @Override
42 | default void sign(SignableRequest> request) {
43 | request.addHeader("Authorization", generateToken(request));
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/AWSServerlessApplicationRepositoryException.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import com.amazonaws.annotation.SdkInternalApi;
7 | import com.amazonaws.opensdk.SdkErrorHttpMetadata;
8 | import com.amazonaws.opensdk.internal.BaseException;
9 |
10 | import javax.annotation.Generated;
11 |
12 | /**
13 | * Base exception for all service exceptions thrown by backend service
14 | */
15 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
16 | public class AWSServerlessApplicationRepositoryException extends com.amazonaws.SdkBaseException implements BaseException {
17 |
18 | private static final long serialVersionUID = 1L;
19 |
20 | private SdkErrorHttpMetadata sdkHttpMetadata;
21 |
22 | private String message;
23 |
24 | /**
25 | * Constructs a new AWSServerlessApplicationRepositoryException with the specified error message.
26 | *
27 | * @param message
28 | * Describes the error encountered.
29 | */
30 | public AWSServerlessApplicationRepositoryException(String message) {
31 | super(message);
32 | this.message = message;
33 | }
34 |
35 | @Override
36 | public AWSServerlessApplicationRepositoryException sdkHttpMetadata(SdkErrorHttpMetadata sdkHttpMetadata) {
37 | this.sdkHttpMetadata = sdkHttpMetadata;
38 | return this;
39 | }
40 |
41 | @Override
42 | public SdkErrorHttpMetadata sdkHttpMetadata() {
43 | return sdkHttpMetadata;
44 | }
45 |
46 | @SdkInternalApi
47 | @Override
48 | public void setMessage(String message) {
49 | this.message = message;
50 | }
51 |
52 | @Override
53 | public String getMessage() {
54 | return message;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/BadRequestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class BadRequestException extends AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new BadRequestException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public BadRequestException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public BadRequestException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/ConflictException.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class ConflictException extends AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new ConflictException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public ConflictException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public ConflictException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/DeleteApplicationResult.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import java.io.Serializable;
7 | import javax.annotation.Generated;
8 |
9 | /**
10 | *
11 | * @see AWS
12 | * API Documentation
13 | */
14 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
15 | public class DeleteApplicationResult extends com.amazonaws.opensdk.BaseResult implements Serializable, Cloneable {
16 |
17 | /**
18 | * Returns a string representation of this object; useful for testing and debugging.
19 | *
20 | * @return A string representation of this object.
21 | *
22 | * @see java.lang.Object#toString()
23 | */
24 | @Override
25 | public String toString() {
26 | StringBuilder sb = new StringBuilder();
27 | sb.append("{");
28 | sb.append("}");
29 | return sb.toString();
30 | }
31 |
32 | @Override
33 | public boolean equals(Object obj) {
34 | if (this == obj)
35 | return true;
36 | if (obj == null)
37 | return false;
38 |
39 | if (obj instanceof DeleteApplicationResult == false)
40 | return false;
41 | DeleteApplicationResult other = (DeleteApplicationResult) obj;
42 | return true;
43 | }
44 |
45 | @Override
46 | public int hashCode() {
47 | final int prime = 31;
48 | int hashCode = 1;
49 |
50 | return hashCode;
51 | }
52 |
53 | @Override
54 | public DeleteApplicationResult clone() {
55 | try {
56 | return (DeleteApplicationResult) super.clone();
57 | } catch (CloneNotSupportedException e) {
58 | throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
59 | }
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/InternalServerErrorException.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class InternalServerErrorException extends AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new InternalServerErrorException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public InternalServerErrorException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public InternalServerErrorException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/NotFoundException.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class NotFoundException extends AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new NotFoundException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public NotFoundException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public NotFoundException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/TooManyRequestsException.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class TooManyRequestsException extends AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new TooManyRequestsException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public TooManyRequestsException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public TooManyRequestsException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/UnauthorizedException.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model;
5 |
6 | import javax.annotation.Generated;
7 |
8 | /**
9 | *
10 | */
11 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
12 | public class UnauthorizedException extends AWSServerlessApplicationRepositoryException {
13 | private static final long serialVersionUID = 1L;
14 |
15 | private String errorCode;
16 |
17 | /**
18 | * Constructs a new UnauthorizedException with the specified error message.
19 | *
20 | * @param message
21 | * Describes the error encountered.
22 | */
23 | public UnauthorizedException(String message) {
24 | super(message);
25 | }
26 |
27 | /**
28 | * @param errorCode
29 | */
30 |
31 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
32 | public void setErrorCode(String errorCode) {
33 | this.errorCode = errorCode;
34 | }
35 |
36 | /**
37 | * @return
38 | */
39 |
40 | @com.fasterxml.jackson.annotation.JsonProperty("errorCode")
41 | public String getErrorCode() {
42 | return this.errorCode;
43 | }
44 |
45 | /**
46 | * @param errorCode
47 | * @return Returns a reference to this object so that method calls can be chained together.
48 | */
49 |
50 | public UnauthorizedException errorCode(String errorCode) {
51 | setErrorCode(errorCode);
52 | return this;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ApplicationListMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.SdkClientException;
7 | import com.amazonaws.annotation.SdkInternalApi;
8 | import com.amazonaws.protocol.MarshallLocation;
9 | import com.amazonaws.protocol.MarshallingInfo;
10 | import com.amazonaws.protocol.MarshallingType;
11 | import com.amazonaws.protocol.ProtocolMarshaller;
12 | import software.amazon.serverless.apprepo.api.client.model.ApplicationList;
13 |
14 | import java.util.List;
15 | import javax.annotation.Generated;
16 |
17 | /**
18 | * ApplicationListMarshaller
19 | */
20 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
21 | @SdkInternalApi
22 | public class ApplicationListMarshaller {
23 |
24 | private static final MarshallingInfo APPLICATIONS_BINDING = MarshallingInfo.builder(MarshallingType.LIST).marshallLocation(MarshallLocation.PAYLOAD)
25 | .marshallLocationName("applications").build();
26 | private static final MarshallingInfo NEXTTOKEN_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
27 | .marshallLocationName("nextToken").build();
28 |
29 | private static final ApplicationListMarshaller instance = new ApplicationListMarshaller();
30 |
31 | public static ApplicationListMarshaller getInstance() {
32 | return instance;
33 | }
34 |
35 | /**
36 | * Marshall the given parameter object.
37 | */
38 | public void marshall(ApplicationList applicationList, ProtocolMarshaller protocolMarshaller) {
39 |
40 | if (applicationList == null) {
41 | throw new SdkClientException("Invalid argument passed to marshall(...)");
42 | }
43 |
44 | try {
45 | protocolMarshaller.marshall(applicationList.getApplications(), APPLICATIONS_BINDING);
46 | protocolMarshaller.marshall(applicationList.getNextToken(), NEXTTOKEN_BINDING);
47 | } catch (Exception e) {
48 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ApplicationSummaryMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.SdkClientException;
7 | import com.amazonaws.annotation.SdkInternalApi;
8 | import com.amazonaws.protocol.MarshallLocation;
9 | import com.amazonaws.protocol.MarshallingInfo;
10 | import com.amazonaws.protocol.MarshallingType;
11 | import com.amazonaws.protocol.ProtocolMarshaller;
12 | import software.amazon.serverless.apprepo.api.client.model.ApplicationSummary;
13 |
14 | import javax.annotation.Generated;
15 |
16 | /**
17 | * ApplicationSummaryMarshaller
18 | */
19 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
20 | @SdkInternalApi
21 | public class ApplicationSummaryMarshaller {
22 |
23 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
24 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("applicationId").build();
25 | private static final MarshallingInfo CREATIONTIME_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
26 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("creationTime").build();
27 | private static final MarshallingInfo DESCRIPTION_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
28 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("description").build();
29 |
30 | private static final ApplicationSummaryMarshaller instance = new ApplicationSummaryMarshaller();
31 |
32 | public static ApplicationSummaryMarshaller getInstance() {
33 | return instance;
34 | }
35 |
36 | /**
37 | * Marshall the given parameter object.
38 | */
39 | public void marshall(ApplicationSummary applicationSummary, ProtocolMarshaller protocolMarshaller) {
40 |
41 | if (applicationSummary == null) {
42 | throw new SdkClientException("Invalid argument passed to marshall(...)");
43 | }
44 |
45 | try {
46 | protocolMarshaller.marshall(applicationSummary.getApplicationId(), APPLICATIONID_BINDING);
47 | protocolMarshaller.marshall(applicationSummary.getCreationTime(), CREATIONTIME_BINDING);
48 | protocolMarshaller.marshall(applicationSummary.getDescription(), DESCRIPTION_BINDING);
49 | } catch (Exception e) {
50 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.SdkClientException;
7 | import com.amazonaws.annotation.SdkInternalApi;
8 | import com.amazonaws.protocol.MarshallLocation;
9 | import com.amazonaws.protocol.MarshallingInfo;
10 | import com.amazonaws.protocol.MarshallingType;
11 | import com.amazonaws.protocol.ProtocolMarshaller;
12 | import com.amazonaws.protocol.StructuredPojo;
13 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationRequest;
14 |
15 | import javax.annotation.Generated;
16 |
17 | /**
18 | * CreateApplicationRequestMarshaller
19 | */
20 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
21 | @SdkInternalApi
22 | public class CreateApplicationRequestMarshaller {
23 |
24 | private static final MarshallingInfo CREATEAPPLICATIONINPUT_BINDING = MarshallingInfo.builder(MarshallingType.STRUCTURED)
25 | .marshallLocation(MarshallLocation.PAYLOAD).isExplicitPayloadMember(true).build();
26 |
27 | private static final CreateApplicationRequestMarshaller instance = new CreateApplicationRequestMarshaller();
28 |
29 | public static CreateApplicationRequestMarshaller getInstance() {
30 | return instance;
31 | }
32 |
33 | /**
34 | * Marshall the given parameter object.
35 | */
36 | public void marshall(CreateApplicationRequest createApplicationRequest, ProtocolMarshaller protocolMarshaller) {
37 |
38 | if (createApplicationRequest == null) {
39 | throw new SdkClientException("Invalid argument passed to marshall(...)");
40 | }
41 |
42 | try {
43 | protocolMarshaller.marshall(createApplicationRequest.getCreateApplicationInput(), CREATEAPPLICATIONINPUT_BINDING);
44 | } catch (Exception e) {
45 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
46 | }
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.Request;
7 | import com.amazonaws.SdkClientException;
8 | import com.amazonaws.annotation.SdkInternalApi;
9 | import com.amazonaws.http.HttpMethodName;
10 | import com.amazonaws.protocol.OperationInfo;
11 | import com.amazonaws.protocol.Protocol;
12 | import com.amazonaws.protocol.ProtocolRequestMarshaller;
13 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationRequest;
14 | import com.amazonaws.transform.Marshaller;
15 |
16 | import javax.annotation.Generated;
17 |
18 | /**
19 | * CreateApplicationRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class CreateApplicationRequestProtocolMarshaller implements Marshaller, CreateApplicationRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY).requestUri("/Prod/applications")
26 | .httpMethodName(HttpMethodName.POST).hasExplicitPayloadMember(true).hasPayloadMembers(true).serviceName("AWSServerlessApplicationRepository")
27 | .build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public CreateApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(CreateApplicationRequest createApplicationRequest) {
36 |
37 | if (createApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | createApplicationRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | CreateApplicationRequestMarshaller.getInstance().marshall(createApplicationRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/CreateApplicationResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import static com.fasterxml.jackson.core.JsonToken.VALUE_NULL;
7 |
8 | import software.amazon.serverless.apprepo.api.client.model.CreateApplicationResult;
9 | import com.amazonaws.transform.JsonUnmarshallerContext;
10 | import com.amazonaws.transform.Unmarshaller;
11 | import com.fasterxml.jackson.core.JsonToken;
12 |
13 | import javax.annotation.Generated;
14 |
15 | /**
16 | * CreateApplicationResult JSON Unmarshaller
17 | */
18 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
19 | public class CreateApplicationResultJsonUnmarshaller implements Unmarshaller {
20 |
21 | public CreateApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception {
22 | CreateApplicationResult createApplicationResult = new CreateApplicationResult();
23 |
24 | int originalDepth = context.getCurrentDepth();
25 | String currentParentElement = context.getCurrentParentElement();
26 | int targetDepth = originalDepth + 1;
27 |
28 | JsonToken token = context.getCurrentToken();
29 | if (token == null)
30 | token = context.nextToken();
31 | if (token == VALUE_NULL) {
32 | return createApplicationResult;
33 | }
34 |
35 | while (true) {
36 | if (token == null)
37 | break;
38 |
39 | createApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context));
40 | token = context.nextToken();
41 | }
42 |
43 | return createApplicationResult;
44 | }
45 |
46 | private static CreateApplicationResultJsonUnmarshaller instance;
47 |
48 | public static CreateApplicationResultJsonUnmarshaller getInstance() {
49 | if (instance == null)
50 | instance = new CreateApplicationResultJsonUnmarshaller();
51 | return instance;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.SdkClientException;
7 | import com.amazonaws.annotation.SdkInternalApi;
8 | import com.amazonaws.protocol.MarshallLocation;
9 | import com.amazonaws.protocol.MarshallingInfo;
10 | import com.amazonaws.protocol.MarshallingType;
11 | import com.amazonaws.protocol.ProtocolMarshaller;
12 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest;
13 |
14 | import javax.annotation.Generated;
15 |
16 | /**
17 | * DeleteApplicationRequestMarshaller
18 | */
19 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
20 | @SdkInternalApi
21 | public class DeleteApplicationRequestMarshaller {
22 |
23 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
24 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build();
25 |
26 | private static final DeleteApplicationRequestMarshaller instance = new DeleteApplicationRequestMarshaller();
27 |
28 | public static DeleteApplicationRequestMarshaller getInstance() {
29 | return instance;
30 | }
31 |
32 | /**
33 | * Marshall the given parameter object.
34 | */
35 | public void marshall(DeleteApplicationRequest deleteApplicationRequest, ProtocolMarshaller protocolMarshaller) {
36 |
37 | if (deleteApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | protocolMarshaller.marshall(deleteApplicationRequest.getApplicationId(), APPLICATIONID_BINDING);
43 | } catch (Exception e) {
44 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
45 | }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.Request;
7 | import com.amazonaws.SdkClientException;
8 | import com.amazonaws.annotation.SdkInternalApi;
9 | import com.amazonaws.http.HttpMethodName;
10 | import com.amazonaws.protocol.OperationInfo;
11 | import com.amazonaws.protocol.Protocol;
12 | import com.amazonaws.protocol.ProtocolRequestMarshaller;
13 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest;
14 | import com.amazonaws.transform.Marshaller;
15 |
16 | import javax.annotation.Generated;
17 |
18 | /**
19 | * DeleteApplicationRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class DeleteApplicationRequestProtocolMarshaller implements Marshaller, DeleteApplicationRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY)
26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.DELETE).hasExplicitPayloadMember(false).hasPayloadMembers(false)
27 | .serviceName("AWSServerlessApplicationRepository").build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public DeleteApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(DeleteApplicationRequest deleteApplicationRequest) {
36 |
37 | if (deleteApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | deleteApplicationRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | DeleteApplicationRequestMarshaller.getInstance().marshall(deleteApplicationRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/DeleteApplicationResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationResult;
7 | import com.amazonaws.transform.JsonUnmarshallerContext;
8 | import com.amazonaws.transform.Unmarshaller;
9 |
10 | import javax.annotation.Generated;
11 |
12 | /**
13 | * DeleteApplicationResult JSON Unmarshaller
14 | */
15 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
16 | public class DeleteApplicationResultJsonUnmarshaller implements Unmarshaller {
17 |
18 | public DeleteApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception {
19 | DeleteApplicationResult deleteApplicationResult = new DeleteApplicationResult();
20 |
21 | return deleteApplicationResult;
22 | }
23 |
24 | private static DeleteApplicationResultJsonUnmarshaller instance;
25 |
26 | public static DeleteApplicationResultJsonUnmarshaller getInstance() {
27 | if (instance == null)
28 | instance = new DeleteApplicationResultJsonUnmarshaller();
29 | return instance;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.SdkClientException;
7 | import com.amazonaws.annotation.SdkInternalApi;
8 | import com.amazonaws.protocol.MarshallLocation;
9 | import com.amazonaws.protocol.MarshallingInfo;
10 | import com.amazonaws.protocol.MarshallingType;
11 | import com.amazonaws.protocol.ProtocolMarshaller;
12 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationRequest;
13 |
14 | import javax.annotation.Generated;
15 |
16 | /**
17 | * GetApplicationRequestMarshaller
18 | */
19 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
20 | @SdkInternalApi
21 | public class GetApplicationRequestMarshaller {
22 |
23 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
24 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build();
25 |
26 | private static final GetApplicationRequestMarshaller instance = new GetApplicationRequestMarshaller();
27 |
28 | public static GetApplicationRequestMarshaller getInstance() {
29 | return instance;
30 | }
31 |
32 | /**
33 | * Marshall the given parameter object.
34 | */
35 | public void marshall(GetApplicationRequest getApplicationRequest, ProtocolMarshaller protocolMarshaller) {
36 |
37 | if (getApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | protocolMarshaller.marshall(getApplicationRequest.getApplicationId(), APPLICATIONID_BINDING);
43 | } catch (Exception e) {
44 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
45 | }
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.Request;
7 | import com.amazonaws.SdkClientException;
8 | import com.amazonaws.annotation.SdkInternalApi;
9 | import com.amazonaws.http.HttpMethodName;
10 | import com.amazonaws.protocol.OperationInfo;
11 | import com.amazonaws.protocol.Protocol;
12 | import com.amazonaws.protocol.ProtocolRequestMarshaller;
13 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationRequest;
14 | import com.amazonaws.transform.Marshaller;
15 |
16 | import javax.annotation.Generated;
17 |
18 | /**
19 | * GetApplicationRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class GetApplicationRequestProtocolMarshaller implements Marshaller, GetApplicationRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY)
26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.GET).hasExplicitPayloadMember(false).hasPayloadMembers(false)
27 | .serviceName("AWSServerlessApplicationRepository").build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public GetApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(GetApplicationRequest getApplicationRequest) {
36 |
37 | if (getApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | getApplicationRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | GetApplicationRequestMarshaller.getInstance().marshall(getApplicationRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/GetApplicationResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import static com.fasterxml.jackson.core.JsonToken.VALUE_NULL;
7 |
8 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationResult;
9 | import com.amazonaws.transform.JsonUnmarshallerContext;
10 | import com.amazonaws.transform.Unmarshaller;
11 | import com.fasterxml.jackson.core.JsonToken;
12 |
13 | import javax.annotation.Generated;
14 |
15 | /**
16 | * GetApplicationResult JSON Unmarshaller
17 | */
18 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
19 | public class GetApplicationResultJsonUnmarshaller implements Unmarshaller {
20 |
21 | public GetApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception {
22 | GetApplicationResult getApplicationResult = new GetApplicationResult();
23 |
24 | int originalDepth = context.getCurrentDepth();
25 | String currentParentElement = context.getCurrentParentElement();
26 | int targetDepth = originalDepth + 1;
27 |
28 | JsonToken token = context.getCurrentToken();
29 | if (token == null)
30 | token = context.nextToken();
31 | if (token == VALUE_NULL) {
32 | return getApplicationResult;
33 | }
34 |
35 | while (true) {
36 | if (token == null)
37 | break;
38 |
39 | getApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context));
40 | token = context.nextToken();
41 | }
42 |
43 | return getApplicationResult;
44 | }
45 |
46 | private static GetApplicationResultJsonUnmarshaller instance;
47 |
48 | public static GetApplicationResultJsonUnmarshaller getInstance() {
49 | if (instance == null)
50 | instance = new GetApplicationResultJsonUnmarshaller();
51 | return instance;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.SdkClientException;
7 | import com.amazonaws.annotation.SdkInternalApi;
8 | import com.amazonaws.protocol.MarshallLocation;
9 | import com.amazonaws.protocol.MarshallingInfo;
10 | import com.amazonaws.protocol.MarshallingType;
11 | import com.amazonaws.protocol.ProtocolMarshaller;
12 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsRequest;
13 |
14 | import javax.annotation.Generated;
15 |
16 | /**
17 | * ListApplicationsRequestMarshaller
18 | */
19 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
20 | @SdkInternalApi
21 | public class ListApplicationsRequestMarshaller {
22 |
23 | private static final MarshallingInfo MAXITEMS_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
24 | .marshallLocation(MarshallLocation.QUERY_PARAM).marshallLocationName("maxItems").build();
25 | private static final MarshallingInfo NEXTTOKEN_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
26 | .marshallLocation(MarshallLocation.QUERY_PARAM).marshallLocationName("nextToken").build();
27 |
28 | private static final ListApplicationsRequestMarshaller instance = new ListApplicationsRequestMarshaller();
29 |
30 | public static ListApplicationsRequestMarshaller getInstance() {
31 | return instance;
32 | }
33 |
34 | /**
35 | * Marshall the given parameter object.
36 | */
37 | public void marshall(ListApplicationsRequest listApplicationsRequest, ProtocolMarshaller protocolMarshaller) {
38 |
39 | if (listApplicationsRequest == null) {
40 | throw new SdkClientException("Invalid argument passed to marshall(...)");
41 | }
42 |
43 | try {
44 | protocolMarshaller.marshall(listApplicationsRequest.getMaxItems(), MAXITEMS_BINDING);
45 | protocolMarshaller.marshall(listApplicationsRequest.getNextToken(), NEXTTOKEN_BINDING);
46 | } catch (Exception e) {
47 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
48 | }
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.Request;
7 | import com.amazonaws.SdkClientException;
8 | import com.amazonaws.annotation.SdkInternalApi;
9 | import com.amazonaws.http.HttpMethodName;
10 | import com.amazonaws.protocol.OperationInfo;
11 | import com.amazonaws.protocol.Protocol;
12 | import com.amazonaws.protocol.ProtocolRequestMarshaller;
13 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsRequest;
14 | import com.amazonaws.transform.Marshaller;
15 |
16 | import javax.annotation.Generated;
17 |
18 | /**
19 | * ListApplicationsRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class ListApplicationsRequestProtocolMarshaller implements Marshaller, ListApplicationsRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY).requestUri("/Prod/applications")
26 | .httpMethodName(HttpMethodName.GET).hasExplicitPayloadMember(false).hasPayloadMembers(false).serviceName("AWSServerlessApplicationRepository")
27 | .build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public ListApplicationsRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(ListApplicationsRequest listApplicationsRequest) {
36 |
37 | if (listApplicationsRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | listApplicationsRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | ListApplicationsRequestMarshaller.getInstance().marshall(listApplicationsRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/ListApplicationsResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import static com.fasterxml.jackson.core.JsonToken.VALUE_NULL;
7 |
8 | import software.amazon.serverless.apprepo.api.client.model.ListApplicationsResult;
9 | import com.amazonaws.transform.JsonUnmarshallerContext;
10 | import com.amazonaws.transform.Unmarshaller;
11 | import com.fasterxml.jackson.core.JsonToken;
12 |
13 | import javax.annotation.Generated;
14 |
15 | /**
16 | * ListApplicationsResult JSON Unmarshaller
17 | */
18 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
19 | public class ListApplicationsResultJsonUnmarshaller implements Unmarshaller {
20 |
21 | public ListApplicationsResult unmarshall(JsonUnmarshallerContext context) throws Exception {
22 | ListApplicationsResult listApplicationsResult = new ListApplicationsResult();
23 |
24 | int originalDepth = context.getCurrentDepth();
25 | String currentParentElement = context.getCurrentParentElement();
26 | int targetDepth = originalDepth + 1;
27 |
28 | JsonToken token = context.getCurrentToken();
29 | if (token == null)
30 | token = context.nextToken();
31 | if (token == VALUE_NULL) {
32 | return listApplicationsResult;
33 | }
34 |
35 | while (true) {
36 | if (token == null)
37 | break;
38 |
39 | listApplicationsResult.setApplicationList(ApplicationListJsonUnmarshaller.getInstance().unmarshall(context));
40 | token = context.nextToken();
41 | }
42 |
43 | return listApplicationsResult;
44 | }
45 |
46 | private static ListApplicationsResultJsonUnmarshaller instance;
47 |
48 | public static ListApplicationsResultJsonUnmarshaller getInstance() {
49 | if (instance == null)
50 | instance = new ListApplicationsResultJsonUnmarshaller();
51 | return instance;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationInputMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.SdkClientException;
7 | import com.amazonaws.annotation.SdkInternalApi;
8 | import com.amazonaws.protocol.MarshallLocation;
9 | import com.amazonaws.protocol.MarshallingInfo;
10 | import com.amazonaws.protocol.MarshallingType;
11 | import com.amazonaws.protocol.ProtocolMarshaller;
12 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationInput;
13 |
14 | import javax.annotation.Generated;
15 |
16 | /**
17 | * UpdateApplicationInputMarshaller
18 | */
19 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
20 | @SdkInternalApi
21 | public class UpdateApplicationInputMarshaller {
22 |
23 | private static final MarshallingInfo AUTHOR_BINDING = MarshallingInfo.builder(MarshallingType.STRING).marshallLocation(MarshallLocation.PAYLOAD)
24 | .marshallLocationName("author").build();
25 | private static final MarshallingInfo DESCRIPTION_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
26 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("description").build();
27 | private static final MarshallingInfo HOMEPAGEURL_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
28 | .marshallLocation(MarshallLocation.PAYLOAD).marshallLocationName("homePageUrl").build();
29 |
30 | private static final UpdateApplicationInputMarshaller instance = new UpdateApplicationInputMarshaller();
31 |
32 | public static UpdateApplicationInputMarshaller getInstance() {
33 | return instance;
34 | }
35 |
36 | /**
37 | * Marshall the given parameter object.
38 | */
39 | public void marshall(UpdateApplicationInput updateApplicationInput, ProtocolMarshaller protocolMarshaller) {
40 |
41 | if (updateApplicationInput == null) {
42 | throw new SdkClientException("Invalid argument passed to marshall(...)");
43 | }
44 |
45 | try {
46 | protocolMarshaller.marshall(updateApplicationInput.getAuthor(), AUTHOR_BINDING);
47 | protocolMarshaller.marshall(updateApplicationInput.getDescription(), DESCRIPTION_BINDING);
48 | protocolMarshaller.marshall(updateApplicationInput.getHomePageUrl(), HOMEPAGEURL_BINDING);
49 | } catch (Exception e) {
50 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationRequestMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.SdkClientException;
7 | import com.amazonaws.annotation.SdkInternalApi;
8 | import com.amazonaws.protocol.MarshallLocation;
9 | import com.amazonaws.protocol.MarshallingInfo;
10 | import com.amazonaws.protocol.MarshallingType;
11 | import com.amazonaws.protocol.ProtocolMarshaller;
12 | import com.amazonaws.protocol.StructuredPojo;
13 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationRequest;
14 |
15 | import javax.annotation.Generated;
16 |
17 | /**
18 | * UpdateApplicationRequestMarshaller
19 | */
20 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
21 | @SdkInternalApi
22 | public class UpdateApplicationRequestMarshaller {
23 |
24 | private static final MarshallingInfo APPLICATIONID_BINDING = MarshallingInfo.builder(MarshallingType.STRING)
25 | .marshallLocation(MarshallLocation.PATH).marshallLocationName("applicationId").build();
26 | private static final MarshallingInfo UPDATEAPPLICATIONINPUT_BINDING = MarshallingInfo.builder(MarshallingType.STRUCTURED)
27 | .marshallLocation(MarshallLocation.PAYLOAD).isExplicitPayloadMember(true).build();
28 |
29 | private static final UpdateApplicationRequestMarshaller instance = new UpdateApplicationRequestMarshaller();
30 |
31 | public static UpdateApplicationRequestMarshaller getInstance() {
32 | return instance;
33 | }
34 |
35 | /**
36 | * Marshall the given parameter object.
37 | */
38 | public void marshall(UpdateApplicationRequest updateApplicationRequest, ProtocolMarshaller protocolMarshaller) {
39 |
40 | if (updateApplicationRequest == null) {
41 | throw new SdkClientException("Invalid argument passed to marshall(...)");
42 | }
43 |
44 | try {
45 | protocolMarshaller.marshall(updateApplicationRequest.getApplicationId(), APPLICATIONID_BINDING);
46 | protocolMarshaller.marshall(updateApplicationRequest.getUpdateApplicationInput(), UPDATEAPPLICATIONINPUT_BINDING);
47 | } catch (Exception e) {
48 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
49 | }
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationRequestProtocolMarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import com.amazonaws.Request;
7 | import com.amazonaws.SdkClientException;
8 | import com.amazonaws.annotation.SdkInternalApi;
9 | import com.amazonaws.http.HttpMethodName;
10 | import com.amazonaws.protocol.OperationInfo;
11 | import com.amazonaws.protocol.Protocol;
12 | import com.amazonaws.protocol.ProtocolRequestMarshaller;
13 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationRequest;
14 | import com.amazonaws.transform.Marshaller;
15 |
16 | import javax.annotation.Generated;
17 |
18 | /**
19 | * UpdateApplicationRequest Marshaller
20 | */
21 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
22 | @SdkInternalApi
23 | public class UpdateApplicationRequestProtocolMarshaller implements Marshaller, UpdateApplicationRequest> {
24 |
25 | private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().protocol(Protocol.API_GATEWAY)
26 | .requestUri("/Prod/applications/{applicationId}").httpMethodName(HttpMethodName.PATCH).hasExplicitPayloadMember(true).hasPayloadMembers(true)
27 | .serviceName("AWSServerlessApplicationRepository").build();
28 |
29 | private final com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory;
30 |
31 | public UpdateApplicationRequestProtocolMarshaller(com.amazonaws.opensdk.protect.protocol.ApiGatewayProtocolFactoryImpl protocolFactory) {
32 | this.protocolFactory = protocolFactory;
33 | }
34 |
35 | public Request marshall(UpdateApplicationRequest updateApplicationRequest) {
36 |
37 | if (updateApplicationRequest == null) {
38 | throw new SdkClientException("Invalid argument passed to marshall(...)");
39 | }
40 |
41 | try {
42 | final ProtocolRequestMarshaller protocolMarshaller = protocolFactory.createProtocolMarshaller(SDK_OPERATION_BINDING,
43 | updateApplicationRequest);
44 |
45 | protocolMarshaller.startMarshalling();
46 | UpdateApplicationRequestMarshaller.getInstance().marshall(updateApplicationRequest, protocolMarshaller);
47 | return protocolMarshaller.finishMarshalling();
48 | } catch (Exception e) {
49 | throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/model/transform/UpdateApplicationResultJsonUnmarshaller.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package software.amazon.serverless.apprepo.api.client.model.transform;
5 |
6 | import static com.fasterxml.jackson.core.JsonToken.VALUE_NULL;
7 |
8 | import software.amazon.serverless.apprepo.api.client.model.UpdateApplicationResult;
9 | import com.amazonaws.transform.JsonUnmarshallerContext;
10 | import com.amazonaws.transform.Unmarshaller;
11 | import com.fasterxml.jackson.core.JsonToken;
12 |
13 | import javax.annotation.Generated;
14 |
15 | /**
16 | * UpdateApplicationResult JSON Unmarshaller
17 | */
18 | @Generated("com.amazonaws:aws-java-sdk-code-generator")
19 | public class UpdateApplicationResultJsonUnmarshaller implements Unmarshaller {
20 |
21 | public UpdateApplicationResult unmarshall(JsonUnmarshallerContext context) throws Exception {
22 | UpdateApplicationResult updateApplicationResult = new UpdateApplicationResult();
23 |
24 | int originalDepth = context.getCurrentDepth();
25 | String currentParentElement = context.getCurrentParentElement();
26 | int targetDepth = originalDepth + 1;
27 |
28 | JsonToken token = context.getCurrentToken();
29 | if (token == null)
30 | token = context.nextToken();
31 | if (token == VALUE_NULL) {
32 | return updateApplicationResult;
33 | }
34 |
35 | while (true) {
36 | if (token == null)
37 | break;
38 |
39 | updateApplicationResult.setApplication(ApplicationJsonUnmarshaller.getInstance().unmarshall(context));
40 | token = context.nextToken();
41 | }
42 |
43 | return updateApplicationResult;
44 | }
45 |
46 | private static UpdateApplicationResultJsonUnmarshaller instance;
47 |
48 | public static UpdateApplicationResultJsonUnmarshaller getInstance() {
49 | if (instance == null)
50 | instance = new UpdateApplicationResultJsonUnmarshaller();
51 | return instance;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/client/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 |
5 | /**
6 | *
7 | */
8 | package software.amazon.serverless.apprepo.api.client;
9 |
10 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/exception/ApiExceptionMapperTest.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.exception;
2 |
3 | import static org.assertj.core.api.Assertions.assertThat;
4 |
5 | import io.swagger.model.InternalServerErrorException;
6 | import io.swagger.model.NotFoundException;
7 |
8 | import javax.ws.rs.core.MediaType;
9 | import javax.ws.rs.core.Response;
10 |
11 | import org.junit.Before;
12 | import org.junit.Test;
13 |
14 | public class ApiExceptionMapperTest {
15 | private ApiExceptionMapper exceptionMapper;
16 |
17 | @Before
18 | public void setup() {
19 | exceptionMapper = new ApiExceptionMapper();
20 | }
21 |
22 | @Test
23 | public void toResponse_apiException() {
24 | NotFoundException exception = new NotFoundException();
25 | Response response = exceptionMapper.toResponse(new NotFoundApiException(exception));
26 | assertThat(response.getStatus()).isEqualTo(404);
27 | assertThat(response.getMediaType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE);
28 | assertThat(response.getEntity()).isEqualTo(exception);
29 | }
30 |
31 | @Test
32 | public void toResponse_otherException() {
33 | InternalServerErrorException exception = new InternalServerErrorException()
34 | .errorCode("InternalError")
35 | .message("Internal Server Error.");
36 | Response response = exceptionMapper.toResponse(new IllegalArgumentException());
37 | assertThat(response.getStatus()).isEqualTo(500);
38 | assertThat(response.getMediaType()).isEqualTo(MediaType.APPLICATION_JSON_TYPE);
39 | assertThat(response.getEntity()).isEqualTo(exception);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/impl/pagination/EncryptedTokenSerializerTest.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.impl.pagination;
2 |
3 | import static org.assertj.core.api.Assertions.assertThat;
4 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
5 | import static org.mockito.ArgumentMatchers.any;
6 | import static org.mockito.Mockito.when;
7 |
8 | import java.util.UUID;
9 |
10 | import org.junit.Before;
11 | import org.junit.Test;
12 | import org.mockito.Mock;
13 | import org.mockito.MockitoAnnotations;
14 | import software.amazon.awssdk.core.SdkBytes;
15 | import software.amazon.awssdk.services.kms.KmsClient;
16 | import software.amazon.awssdk.services.kms.model.DecryptRequest;
17 | import software.amazon.awssdk.services.kms.model.DecryptResponse;
18 | import software.amazon.awssdk.services.kms.model.EncryptRequest;
19 | import software.amazon.awssdk.services.kms.model.EncryptResponse;
20 |
21 | public class EncryptedTokenSerializerTest {
22 | private static final String KEY_ID = UUID.randomUUID().toString();
23 |
24 | @Mock
25 | private KmsClient kms;
26 | private TokenSerializer serializer;
27 |
28 | @Before
29 | public void setup() {
30 | MockitoAnnotations.initMocks(this);
31 | serializer = new EncryptedTokenSerializer(kms, KEY_ID);
32 | }
33 |
34 | @Test
35 | public void testSerializeAndDeserialize() throws Exception {
36 | String plainText = "cat";
37 | String cipherText = "dog";
38 | EncryptResponse encryptResponse = EncryptResponse.builder()
39 | .ciphertextBlob(SdkBytes.fromUtf8String(cipherText))
40 | .build();
41 | DecryptResponse decryptResponse = DecryptResponse.builder()
42 | .plaintext(SdkBytes.fromUtf8String(plainText))
43 | .build();
44 | when(kms.encrypt(any(EncryptRequest.class))).thenReturn(encryptResponse);
45 | when(kms.decrypt(any(DecryptRequest.class))).thenReturn(decryptResponse);
46 |
47 | String encodedToken = serializer.serialize(plainText);
48 | assertThat(serializer.deserialize(encodedToken))
49 | .isEqualTo(plainText);
50 | }
51 |
52 | @Test
53 | public void deserialize_nonBase64() {
54 | assertThatThrownBy(() -> serializer.deserialize("something"))
55 | .isInstanceOf(InvalidTokenException.class);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/api/impl/pagination/TimeBasedTokenSerializerTest.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.api.impl.pagination;
2 |
3 | import static org.assertj.core.api.Assertions.assertThat;
4 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
5 |
6 | import java.time.Duration;
7 | import java.time.Instant;
8 |
9 | import org.junit.Before;
10 | import org.junit.Test;
11 |
12 | public class TimeBasedTokenSerializerTest {
13 | private final static long TOKEN_TTL_IN_SECOND = 3600;
14 | private TokenSerializer serializer;
15 |
16 | @Before
17 | public void setup() {
18 | serializer = new TimeBasedTokenSerializer(Duration.ofSeconds(TOKEN_TTL_IN_SECOND));
19 | }
20 |
21 | @Test
22 | public void testSerializeAndDeserialize() throws Exception {
23 | String plainToken = "something";
24 | String encodedToken = serializer.serialize(plainToken);
25 | assertThat(serializer.deserialize(encodedToken))
26 | .isEqualTo(plainToken);
27 | }
28 |
29 | @Test
30 | public void deserialize_noTimestamp() {
31 | assertThatThrownBy(() -> serializer.deserialize("something"))
32 | .isInstanceOf(InvalidTokenException.class);
33 | }
34 |
35 | @Test
36 | public void deserialize_timestampNonBase64() {
37 | assertThatThrownBy(() -> serializer.deserialize("&something"))
38 | .isInstanceOf(InvalidTokenException.class);
39 | }
40 |
41 | @Test
42 | public void deserialize_tokenExpired() {
43 | Instant expiredInstant = Instant.now().minusSeconds(TOKEN_TTL_IN_SECOND + 1);
44 | assertThatThrownBy(() -> serializer.deserialize("something&" + expiredInstant.toString()))
45 | .isInstanceOf(InvalidTokenException.class);
46 | }
47 |
48 | @Test
49 | public void deserialize_noToken() {
50 | assertThatThrownBy(() -> serializer.deserialize("&" + Instant.now().toString()))
51 | .isInstanceOf(InvalidTokenException.class);
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/ApplicationsService_IT.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber;
2 |
3 | import io.cucumber.junit.Cucumber;
4 | import io.cucumber.junit.CucumberOptions;
5 | import org.junit.runner.RunWith;
6 |
7 | /**
8 | * Junit entry point for cucumber tests.
9 | */
10 | @RunWith(Cucumber.class)
11 | @CucumberOptions(features = "src/test/java/software/amazon/serverless/apprepo/cucumber/features",
12 | glue = "software.amazon.serverless.apprepo.cucumber.steps",
13 | tags = {"not @NotImplemented"},// Use @NotImplemented tag for scenarios that have not been implemented
14 | plugin = {"pretty"})
15 | public class ApplicationsService_IT {
16 | }
17 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/CreateApplication.feature:
--------------------------------------------------------------------------------
1 | Feature: CreateApplication
2 | As a user, I would like to create an application.
3 |
4 | Scenario: User creates an application
5 | When a user creates an application
6 | Then a new application should be created
7 |
8 | Scenario: User creates an application with the same id
9 | Given a user has an application
10 | When the user creates an application with the same id
11 | Then the call should fail because the application already exists
12 |
13 | Scenario: User creates an application without application id
14 | When a user creates an application without application id
15 | Then the call should fail because of bad request
16 |
17 | Scenario: User creates an application without author
18 | When a user creates an application without author
19 | Then the call should fail because of bad request
20 |
21 | Scenario: User creates an application without description
22 | When a user creates an application without description
23 | Then the call should fail because of bad request
24 |
25 | Scenario: User creates an application with invalid application id
26 | When a user creates an application with invalid application id
27 | Then the call should fail because of bad request
28 |
29 | Scenario: User creates an application with invalid author
30 | When a user creates an application with invalid author
31 | Then the call should fail because of bad request
32 |
33 | Scenario: User creates an application with invalid description
34 | When a user creates an application with invalid description
35 | Then the call should fail because of bad request
36 |
37 | Scenario: User creates an application with invalid home page URL
38 | When a user creates an application with invalid home page URL
39 | Then the call should fail because of bad request
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/DeleteApplication.feature:
--------------------------------------------------------------------------------
1 | Feature: DeleteApplication
2 | As a user, I would like to delete my application.
3 |
4 | Scenario: User deletes an application
5 | Given a user has an application
6 | When the user deletes the application
7 | Then the application should be deleted
8 | And the application should no longer be listed
9 |
10 | Scenario: User deletes a non-existent application
11 | When a user deletes a non-existent application
12 | Then the call should fail because the application does not exist
13 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/GetApplication.feature:
--------------------------------------------------------------------------------
1 | Feature: GetApplication
2 | As a user, I would like to get the details of my application.
3 |
4 | Scenario: User gets an application
5 | Given a user has an application
6 | When the user gets the application
7 | Then the application should be returned
8 |
9 | Scenario: User gets a non-existent application
10 | When a user gets a non-existent application
11 | Then the call should fail because the application does not exist
12 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/ListApplications.feature:
--------------------------------------------------------------------------------
1 | Feature: ListApplications
2 | As a user, I would like to see what applications I have.
3 |
4 | Scenario: User lists applications
5 | Given a user has an application
6 | And the user creates another application
7 | When the user lists applications
8 | Then all applications should be listed
9 | And the listed applications should be in alphabetical order
10 |
11 | Scenario: User lists applications with pagination
12 | Given a user has an application
13 | And the user creates another application
14 | And the user creates another application
15 | When the user lists applications with 2 max items
16 | Then 2 applications should be listed
17 | And the user lists applications with next token
18 | Then 1 applications should be listed
19 |
20 | Scenario: Unauthorized user lists applications
21 | When an unauthorized user lists applications
22 | Then the call should fail because of access denied
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/features/UpdateApplication.feature:
--------------------------------------------------------------------------------
1 | Feature: UpdateApplication
2 | As a user, I would like to update my application.
3 |
4 | Scenario: User updates an application
5 | Given a user has an application
6 | When the user updates the application
7 | Then the application should be updated
8 |
9 | Scenario: User updates an application with no update
10 | Given a user has an application
11 | When the user updates the application with no update
12 | Then the call should fail because there is no update
13 |
14 | Scenario: User updates a non-existent application
15 | When a user updates a non-existent application
16 | Then the call should fail because the application does not exist
17 |
18 | Scenario: User updates an application with invalid author
19 | Given a user has an application
20 | When the user updates the application with invalid author
21 | Then the call should fail because of bad request
22 |
23 | Scenario: User updates an application with invalid description
24 | Given a user has an application
25 | When the user updates the application with invalid description
26 | Then the call should fail because of bad request
27 |
28 | Scenario: User updates an application with invalid home page URL
29 | Given a user has an application
30 | When the user updates the application with invalid home page URL
31 | Then the call should fail because of bad request
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/guice/CognitoAuthorizerImpl.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber.guice;
2 |
3 | import com.amazonaws.ImmutableRequest;
4 | import software.amazon.serverless.apprepo.api.client.auth.CognitoAuthorizer;
5 | import software.amazon.serverless.apprepo.cucumber.steps.CognitoUserManager;
6 |
7 | import java.util.UUID;
8 |
9 | import lombok.RequiredArgsConstructor;
10 | import lombok.extern.slf4j.Slf4j;
11 |
12 | /**
13 | * Implementation of {@link CognitoAuthorizer} to provide signer for API requests.
14 | */
15 | @Slf4j
16 | @RequiredArgsConstructor
17 | public class CognitoAuthorizerImpl implements CognitoAuthorizer {
18 | private final CognitoUserManager cognitoUserManager;
19 |
20 | @Override
21 | public String generateToken(ImmutableRequest> request) {
22 | try {
23 | return cognitoUserManager.generateIdToken();
24 | } catch (Throwable t) {
25 | log.warn("Exception thrown when generating token", t);
26 | return UUID.randomUUID().toString();
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/guice/CukeInjectorSource.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber.guice;
2 |
3 | import com.google.common.collect.Lists;
4 | import com.google.inject.Guice;
5 | import com.google.inject.Injector;
6 |
7 | import cucumber.runtime.java.guice.InjectorSource;
8 |
9 | /**
10 | * Guice injector source for Cucumber.
11 | */
12 | public class CukeInjectorSource implements InjectorSource {
13 | @Override
14 | public Injector getInjector() {
15 | return Guice.createInjector(Lists.newArrayList(new ApplicationModule()));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/CommonSteps.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber.steps;
2 |
3 | import static org.assertj.core.api.Assertions.assertThat;
4 |
5 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository;
6 | import software.amazon.serverless.apprepo.api.client.model.BadRequestException;
7 | import software.amazon.serverless.apprepo.api.client.model.NotFoundException;
8 | import software.amazon.serverless.apprepo.api.client.model.UnauthorizedException;
9 | import com.google.inject.Inject;
10 |
11 | import io.cucumber.java.en.Then;
12 | import lombok.extern.slf4j.Slf4j;
13 |
14 | /**
15 | * Implementation of common steps in multiple features.
16 | */
17 | @Slf4j
18 | public class CommonSteps {
19 | @Inject
20 | private AWSServerlessApplicationRepository appRepo;
21 |
22 | @Then("^the call should fail because the application does not exist$")
23 | public void the_call_should_fail_because_the_application_does_not_exist() {
24 | assertThat(TestEnv.getLastException())
25 | .isNotNull()
26 | .isInstanceOf(NotFoundException.class);
27 | }
28 |
29 | @Then("^the call should fail because of bad request$")
30 | public void the_call_should_fail_because_of_bad_request() {
31 | assertThat(TestEnv.getLastException())
32 | .isNotNull()
33 | .isInstanceOf(BadRequestException.class);
34 | }
35 |
36 | @Then("^the call should fail because of access denied$")
37 | public void the_call_should_fail_because_of_access_denied() {
38 | assertThat(TestEnv.getLastException())
39 | .isNotNull()
40 | .isInstanceOf(UnauthorizedException.class);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/DeleteApplicationSteps.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber.steps;
2 |
3 | import static org.assertj.core.api.Assertions.assertThat;
4 | import static org.assertj.core.api.Assertions.assertThatThrownBy;
5 |
6 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository;
7 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest;
8 | import software.amazon.serverless.apprepo.api.client.model.NotFoundException;
9 | import com.google.common.base.Preconditions;
10 | import com.google.inject.Inject;
11 |
12 | import java.util.UUID;
13 |
14 | import io.cucumber.java.en.Then;
15 | import io.cucumber.java.en.When;
16 | import lombok.extern.slf4j.Slf4j;
17 |
18 | /**
19 | * Implementation of the steps in DeleteApplication.feature.
20 | */
21 | @Slf4j
22 | public class DeleteApplicationSteps {
23 | @Inject
24 | private AWSServerlessApplicationRepository appRepo;
25 |
26 | @When("^the user deletes the application$")
27 | public void the_user_deletes_the_application() {
28 | assertThat(TestEnv.getLastException()).isNull();
29 | Preconditions.checkState(TestEnv.getApplicationId() != null, "Step assumes previous application id exists");
30 |
31 | appRepo.deleteApplication(new DeleteApplicationRequest().applicationId(TestEnv.getApplicationId()));
32 | }
33 |
34 | @When("^a user deletes a non-existent application$")
35 | public void a_user_deletes_a_non_existent_application() {
36 | try {
37 | appRepo.deleteApplication(new DeleteApplicationRequest()
38 | .applicationId("applicationId" + UUID.randomUUID().toString()));
39 | } catch (Exception e) {
40 | // do nothing and verify exception in the next step
41 | }
42 | }
43 |
44 | @Then("^the application should be deleted$")
45 | public void the_application_should_be_deleted() {
46 | assertThat(TestEnv.getLastException()).isNull();
47 | Preconditions.checkState(TestEnv.getApplicationId() != null, "Step assumes previous application id exists");
48 | assertThatThrownBy(() -> appRepo.deleteApplication(new DeleteApplicationRequest()
49 | .applicationId("applicationId" + UUID.randomUUID().toString())))
50 | .isInstanceOf(NotFoundException.class);
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/GetApplicationSteps.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber.steps;
2 |
3 | import static org.assertj.core.api.Assertions.assertThat;
4 |
5 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository;
6 | import software.amazon.serverless.apprepo.api.client.model.Application;
7 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationRequest;
8 | import software.amazon.serverless.apprepo.api.client.model.GetApplicationResult;
9 | import com.google.common.base.Preconditions;
10 | import com.google.inject.Inject;
11 |
12 | import java.util.UUID;
13 |
14 | import io.cucumber.java.en.Then;
15 | import io.cucumber.java.en.When;
16 | import lombok.extern.slf4j.Slf4j;
17 |
18 | /**
19 | * Implementation of the steps in GetApplication.feature.
20 | */
21 | @Slf4j
22 | public class GetApplicationSteps {
23 | @Inject
24 | private AWSServerlessApplicationRepository appRepo;
25 |
26 | @When("^the user gets the application$")
27 | public void the_user_gets_the_application() {
28 | assertThat(TestEnv.getLastException()).isNull();
29 | Preconditions.checkState(TestEnv.getApplicationId() != null, "Step assumes previous application id exists");
30 |
31 | GetApplicationResult result = appRepo.getApplication(new GetApplicationRequest().applicationId(TestEnv.getApplicationId()));
32 | TestEnv.setApplication(result.getApplication());
33 | }
34 |
35 | @When("^a user gets a non-existent application$")
36 | public void a_user_gets_a_non_existent_application() {
37 | try {
38 | appRepo.getApplication(new GetApplicationRequest()
39 | .applicationId("applicationId-" + UUID.randomUUID().toString()));
40 | } catch (Exception e) {
41 | // do nothing and verify exception in the next step
42 | }
43 | }
44 |
45 | @Then("^the application should be returned$")
46 | public void the_application_should_be_returned() {
47 | assertThat(TestEnv.getLastException()).isNull();
48 | Application application = TestEnv.getApplication();
49 | assertThat(application.getApplicationId()).isEqualTo(TestEnv.getApplicationId());
50 | assertThat(application.getAuthor()).isEqualTo(TestEnv.getAuthor());
51 | assertThat(application.getDescription()).isEqualTo(TestEnv.getApplicationDescription());
52 | assertThat(application.getHomePageUrl()).isEqualTo(TestEnv.getHomePageUrl());
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/backend/src/test/java/software/amazon/serverless/apprepo/cucumber/steps/SetupAndTeardownSteps.java:
--------------------------------------------------------------------------------
1 | package software.amazon.serverless.apprepo.cucumber.steps;
2 |
3 | import software.amazon.serverless.apprepo.api.client.AWSServerlessApplicationRepository;
4 | import software.amazon.serverless.apprepo.api.client.model.DeleteApplicationRequest;
5 | import com.google.inject.Inject;
6 |
7 | import java.time.Duration;
8 | import java.time.Instant;
9 |
10 | import io.cucumber.core.api.Scenario;
11 | import io.cucumber.java.After;
12 | import io.cucumber.java.Before;
13 | import lombok.extern.slf4j.Slf4j;
14 |
15 | /**
16 | * Setup and teardown implementation.
17 | */
18 | @Slf4j
19 | public class SetupAndTeardownSteps {
20 | @Inject
21 | private AWSServerlessApplicationRepository appRepo;
22 | @Inject
23 | private CognitoUserManager cognitoUserManager;
24 |
25 | @Before
26 | public void beforeScenario(final Scenario s) {
27 | TestEnv.reset();
28 | Instant startedAt = Instant.now();
29 | TestEnv.setScenarioStartedAt(startedAt);
30 | cognitoUserManager.setupCognitoUser();
31 | log.info("Starting scenario \"{}\" at {}", s.getName(), startedAt);
32 | }
33 |
34 | @After
35 | public void afterScenario(Scenario s) {
36 | TestEnv.getApplications().forEach(app -> tryDeleteApplication(app.getApplicationId()));
37 |
38 | try {
39 | cognitoUserManager.cleanupCognitoUser();
40 | } catch (Throwable t) {
41 | log.warn(String.format("Failed to clean up cognito user %s", TestEnv.getUsername()), t);
42 | }
43 |
44 | Instant endedAt = Instant.now();
45 | long durationMillis = Duration.between(TestEnv.getScenarioStartedAt(), endedAt).toMillis();
46 | if (s.isFailed()) {
47 | log.info("Failed scenario \"{}\" at {} (Duration: {} ms)", s.getName(), endedAt, durationMillis);
48 | log.info("TestData: {}", TestEnv.getTestData().toString());
49 | } else {
50 | log.info("Completed scenario \"{}\" at {} (Duration: {} ms)", s.getName(), endedAt, durationMillis);
51 | }
52 |
53 | }
54 |
55 | private void tryDeleteApplication(String applicationId) {
56 | try {
57 | log.info("Cleaning up application {}", applicationId);
58 | appRepo.deleteApplication(new DeleteApplicationRequest().applicationId(applicationId));
59 | } catch (Throwable t) {
60 | log.warn("Failed to clean up application {}", applicationId, t);
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/backend/src/test/resources/cucumber.properties:
--------------------------------------------------------------------------------
1 | guice.injector-source=software.amazon.serverless.apprepo.cucumber.guice.CukeInjectorSource
2 |
--------------------------------------------------------------------------------
/backend/src/test/resources/integ-test-env.template.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Description: >-
3 | This template creates the resources for integration tests.
4 |
5 | Parameters:
6 | Stage:
7 | Type: String
8 | Description: The stage where the application is running in, e.g., dev, prod.
9 | Resources:
10 | IntegTestClient:
11 | Type: AWS::Cognito::UserPoolClient
12 | Properties:
13 | UserPoolId: !Sub '{{resolve:ssm:/applications/apprepo/${Stage}/cognito/userpool/ApplicationsApi/Id:1}}'
14 | GenerateSecret: false
15 | ExplicitAuthFlows:
16 | - ADMIN_NO_SRP_AUTH
17 |
18 | IntegTestClientId:
19 | Type: "AWS::SSM::Parameter"
20 | Properties:
21 | Name: !Sub "/applications/apprepo/${Stage}/cognito/userpoolclient/IntegTest/${AWS::StackName}/Id"
22 | Type: "String"
23 | Value: !Ref IntegTestClient
24 | Description: "Integration test Cognito User Pool Client ID."
--------------------------------------------------------------------------------
/bin/delete-stack.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | #
3 | # Delete a CloudFormation stack. This is best effort and failing to delete a stack won't fail the script.
4 | #
5 | # This script assumes following are installed on the build host:
6 | # - AWS CLI
7 |
8 | usage() {
9 | echo "Usage:"
10 | echo " delete-stack.sh -n Delete CloudFormation stack by name."
11 | echo "Example:"
12 | echo " delete-stack.sh -n my-stack"
13 | }
14 |
15 | arg_parse() {
16 | while getopts "n:" opt; do
17 | case ${opt} in
18 | n )
19 | STACK_NAME=${OPTARG}
20 | ;;
21 | \? )
22 | usage
23 | exit 1
24 | ;;
25 | esac
26 | done
27 | shift $((OPTIND -1))
28 |
29 | if [[ -z ${STACK_NAME} ]]
30 | then
31 | usage
32 | exit 1;
33 | fi
34 | }
35 |
36 | main() {
37 | arg_parse "$@"
38 | echo "Deleting stack: ${STACK_NAME}"
39 | aws cloudformation delete-stack --stack-name ${STACK_NAME}
40 | exit 0
41 | }
42 |
43 | # Spin up hook
44 | main "$@"
--------------------------------------------------------------------------------
/bin/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Deploy a SAM template.
5 | #
6 | # This script assumes following are installed on the build host:
7 | # - AWS CLI
8 |
9 | set -e # fail script on any individual command failing
10 |
11 | usage() {
12 | echo "Usage:"
13 | echo " deploy.sh -n -t [-o ] Deploy SAM template."
14 | echo "Example:"
15 | echo " deploy.sh -n realworld-serverless-application-backend-prod -t backend/target/sam/app/packaged-template.yaml -o \"Stage=prod\""
16 | }
17 |
18 | arg_parse() {
19 | while getopts "n:t:o:" opt; do
20 | case ${opt} in
21 | n )
22 | STACK_NAME=${OPTARG}
23 | ;;
24 | t )
25 | TEMPLATE=${OPTARG}
26 | ;;
27 | o )
28 | PARAMETERS=${OPTARG}
29 | ;;
30 | \? )
31 | usage
32 | exit 1
33 | ;;
34 | esac
35 | done
36 | shift $((OPTIND -1))
37 |
38 | if [[ -z ${STACK_NAME} ]] || [[ -z ${TEMPLATE} ]]
39 | then
40 | usage
41 | exit 1;
42 | fi
43 | }
44 |
45 | deploy() {
46 | echo "Deploying SAM template: ${TEMPLATE} to Stack ${STACK_NAME} with parameter overrides ${PARAMETERS}"
47 | if [[ -z "${PARAMETERS}" ]]
48 | then
49 | aws cloudformation deploy \
50 | --template-file ${TEMPLATE} \
51 | --stack-name ${STACK_NAME} \
52 | --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND
53 | else
54 | aws cloudformation deploy \
55 | --template-file ${TEMPLATE} \
56 | --stack-name ${STACK_NAME} \
57 | --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND \
58 | --parameter-overrides ${PARAMETERS}
59 | fi
60 | }
61 |
62 | main() {
63 | arg_parse "$@"
64 | deploy
65 | }
66 |
67 | # Spin up hook
68 | main "$@"
69 |
--------------------------------------------------------------------------------
/bin/generate-sdk.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # Generate SDK from API Gateway and put it under test sources
5 | #
6 | # This script assumes the following are installed on the host:
7 | # - AWS CLI
8 |
9 | set -e # fail script on any individual command failing
10 |
11 | usage() {
12 | echo "Usage:"
13 | echo " generate-sdk.sh -i Generate SDK from API Gateway Rest API ID"
14 | echo "Example:"
15 | echo " generate-sdk.sh -i 4a9oerm0eh"
16 | }
17 |
18 | arg_parse() {
19 | while getopts "i:" opt; do
20 | case ${opt} in
21 | i )
22 | REST_API_ID=${OPTARG}
23 | ;;
24 | \? )
25 | usage
26 | exit 1
27 | ;;
28 | esac
29 | done
30 | shift $((OPTIND -1))
31 |
32 | if [[ -z ${REST_API_ID} ]]
33 | then
34 | usage
35 | exit 1;
36 | fi
37 | }
38 |
39 | generate_sdk() {
40 | MODULE_DIR=`dirname "${BASH_SOURCE[0]}"`/..
41 | mkdir -p ${MODULE_DIR}/target
42 |
43 | ZIP_PATH=${MODULE_DIR}/target/api-sdk.zip
44 | echo "Generating SDK from API Gateway Rest API ${REST_API_ID} to ${ZIP_PATH}"
45 |
46 | aws apigateway get-sdk \
47 | --rest-api-id ${REST_API_ID} \
48 | --stage-name Prod \
49 | --sdk-type java \
50 | --parameters service.name='AWSServerlessApplicationRepository',java.package-name='software.amazon.serverless.apprepo.api.client' ${ZIP_PATH}
51 |
52 | UNZIP_DIR=${MODULE_DIR}/target/sdk
53 | echo "Unzipping SDK zip to directory ${UNZIP_DIR}"
54 | mkdir -p ${UNZIP_DIR}
55 | unzip ${ZIP_PATH} -d ${UNZIP_DIR}
56 |
57 | for component in backend analytics
58 | do
59 | echo "Copying generated SDK to ${component} test source directory"
60 | rsync -avr --exclude=${UNZIP_DIR}/generated-code/pom.xml \
61 | --exclude=${UNZIP_DIR}/generated-code/README.html \
62 | --exclude=${UNZIP_DIR}/generated-code/README.md \
63 | ${UNZIP_DIR}/generated-code/src/main/* ${MODULE_DIR}/${component}/src/test/
64 | done
65 | }
66 |
67 | main() {
68 | arg_parse "$@"
69 | generate_sdk
70 | }
71 |
72 | # Spin up hook
73 | main "$@"
--------------------------------------------------------------------------------
/bin/package.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Packages SAM templates for a specific module, such as backend
4 | #
5 | # This script assumes the following environment variable is set:
6 | # - PACKAGE_BUCKET: the S3 bucket name used to store packaged artifacts
7 | #
8 | # This script assumes following are installed on the build host:
9 | # - AWS CLI
10 |
11 | set -e # fail script on any individual command failing
12 |
13 | usage() {
14 | echo "Usage:"
15 | echo " package.sh -n [-b ] Package SAM template and upload artifacts to the package bucket."
16 | echo "Example:"
17 | echo " package.sh -n backend"
18 | }
19 |
20 | arg_parse() {
21 | while getopts "n:b:" opt; do
22 | case ${opt} in
23 | n )
24 | MODULE=${OPTARG}
25 | ;;
26 | b )
27 | PACKAGE_BUCKET=${OPTARG}
28 | ;;
29 | \? )
30 | usage
31 | exit 1
32 | ;;
33 | esac
34 | done
35 | shift $((OPTIND -1))
36 |
37 | if [[ -z ${MODULE} ]]
38 | then
39 | usage
40 | exit 1;
41 | fi
42 |
43 | if [[ -z ${PACKAGE_BUCKET} ]]
44 | then
45 | echo "PACKAGE_BUCKET must be set either as environment variable or via the command"
46 | usage
47 | exit 1;
48 | fi
49 | }
50 |
51 | package() {
52 | module_dir=`dirname "${BASH_SOURCE[0]}"`/../${MODULE}
53 |
54 | for component in app cicd
55 | do
56 | template_file=${module_dir}/sam/${component}/template.yaml
57 | if [[ -f ${template_file} ]]; then
58 | output_template_file=${module_dir}/target/sam/${component}/packaged-template.yaml
59 |
60 | echo "Packaging SAM template: ${template_file}"
61 | mkdir -p `dirname ${output_template_file}`
62 |
63 | aws cloudformation package \
64 | --template-file ${template_file} \
65 | --s3-bucket ${PACKAGE_BUCKET} \
66 | --output-template-file ${output_template_file}
67 | else
68 | echo "Template file ${template_file} does not exist. Skip packaging."
69 | fi
70 | done
71 | }
72 |
73 | main() {
74 | arg_parse "$@"
75 | package
76 | }
77 |
78 | # Spin up hook
79 | main "$@"
80 |
--------------------------------------------------------------------------------
/buildspec.yaml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | java: openjdk8
7 | nodejs: 8
8 | commands:
9 | - npm install -g @vue/cli
10 | build:
11 | commands:
12 | - cd static-website
13 | - npm install
14 | - npm run ci
15 | - cd ..
16 | - mvn clean package -DpackageBucket=${PACKAGE_BUCKET}
17 |
--------------------------------------------------------------------------------
/images/architecture_diagram.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amazon-archives/realworld-serverless-application/effdb9643b778fa78280bfb5da9e6db371f5b09e/images/architecture_diagram.png
--------------------------------------------------------------------------------
/ops/README.md:
--------------------------------------------------------------------------------
1 | # realworld-serverless-application-ops
2 |
3 | realworld-serverless-application-ops is the operations (DevOps) component of a larger project providing alarms and dashboards for the application. It can be deployed together with the other system components to produce an example serverless application demonstrating real world patterns and best practices for serverless applications.
4 |
5 | To get started with the full project, follow the [Quick Start](https://github.com/awslabs/realworld-serverless-application/wiki/Quick-Start) guide.
6 |
7 | ## License
8 |
9 | This project is licensed under the Apache-2.0 License.
10 |
--------------------------------------------------------------------------------
/ops/buildspec.yaml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | java: openjdk8 # Runtime version is required in the build spec even though this module does not use java
7 | build:
8 | commands:
9 | - bin/package.sh -n ops
10 | artifacts:
11 | files:
12 | - ops/target/sam/app/packaged-template.yaml
13 | discard-paths: yes
14 |
--------------------------------------------------------------------------------
/ops/images/alarm-email.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amazon-archives/realworld-serverless-application/effdb9643b778fa78280bfb5da9e6db371f5b09e/ops/images/alarm-email.png
--------------------------------------------------------------------------------
/ops/images/alarms.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amazon-archives/realworld-serverless-application/effdb9643b778fa78280bfb5da9e6db371f5b09e/ops/images/alarms.png
--------------------------------------------------------------------------------
/ops/images/dashboard.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amazon-archives/realworld-serverless-application/effdb9643b778fa78280bfb5da9e6db371f5b09e/ops/images/dashboard.png
--------------------------------------------------------------------------------
/ops/sam/app/template.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Transform: 'AWS::Serverless-2016-10-31'
3 | Description: >-
4 | This application creates alarms and dashboards for a backend service.
5 |
6 | Metadata:
7 | AWS::ServerlessRepo::Application:
8 | Name: realworld-serverless-application-ops
9 | Description: >-
10 | This application creates alarms and dashboards for the backend service.
11 | Author: AWS Serverless Application Repository
12 | SpdxLicenseId: Apache-2.0
13 | Labels: [github, serverless, sam]
14 | HomePageUrl: https://github.com/awslabs/realworld-serverless-application
15 | SemanticVersion: 1.0.1
16 | SourceCodeUrl: https://github.com/awslabs/realworld-serverless-application/tree/1.0.1
17 | LicenseUrl: ../../../LICENSE
18 | ReadmeUrl: ../../README.md
19 |
20 | Parameters:
21 | Stage:
22 | Type: String
23 | Description: The stage where the application is running in, e.g., dev, prod.
24 | Default: 'test'
25 |
26 | Resources:
27 | Alarm:
28 | Type: 'AWS::Serverless::Application'
29 | Properties:
30 | Location: 'alarm.template.yaml'
31 | Parameters:
32 | Stage: !Ref Stage
33 | Dashboard:
34 | Type: 'AWS::Serverless::Application'
35 | Properties:
36 | Location: 'dashboard.template.yaml'
37 | Parameters:
38 | Stage: !Ref Stage
39 |
--------------------------------------------------------------------------------
/sam/app/template.yaml:
--------------------------------------------------------------------------------
1 | AWSTemplateFormatVersion: '2010-09-09'
2 | Transform: 'AWS::Serverless-2016-10-31'
3 | Description: >-
4 | This project is an adaptation of the AWS Serverless Application Repository.
5 | It's primary objective is to serve as a case study of how to build a production grade service using a combination of serverless technologies and approaches.
6 | Metadata:
7 | AWS::ServerlessRepo::Application:
8 | Name: realworld-serverless-application
9 | Description: >-
10 | This project is an adaptation of the AWS Serverless Application Repository.
11 | It's primary objective is to serve as a case study of how to build a production grade service using a combination of serverless technologies and approaches.
12 | Author: AWS Serverless Application Repository
13 | SpdxLicenseId: Apache-2.0
14 | Labels: [github, serverless, sam]
15 | HomePageUrl: https://github.com/awslabs/realworld-serverless-application
16 | SemanticVersion: 1.0.1
17 | SourceCodeUrl: https://github.com/awslabs/realworld-serverless-application/tree/1.0.1
18 | LicenseUrl: ../../LICENSE
19 | ReadmeUrl: ../../README.md
20 |
21 | Parameters:
22 | Stage:
23 | Type: String
24 | Description: The stage where the application is running in, e.g., dev, prod.
25 | Default: 'test'
26 |
27 | Resources:
28 | Backend:
29 | Type: 'AWS::Serverless::Application'
30 | Properties:
31 | Location: '../../backend/sam/app/template.yaml'
32 | Parameters:
33 | Stage: !Ref Stage
34 | Ops:
35 | Type: 'AWS::Serverless::Application'
36 | Properties:
37 | Location: '../../ops/sam/app/template.yaml'
38 | Parameters:
39 | Stage: !Ref Stage
40 | DependsOn: Backend
41 | Website:
42 | Type: 'AWS::Serverless::Application'
43 | Properties:
44 | Location: '../../static-website/sam/app/template.yaml'
45 | Parameters:
46 | Stage: !Ref Stage
47 | DependsOn: Backend
48 | Analytics:
49 | Type: 'AWS::Serverless::Application'
50 | Properties:
51 | Location: '../../analytics/sam/app/template.yaml'
52 | Parameters:
53 | Stage: !Ref Stage
54 | DependsOn: Backend
55 |
56 | Outputs:
57 | WebsiteUrl:
58 | Description: The static website URL for the service.
59 | Value: !GetAtt Website.Outputs.Url
60 |
61 |
--------------------------------------------------------------------------------
/static-website/.browserslistrc:
--------------------------------------------------------------------------------
1 | > 1%
2 | last 2 versions
3 |
--------------------------------------------------------------------------------
/static-website/.editorconfig:
--------------------------------------------------------------------------------
1 | [*.{js,jsx,ts,tsx,vue}]
2 | indent_style = space
3 | indent_size = 2
4 | end_of_line = lf
5 | trim_trailing_whitespace = true
6 | insert_final_newline = true
7 | max_line_length = 100
8 |
--------------------------------------------------------------------------------
/static-website/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: {
4 | node: true,
5 | },
6 | extends: [
7 | 'plugin:vue/essential',
8 | '@vue/airbnb',
9 | ],
10 | rules: {
11 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
12 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
13 | 'no-shadow': 'off',
14 | 'max-len': ['error', 120, 2, {
15 | ignoreUrls: true,
16 | ignoreComments: false,
17 | ignoreRegExpLiterals: true,
18 | ignoreStrings: true,
19 | ignoreTemplateLiterals: true,
20 | }],
21 | },
22 | parserOptions: {
23 | parser: 'babel-eslint',
24 | },
25 | overrides: [
26 | {
27 | files: [
28 | '**/__tests__/*.{j,t}s?(x)',
29 | ],
30 | env: {
31 | mocha: true,
32 | },
33 | },
34 | ],
35 | };
36 |
--------------------------------------------------------------------------------
/static-website/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | node_modules
3 | /dist
4 |
5 | /tests/e2e/reports/
6 | selenium-debug.log
7 |
8 | # local env files
9 | .env.local
10 | .env.*.local
11 |
12 | # Log files
13 | npm-debug.log*
14 | yarn-debug.log*
15 | yarn-error.log*
16 |
17 | # Editor directories and files
18 | .idea
19 | .vscode
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/static-website/README.md:
--------------------------------------------------------------------------------
1 | # realworld-serverless-application-website
2 |
3 | realworld-serverless-application-website is the website component of a larger project providing a web UI for the application. It can be deployed together with the other system components to produce an example serverless application demonstrating real world patterns and best practices for serverless applications.
4 |
5 | To get started with the full project, follow the [Quick Start](https://github.com/awslabs/realworld-serverless-application/wiki/Quick-Start) guide.
6 |
7 | ## License
8 |
9 | This project is licensed under the Apache-2.0 License.
10 |
--------------------------------------------------------------------------------
/static-website/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | [
4 | '@vue/app',
5 | {
6 | useBuiltIns: 'entry',
7 | },
8 | ],
9 | ],
10 | };
11 |
--------------------------------------------------------------------------------
/static-website/bin/package-static-website.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Builds and packages static website SAR static website module
4 |
5 | set -e # fail script on any individual command failing
6 |
7 | VUE_CLI=$(which vue)
8 | if [ -z "$VUE_CLI" ] ; then
9 | echo "Cannot find vue CLI in path. Please ensure vue CLI is installed and in your path."
10 | exit 1
11 | fi
12 |
13 | DIR=`dirname "${BASH_SOURCE[0]}"`
14 | # build production static website
15 | cd ${DIR}/..
16 | npm install
17 | npm run ci
18 |
19 |
--------------------------------------------------------------------------------
/static-website/buildspec-integ-test.yaml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | nodejs: 8
7 | java: openjdk8
8 | commands:
9 | - npm install -g @vue/cli
10 | build:
11 | commands:
12 | - TEST_STAGE=integ-tests-`date +%s`
13 | - ./static-website/bin/package-static-website.sh
14 | - mvn clean package -DpackageBucket=${PACKAGE_BUCKET}
15 | - ./bin/deploy.sh -n $TEST_STAGE-backend -t backend/sam/app/packaged-template.yaml -o "Stage=$TEST_STAGE"
16 | - ./bin/package.sh -n static-website
17 | - ./bin/deploy.sh -n $TEST_STAGE-website -t static-website/sam/app/packaged-template.yaml -o "Stage=$TEST_STAGE"
18 | - WEBSITE_URL=$(aws ssm get-parameter --name /applications/apprepo/$TEST_STAGE/s3/WebsiteBucket/WebsiteURL --query Parameter.Value --output text)
19 | - COGNITO_USER_POOL_ID=$(aws ssm get-parameter --name /applications/apprepo/$TEST_STAGE/cognito/userpool/ApplicationsApi/Id --query Parameter.Value --output text)
20 | - cd static-website
21 | - echo "Running tests in Chrome"
22 | - npm run test:e2e -- -e chrome
23 | - echo "Running tests in Firefox"
24 | - npm run test:e2e -- -e firefox
25 | finally:
26 | - cd $CODEBUILD_SRC_DIR
27 | # Cleanup commands end with "|| true" to ensure that all of them are executed. It's ok if they fail trying to delete a resource that was never created due to a build phase error.
28 | - WEBSITE_BUCKET=$(aws ssm get-parameter --name /applications/apprepo/$TEST_STAGE/s3/WebsiteBucket/Name --query Parameter.Value --output text) || true
29 | - aws s3 rm s3://$WEBSITE_BUCKET --recursive || true # S3 buckets must be emptied before being deleted
30 | - ./bin/delete-stack.sh -n $TEST_STAGE-website || true
31 | - ./bin/delete-stack.sh -n $TEST_STAGE-backend || true
--------------------------------------------------------------------------------
/static-website/buildspec.yaml:
--------------------------------------------------------------------------------
1 | version: 0.2
2 |
3 | phases:
4 | install:
5 | runtime-versions:
6 | nodejs: 8
7 | commands:
8 | - npm install -g @vue/cli
9 | build:
10 | commands:
11 | - ./static-website/bin/package-static-website.sh
12 | - ./bin/package.sh -n static-website
13 | artifacts:
14 | files:
15 | - static-website/target/sam/app/packaged-template.yaml
16 | discard-paths: yes
--------------------------------------------------------------------------------
/static-website/images/sign-in.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amazon-archives/realworld-serverless-application/effdb9643b778fa78280bfb5da9e6db371f5b09e/static-website/images/sign-in.png
--------------------------------------------------------------------------------
/static-website/nightwatch.conf.js:
--------------------------------------------------------------------------------
1 | const launchUrl = process.env.WEBSITE_URL || 'http://localhost:8080';
2 | module.exports = {
3 | src_folders: ['tests/e2e/specs'],
4 | output_folder: 'tests/e2e/reports',
5 | page_objects_path: 'tests/e2e/page-objects',
6 | test_settings: {
7 | default: {
8 | globals: {
9 | waitForConditionTimeout: 30000,
10 | },
11 | },
12 | chrome: {
13 | launch_url: launchUrl,
14 | webdriver: {
15 | start_process: true,
16 | server_path: './node_modules/.bin/chromedriver',
17 | port: 9515,
18 | },
19 | desiredCapabilities: {
20 | browserName: 'chrome',
21 | chromeOptions: {
22 | w3c: false,
23 | args: [
24 | 'headless',
25 | ],
26 | },
27 | },
28 | },
29 | firefox: {
30 | launch_url: launchUrl,
31 | webdriver: {
32 | start_process: true,
33 | server_path: './node_modules/.bin/geckodriver',
34 | cli_args: [
35 | '--log', 'debug',
36 | ],
37 | port: 4444,
38 | },
39 | desiredCapabilities: {
40 | alwaysMatch: {
41 | browserName: 'firefox',
42 | 'moz:firefoxOptions': {
43 | args: ['--headless'],
44 | },
45 | },
46 | },
47 | },
48 | },
49 | };
50 |
--------------------------------------------------------------------------------
/static-website/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "realworld-serverless-application-static-website",
3 | "version": "1.0.1",
4 | "private": true,
5 | "scripts": {
6 | "serve": "vue-cli-service serve",
7 | "build": "vue-cli-service build",
8 | "lint": "vue-cli-service lint",
9 | "test:e2e": "nightwatch",
10 | "test:unit": "vue-cli-service test:unit --include ./tests/setup.js",
11 | "ci": "npm run lint && npm run test:unit && npm run build"
12 | },
13 | "dependencies": {
14 | "@aws-amplify/auth": "^1.6.3",
15 | "@babel/polyfill": "^7.10.1",
16 | "aws-amplify": "^1.3.3",
17 | "aws-amplify-vue": "^0.2.17",
18 | "axios": "^0.21.1",
19 | "bootstrap": "^4.5.0",
20 | "bootstrap-vue": "^2.15.0",
21 | "core-js": "^2.6.11",
22 | "mutationobserver-shim": "^0.3.7",
23 | "vue": "^2.6.11",
24 | "vue-axios": "^2.1.5",
25 | "vue-router": "^3.3.4",
26 | "vuex": "^3.4.0"
27 | },
28 | "devDependencies": {
29 | "@vue/cli-plugin-babel": "^3.12.1",
30 | "@vue/cli-plugin-eslint": "^3.12.1",
31 | "@vue/cli-plugin-unit-mocha": "^4.5.4",
32 | "@vue/cli-service": "^4.5.12",
33 | "@vue/eslint-config-airbnb": "^4.0.0",
34 | "@vue/test-utils": "1.0.0-beta.29",
35 | "aws-sdk": "^2.698.0",
36 | "babel-eslint": "^10.1.0",
37 | "chai": "^4.1.2",
38 | "chromedriver": "^77.0.0",
39 | "eslint": "^5.16.0",
40 | "eslint-plugin-vue": "^5.0.0",
41 | "geckodriver": "^1.19.1",
42 | "nightwatch": "^1.3.6",
43 | "node-sass": "^4.14.1",
44 | "popper.js": "^1.16.1",
45 | "portal-vue": "^2.1.7",
46 | "sass-loader": "^7.1.0",
47 | "sinon": "^7.4.2",
48 | "sinon-chai": "^3.5.0",
49 | "uuid": "^3.4.0",
50 | "vue-cli-plugin-bootstrap-vue": "^0.4.0",
51 | "vue-template-compiler": "^2.6.11",
52 | "ssri": ">=8.0.1",
53 | "is-svg": ">=4.2.2",
54 | "netmask": ">=2.0.1"
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/static-website/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: {
3 | autoprefixer: {},
4 | },
5 | };
6 |
--------------------------------------------------------------------------------
/static-website/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amazon-archives/realworld-serverless-application/effdb9643b778fa78280bfb5da9e6db371f5b09e/static-website/public/favicon.ico
--------------------------------------------------------------------------------
/static-website/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | AWS Serverless Application Repository
9 |
10 |
11 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/static-website/src/App.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
18 |
--------------------------------------------------------------------------------
/static-website/src/assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/amazon-archives/realworld-serverless-application/effdb9643b778fa78280bfb5da9e6db371f5b09e/static-website/src/assets/logo.png
--------------------------------------------------------------------------------
/static-website/src/components/Breadcrumb.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
--------------------------------------------------------------------------------
/static-website/src/components/ErrorAlert.vue:
--------------------------------------------------------------------------------
1 |
2 | Error: {{ message }}
3 |
4 |
5 |
15 |
--------------------------------------------------------------------------------
/static-website/src/components/Nav.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 | Serverless Application Repository
4 |
5 | SignOut
6 |
7 |
8 | Sign In
9 |
10 |
11 |
12 |
13 |
33 |
--------------------------------------------------------------------------------
/static-website/src/config.js:
--------------------------------------------------------------------------------
1 | /* eslint no-template-curly-in-string: 0 */
2 |
3 | // This file vends configuration values that vary per stage, e.g., test, production.
4 | // The deployment system does string substitution on variables within ${} prior to
5 | // uploading the website to S3.
6 |
7 | export const SAR_API_ENDPOINT = '${SAR_BACKEND_ENDPOINT}';
8 |
9 | export const COGNITO_USER_POOL_DATA = {
10 | userPoolId: '${USER_POOL_ID}',
11 | userPoolWebClientId: '${USER_POOL_WEB_CLIENT_ID}',
12 | };
13 |
--------------------------------------------------------------------------------
/static-website/src/main.js:
--------------------------------------------------------------------------------
1 | import '@babel/polyfill';
2 | import 'mutationobserver-shim';
3 | import Vue from 'vue';
4 | import './plugins/bootstrap-vue';
5 | import Amplify, * as AmplifyModules from 'aws-amplify';
6 | import { AmplifyPlugin, AmplifyEventBus } from 'aws-amplify-vue';
7 | import App from './App.vue';
8 | import router from './router';
9 | import store from './store';
10 | import SarApi from './services/sar-api';
11 | import { IS_AUTHENTICATED, SIGNOUT } from './store/actions.type';
12 | import { COGNITO_USER_POOL_DATA } from './config';
13 |
14 | Vue.config.productionTip = false;
15 |
16 | SarApi.init();
17 |
18 | Amplify.configure({
19 | Auth: {
20 | ...COGNITO_USER_POOL_DATA,
21 | },
22 | });
23 |
24 | Vue.use(AmplifyPlugin, AmplifyModules);
25 |
26 | AmplifyEventBus.$on('authState', async (state) => {
27 | if (state === 'signedOut') {
28 | await store.dispatch(SIGNOUT);
29 | router.push({ name: 'home' });
30 | } else if (state === 'signedIn') {
31 | await store.dispatch(IS_AUTHENTICATED);
32 | router.push({ name: 'applications' });
33 | }
34 | });
35 |
36 | router.beforeEach((to, from, next) => {
37 | if (to.matched.some(route => route.meta && route.meta.checkAuth)) {
38 | store.dispatch(IS_AUTHENTICATED)
39 | .then(() => {
40 | const token = store.getters.jwtToken;
41 | if (!token) {
42 | return next({ name: 'signin' });
43 | }
44 | return next();
45 | })
46 | .catch(() => next({ name: 'signin' }));
47 | }
48 | return next();
49 | });
50 |
51 | new Vue({
52 | store,
53 | router,
54 | render: h => h(App),
55 | }).$mount('#app');
56 |
--------------------------------------------------------------------------------
/static-website/src/plugins/bootstrap-vue.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 |
3 | import BootstrapVue from 'bootstrap-vue';
4 | import 'bootstrap/dist/css/bootstrap.min.css';
5 | import 'bootstrap-vue/dist/bootstrap-vue.css';
6 |
7 | Vue.use(BootstrapVue);
8 |
--------------------------------------------------------------------------------
/static-website/src/router.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Router from 'vue-router';
3 | import Home from './views/Home.vue';
4 | import SignIn from './views/SignIn.vue';
5 | import Applications from './views/Applications.vue';
6 | import NewApplication from './views/NewApplication.vue';
7 | import ViewApplication from './views/ViewApplication.vue';
8 | import EditApplication from './views/EditApplication.vue';
9 |
10 | Vue.use(Router);
11 |
12 | export default new Router({
13 | routes: [
14 | {
15 | path: '/',
16 | name: 'home',
17 | component: Home,
18 | meta: {
19 | checkAuth: false,
20 | },
21 | },
22 | {
23 | path: '/signin',
24 | name: 'signin',
25 | component: SignIn,
26 | },
27 | {
28 | path: '/applications',
29 | name: 'applications',
30 | component: Applications,
31 | meta: {
32 | breadcrumb: [
33 | {
34 | text: 'My applications',
35 | active: true,
36 | },
37 | ],
38 | checkAuth: true,
39 | },
40 | },
41 | {
42 | path: '/applications/new',
43 | name: 'new-application',
44 | component: NewApplication,
45 | meta: {
46 | breadcrumb: [
47 | {
48 | text: 'My applications',
49 | to: { name: 'applications' },
50 | },
51 | {
52 | text: 'Publish an application',
53 | active: true,
54 | },
55 | ],
56 | checkAuth: true,
57 | },
58 | },
59 | {
60 | path: '/applications/:id',
61 | name: 'view-application',
62 | component: ViewApplication,
63 | meta: {
64 | breadcrumb: [
65 | {
66 | text: 'My applications',
67 | to: { name: 'applications' },
68 | },
69 | {
70 | text: 'Application details',
71 | active: true,
72 | },
73 | ],
74 | checkAuth: true,
75 | },
76 | },
77 | {
78 | path: '/applications/:id/edit',
79 | name: 'edit-application',
80 | component: EditApplication,
81 | meta: {
82 | breadcrumb: [
83 | {
84 | text: 'My applications',
85 | to: { name: 'applications' },
86 | },
87 | {
88 | text: 'Edit application',
89 | active: true,
90 | },
91 | ],
92 | checkAuth: true,
93 | },
94 | },
95 | ],
96 | });
97 |
--------------------------------------------------------------------------------
/static-website/src/services/sar-api.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import axios from 'axios';
3 | import VueAxios from 'vue-axios';
4 | import { SAR_API_ENDPOINT } from '../config';
5 |
6 | const SarApi = {
7 | init() {
8 | Vue.use(VueAxios, axios);
9 | Vue.axios.defaults.baseURL = SAR_API_ENDPOINT;
10 | },
11 | listApplications(jwtToken) {
12 | return Vue.axios.get('/applications', {
13 | headers: {
14 | Authorization: jwtToken,
15 | },
16 | })
17 | .then(response => response.data.applications);
18 | },
19 | createApplication(jwtToken, request) {
20 | return Vue.axios.post('/applications', {
21 | applicationId: request.applicationId,
22 | author: request.author,
23 | description: request.description,
24 | homePageUrl: request.homePageUrl,
25 | }, {
26 | headers: {
27 | Authorization: jwtToken,
28 | },
29 | })
30 | .then(response => response.data);
31 | },
32 | getApplication(jwtToken, applicationId) {
33 | return Vue.axios.get(`/applications/${applicationId}`, {
34 | headers: {
35 | Authorization: jwtToken,
36 | },
37 | }).then(response => response.data);
38 | },
39 | updateApplication(jwtToken, request) {
40 | return Vue.axios.patch(`/applications/${request.applicationId}`, {
41 | author: request.author,
42 | description: request.description,
43 | homePageUrl: request.homePageUrl,
44 | }, {
45 | headers: {
46 | Authorization: jwtToken,
47 | },
48 | })
49 | .then(response => response.data);
50 | },
51 | deleteApplication(jwtToken, applicationId) {
52 | return Vue.axios.delete(`/applications/${applicationId}`, {
53 | headers: {
54 | Authorization: jwtToken,
55 | },
56 | })
57 | .then(response => response.data);
58 | },
59 | };
60 |
61 | export default SarApi;
62 |
--------------------------------------------------------------------------------
/static-website/src/store/actions.type.js:
--------------------------------------------------------------------------------
1 | export const SIGNOUT = 'signout';
2 | export const IS_AUTHENTICATED = 'isAuthenticated';
3 | export const LIST_APPLICATIONS = 'listApplications';
4 | export const GET_APPLICATION = 'getApplication';
5 | export const CREATE_APPLICATION = 'createApplication';
6 | export const UPDATE_APPLICATION = 'updateApplication';
7 | export const DELETE_APPLICATION = 'deleteApplication';
8 |
--------------------------------------------------------------------------------
/static-website/src/store/auth.module.js:
--------------------------------------------------------------------------------
1 | /* eslint no-shadow: ["error", { "allow": ["state"] }] */
2 |
3 | import { AuthClass } from '@aws-amplify/auth';
4 | import {
5 | SIGNOUT, IS_AUTHENTICATED,
6 | } from './actions.type';
7 | import { SET_ERROR, SET_TOKEN } from './mutations.type';
8 | import { COGNITO_USER_POOL_DATA } from '../config';
9 |
10 |
11 | const Auth = new AuthClass(COGNITO_USER_POOL_DATA);
12 |
13 | const state = {
14 | error: null,
15 | jwtToken: null,
16 | };
17 |
18 | const getters = {
19 | jwtToken(state) {
20 | return state.jwtToken;
21 | },
22 | error(state) {
23 | return state.error;
24 | },
25 | };
26 |
27 | const actions = {
28 | [IS_AUTHENTICATED](context) {
29 | return new Promise((resolve, reject) => {
30 | Auth.currentSession()
31 | .then((user) => {
32 | if (user.isValid()) {
33 | context.commit(SET_TOKEN, user.getIdToken().getJwtToken());
34 | resolve();
35 | } else {
36 | reject();
37 | }
38 | })
39 | .catch((e) => {
40 | context.commit(SET_TOKEN, null);
41 | context.commit(SET_ERROR, e);
42 | reject(e);
43 | });
44 | });
45 | },
46 | [SIGNOUT](context) {
47 | return Auth.signOut().then(() => {
48 | context.commit(SET_TOKEN, null);
49 | context.commit(SET_ERROR, null);
50 | });
51 | },
52 | };
53 |
54 | const mutations = {
55 | [SET_ERROR](state, error) {
56 | state.error = error;
57 | },
58 | [SET_TOKEN](state, token) {
59 | state.jwtToken = token;
60 | },
61 | };
62 |
63 | export default {
64 | state,
65 | actions,
66 | mutations,
67 | getters,
68 | };
69 |
--------------------------------------------------------------------------------
/static-website/src/store/index.js:
--------------------------------------------------------------------------------
1 | import Vue from 'vue';
2 | import Vuex from 'vuex';
3 | import auth from './auth.module';
4 | import sar from './sar.module';
5 |
6 | Vue.use(Vuex);
7 |
8 | export default new Vuex.Store({
9 | modules: {
10 | auth,
11 | sar,
12 | },
13 | });
14 |
--------------------------------------------------------------------------------
/static-website/src/store/mutations.type.js:
--------------------------------------------------------------------------------
1 | export const SET_ERROR = 'setError';
2 | export const SET_TOKEN = 'setToken';
3 |
--------------------------------------------------------------------------------
/static-website/src/store/sar.module.js:
--------------------------------------------------------------------------------
1 | import {
2 | LIST_APPLICATIONS, GET_APPLICATION, CREATE_APPLICATION, UPDATE_APPLICATION,
3 | DELETE_APPLICATION,
4 | } from './actions.type';
5 | import SarApi from '../services/sar-api';
6 |
7 | const actions = {
8 | [LIST_APPLICATIONS](context) {
9 | return SarApi.listApplications(context.getters.jwtToken);
10 | },
11 | [GET_APPLICATION](context, applicationId) {
12 | return SarApi.getApplication(context.getters.jwtToken, applicationId);
13 | },
14 | [CREATE_APPLICATION](context, request) {
15 | return SarApi.createApplication(context.getters.jwtToken, request);
16 | },
17 | [UPDATE_APPLICATION](context, request) {
18 | return SarApi.updateApplication(context.getters.jwtToken, request);
19 | },
20 | [DELETE_APPLICATION](context, applicationId) {
21 | return SarApi.deleteApplication(context.getters.jwtToken, applicationId);
22 | },
23 | };
24 |
25 | export default {
26 | actions,
27 | };
28 |
--------------------------------------------------------------------------------
/static-website/src/views/Home.vue:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 | This is a cover page for the front end module of the awslabs/realworld-serverless-application project. See more details here.
9 |
10 | Try the Demo
11 |
12 | View Source Code
13 |
14 |
15 |
16 |
22 |
--------------------------------------------------------------------------------
/static-website/src/views/SignIn.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
42 |
--------------------------------------------------------------------------------
/static-website/tests/e2e/custom-assertions/elementCount.js:
--------------------------------------------------------------------------------
1 | // A custom Nightwatch assertion.
2 | // The assertion name is the filename.
3 | // Example usage:
4 | //
5 | // browser.assert.elementCount(selector, count)
6 | //
7 | // For more information on custom assertions see:
8 | // http://nightwatchjs.org/guide#writing-custom-assertions
9 |
10 | exports.assertion = function elementCount(selector, count) {
11 | this.message = `Testing if element <${selector}> has count: ${count}`;
12 | this.expected = count;
13 | this.pass = val => val === count;
14 | this.value = res => res.value;
15 | function evaluator(_selector) {
16 | return document.querySelectorAll(_selector).length;
17 | }
18 | this.command = cb => this.api.execute(evaluator, [selector], cb);
19 | };
20 |
--------------------------------------------------------------------------------
/static-website/tests/e2e/page-objects/appDetails.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | elements: {
3 | deleteBtn: '#delete',
4 | editBtn: '#edit',
5 | deleteModal: '#delete-modal',
6 | confirmDeleteBtn: '#delete-modal footer button.btn-primary',
7 | details: '.card-body .card-body',
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/static-website/tests/e2e/page-objects/editApp.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | elements: {
3 | authorInput: '#author',
4 | homePageUrlInput: '#homepage-url',
5 | descriptionInput: '#description',
6 | saveBtn: 'button[type=Submit]',
7 | error: '#error-alert',
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/static-website/tests/e2e/page-objects/myApps.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | elements: {
3 | publishAppBtn: 'a.btn',
4 | appsTable: 'table',
5 | appsTableRows: 'table tbody tr',
6 | },
7 | };
8 |
--------------------------------------------------------------------------------
/static-website/tests/e2e/page-objects/publishApp.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | elements: {
3 | appNameInput: '#application-id',
4 | authorInput: '#author',
5 | homePageUrlInput: '#homepage-url',
6 | descriptionInput: '#description',
7 | publishBtn: 'button[type=Submit]',
8 | error: '#error-alert',
9 | },
10 | };
11 |
--------------------------------------------------------------------------------
/static-website/tests/e2e/page-objects/signIn.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | elements: {
3 | usernameInput: 'input[data-test=email-input]',
4 | passwordInput: 'input[data-test=sign-in-password-input]',
5 | signInBtn: 'button[data-test=sign-in-sign-in-button]',
6 | createAccount: '[data-test=sign-in-create-account-link]',
7 | createAccountEmailInput: 'div[signupfield=email] input',
8 | createAccountPasswordInput: 'div[signupfield=password] input',
9 | createAccountBtn: 'button[data-test=sign-up-create-account-button]',
10 | confirmationCodeInput: '[data-test="confirm-sign-up-confirmation-code-input"]',
11 | },
12 | };
13 |
--------------------------------------------------------------------------------
/static-website/tests/e2e/page-objects/welcome.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | elements: {
3 | signInBtn: 'nav .nav-link:nth-child(1)',
4 | tryDemoBtn: '#try-demo',
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/static-website/tests/e2e/utils/cognitoAdmin.js:
--------------------------------------------------------------------------------
1 | const AWS = require('aws-sdk');
2 | const uuid = require('uuid');
3 |
4 | const USER_POOL_ID = process.env.COGNITO_USER_POOL_ID;
5 | const cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({ region: 'us-east-1' });
6 |
7 | const createTestUser = async () => {
8 | const username = `success+${uuid.v4()}@simulator.amazonses.com`;
9 | const password = uuid.v4();
10 |
11 | await cognitoidentityserviceprovider.adminCreateUser({
12 | UserPoolId: USER_POOL_ID,
13 | Username: username,
14 | }).promise();
15 |
16 | await cognitoidentityserviceprovider.adminSetUserPassword({
17 | Password: password,
18 | UserPoolId: USER_POOL_ID,
19 | Username: username,
20 | Permanent: true,
21 | }).promise();
22 | return { username, password };
23 | };
24 |
25 | module.exports = {
26 | createTestUser,
27 | };
28 |
--------------------------------------------------------------------------------
/static-website/tests/setup.js:
--------------------------------------------------------------------------------
1 | /* eslint no-undef: 0 */
2 |
3 | // common mocha setup
4 |
5 | import chai from 'chai';
6 | import sinon from 'sinon';
7 | import sinonChai from 'sinon-chai';
8 |
9 | // support sinon-chai assertions
10 | chai.use(sinonChai);
11 |
12 | afterEach(() => {
13 | sinon.restore();
14 | });
15 |
--------------------------------------------------------------------------------
/static-website/tests/unit/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | env: {
3 | mocha: true,
4 | },
5 | };
6 |
--------------------------------------------------------------------------------
/static-website/tests/unit/components/Nav.spec.js:
--------------------------------------------------------------------------------
1 | /* eslint no-unused-expressions: 0 */
2 |
3 | import Vuex from 'vuex';
4 | import { expect } from 'chai';
5 | import sinon from 'sinon';
6 | import { mount, createLocalVue } from '@vue/test-utils';
7 | import BootstrapVue from 'bootstrap-vue';
8 | import Nav from '@/components/Nav.vue';
9 |
10 | const localVue = createLocalVue();
11 | localVue.use(BootstrapVue);
12 | localVue.use(Vuex);
13 |
14 | describe('Nav.vue', () => {
15 | describe('when a user is signed in', () => {
16 | let getters;
17 | let actions;
18 | let store;
19 |
20 | beforeEach(() => {
21 | actions = {
22 | signout: sinon.fake(),
23 | };
24 | getters = {
25 | jwtToken: () => sinon.match.any,
26 | error: sinon.fake(),
27 | };
28 | store = new Vuex.Store({
29 | modules: {
30 | auth: {
31 | actions,
32 | getters,
33 | },
34 | },
35 | });
36 | });
37 | it('renders with a SignOut button', () => {
38 | const wrapper = mount(Nav, {
39 | store,
40 | localVue,
41 | });
42 | expect(wrapper.contains('#signout')).to.equal(true);
43 | });
44 |
45 | it('dispatches SignOut action when button clicked', () => {
46 | const wrapper = mount(Nav, {
47 | store,
48 | localVue,
49 | });
50 | expect(wrapper.contains('#signout')).to.equal(true);
51 | wrapper.find('#signout a').trigger('click');
52 | expect(actions.signout).to.have.been.called;
53 | });
54 | });
55 |
56 | describe('when a user is not signed in', () => {
57 | it('renders without a SignOut button', () => {
58 | const getters = {
59 | jwtToken: () => null,
60 | error: sinon.fake(),
61 | };
62 | const store = new Vuex.Store({
63 | modules: {
64 | auth: {
65 | getters,
66 | },
67 | },
68 | });
69 | const wrapper = mount(Nav, {
70 | store,
71 | localVue,
72 | });
73 | expect(wrapper.contains('#signout')).to.equal(false);
74 | expect(wrapper.contains('#signin')).to.equal(true);
75 | });
76 | });
77 | });
78 |
--------------------------------------------------------------------------------
/static-website/tests/unit/views/Home.spec.js:
--------------------------------------------------------------------------------
1 | /* eslint no-unused-expressions: 0 */
2 |
3 | import { expect } from 'chai';
4 | import { mount, createLocalVue } from '@vue/test-utils';
5 | import BootstrapVue from 'bootstrap-vue';
6 | import Home from '@/views/Home.vue';
7 |
8 | // render bootstrap components
9 | const localVue = createLocalVue();
10 | localVue.use(BootstrapVue);
11 |
12 | describe('Home.vue', () => {
13 | it('renders', () => {
14 | const wrapper = mount(Home, {
15 | localVue,
16 | propsData: {},
17 | });
18 | expect(wrapper.text()).to.include('Welcome!');
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/static-website/vue.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | css: {
3 | sourceMap: true,
4 | },
5 | };
6 |
--------------------------------------------------------------------------------