Skip to content

Commit 66fe2c9

Browse files
authored
Merge pull request #11 from Mastercard/feature/documentation-updates
Various Updates
2 parents e07d01e + c65122e commit 66fe2c9

22 files changed

+540
-691
lines changed

CONTRIBUTING.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Contributing
2+
3+
## Submitting Changes
4+
1. Fork the repository
5+
2. Create your feature branch (git checkout -b my-new-feature)
6+
3. Commit your changes (git commit -am 'Add some feature')
7+
4. Execute the unit tests to ensure all pass
8+
5. Squash your commits (git rebase --interactive --autosquash)
9+
6. Push the branch (git push origin my-new-feature)
10+
7. Create a new Pull Request
11+
12+
### Pull request Approval
13+
14+
Internal developers will verify the changes and approve the request or leave comments for improvements.
15+
16+
### Quality Expectations
17+
Please ensure any contributions include unit tests. The project maintains a high level of test coverage for its functionality.
18+
Submissions are expected to maintain a similar level of coverage.
19+
20+
## Code of Conduct
21+
22+
Examples of behavior that contributes to creating a positive environment
23+
include:
24+
25+
* Using welcoming and inclusive language
26+
* Being respectful of differing viewpoints and experiences
27+
* Gracefully accepting constructive criticism
28+
* Focusing on what is best for the community
29+
* Showing empathy towards other community members
30+
31+
Examples of unacceptable behavior by participants include:
32+
33+
* Trolling, insulting/derogatory comments, and personal or political attacks
34+
* Public or private harassment
35+
* Publishing others' private information, such as a physical or electronic
36+
address, without explicit permission
37+
* Other conduct which could reasonably be considered inappropriate in a
38+
professional setting
39+
40+
## How to engage Maintainers
41+
Leaving Issues using the issue tracker in GitHub.
42+
Maintainers will look for issues posted to the repository and will resolve the issue as soon as possible.
43+
44+
**Copyright © 1994-2024, All Rights Reserved by Mastercard.**

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2024 Mastercard
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ Please follow the instruction below to begin
2222
mvn clean install
2323
```
2424

25-
This will generate all required files as defined in [petstore.yaml](src/main/resources/petstore.yaml). They should be built into the target folder.
25+
This will generate all required files as defined in [petstore.yaml](src/main/resources/petstore.yaml) using the [OpenAPI Generator](https://openapi-generator.tech/) plugin. They should be built into the target folder.
2626

2727
## Getting Started
2828

2929
Set properties in [application.properties](src/main/resources/application.properties)
3030

31-
The authentication mode (MTLS or OAuth1.0a) must be set using
31+
The authentication mode (mTLS or OAuth1.0a) must be set using
3232
```
3333
-Dspring.profiles.active=oauth
3434
-Dspring.profiles.active=mtls
@@ -40,7 +40,7 @@ mastercard.oauth.consumerKey
4040
mastercard.oauth.keyAlias
4141
mastercard.oauth.keyPassword
4242
```
43-
If using the API in MTLS mode the following are required in [application-mtls.properties](src/main/resources/application-mtls.properties)
43+
If using the API in mTLS mode the following are required in [application-mtls.properties](src/main/resources/application-mtls.properties)
4444
```
4545
mastercard.mtls.pfxKeyFile
4646
mastercard.mtls.keyPassword

pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
<plugin>
115115
<groupId>org.openapitools</groupId>
116116
<artifactId>openapi-generator-maven-plugin</artifactId>
117-
<version>7.5.0</version>
117+
<version>7.9.0</version>
118118
<executions>
119119
<execution>
120120
<id>Petstore REST Client</id>
@@ -124,12 +124,14 @@
124124
<configuration>
125125
<inputSpec>${project.basedir}/src/main/resources/petstore.yaml</inputSpec>
126126
<generatorName>java</generatorName>
127-
<library>okhttp-gson</library>
128127
<configurationFile>${project.basedir}/src/main/resources/openapi-config.json</configurationFile>
129128
<generateApiTests>false</generateApiTests>
130129
<generateModelTests>false</generateModelTests>
131130
<configOptions>
132131
<sourceFolder>src/gen/java/main</sourceFolder>
132+
<library>okhttp-gson</library>
133+
<serializationLibrary>jackson</serializationLibrary>
134+
<failOnUnknownProperties>false</failOnUnknownProperties>
133135
</configOptions>
134136
</configuration>
135137
</execution>

src/main/java/com/mastercard/app/petstore/PetstoreApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class PetstoreApplication {
2222
EmployeeFlowExample employeeFlowExample;
2323

2424
@Bean
25-
PetFlowExample petFlowExample() throws ApiException {
25+
PetFlowExample petFlowExample() {
2626
petFlowExample = new PetFlowExample();
2727
return petFlowExample;
2828
}

src/main/java/com/mastercard/app/petstore/configuration/Configuration.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
public class Configuration {
1515

1616
@Bean
17-
public AdoptionsApi adoptionsApiFle(ApiClient apiClientEncryption) throws Exception {
18-
return new AdoptionsApi(apiClientEncryption);
17+
public AdoptionsApi adoptionsApiFle(ApiClient apiClientEncryptionAdoptionFle) {
18+
return new AdoptionsApi(apiClientEncryptionAdoptionFle);
1919
}
2020

2121
@Bean
22-
public AdoptionsApi adoptionsApiFullBody(ApiClient apiClientEncryption) throws Exception {
22+
public AdoptionsApi adoptionsApiFullBody(ApiClient apiClientEncryption) {
2323
return new AdoptionsApi(apiClientEncryption);
2424
}
2525

@@ -44,14 +44,12 @@ public EmployeesApi employeesApi(ApiClient apiClient) {
4444
}
4545

4646
@Bean
47-
public EmployeesApi employeesApiEncryptedForFLE(ApiClient apiClientEncryption) {
48-
return new EmployeesApi(apiClientEncryption);
47+
public EmployeesApi employeesApiEncryptedForFLE(ApiClient apiClientEncryptionEmployeeFle) {
48+
return new EmployeesApi(apiClientEncryptionEmployeeFle);
4949
}
5050

5151
@Bean
5252
public EmployeesApi employeesApiEncryptedForBody(ApiClient apiClientEncryption) {
5353
return new EmployeesApi(apiClientEncryption);
5454
}
55-
56-
5755
}

src/main/java/com/mastercard/app/petstore/examples/AdoptionFlowExample.java

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package com.mastercard.app.petstore.examples;
22

33
import com.mastercard.app.petstore.services.AdoptionsService;
4+
import com.mastercard.app.petstore.services.CatService;
45
import com.mastercard.app.petstore.utils.MockDataBuilders;
56
import org.openapitools.client.ApiException;
67
import org.openapitools.client.model.Adoption;
7-
import org.openapitools.client.model.AdoptionWrapper;
8+
import org.openapitools.client.model.AdoptionSearch;
9+
import org.openapitools.client.model.Cat;
810
import org.openapitools.client.model.NewAdoption;
11+
import org.openapitools.client.model.NewCat;
12+
import org.openapitools.client.model.PetStatus;
913
import org.springframework.beans.factory.annotation.Autowired;
10-
import org.springframework.beans.factory.annotation.Value;
1114
import org.springframework.context.annotation.ComponentScan;
12-
import org.springframework.core.env.Environment;
1315
import org.springframework.stereotype.Component;
1416

17+
import java.util.Date;
18+
1519
/**
1620
* The type Adoption flow example.
1721
*/
@@ -20,37 +24,31 @@
2024
@Component("AdoptionFLowExample")
2125
public class AdoptionFlowExample {
2226

23-
/**
24-
* The Base path. Set in application.properties
25-
*/
26-
@Value("${mastercard.basePath}")
27-
String basePath;
28-
29-
private Environment environment;
30-
3127
@Autowired
3228
private AdoptionsService adoptionsService;
29+
@Autowired
30+
private CatService catService;
3331

3432
/**
3533
* Adoption use case. Shows a typical adding an adoption, adopting pet, updating status and then removing it
3634
*
37-
* @throws ApiException the api exception
35+
* @throws ApiException thrown whenever there is an issue sending a request
3836
*/
3937
public void adoptionUseCase() throws ApiException {
38+
//Add cat
39+
NewCat newCat = MockDataBuilders.buildNewCat();
40+
Cat cat = catService.addCat(newCat);
4041

41-
//Skipping test if applications.properties isn't set
42-
if(basePath == null){
43-
return;
44-
}
4542
//Create adoption
46-
NewAdoption newAdoption = MockDataBuilders.buildNewAdoptionObject();
47-
adoptionsService.adoptPet(newAdoption);
43+
NewAdoption newAdoption = MockDataBuilders.buildNewAdoptionObject(cat.getId());
44+
String location = adoptionsService.adoptPet(newAdoption);
45+
String adoptionId = location.substring(location.lastIndexOf('/') + 1).trim();
4846

4947
//Get Adoption
50-
Adoption adoption = adoptionsService.getAdoption(newAdoption.getPetId().toString());
48+
Adoption adoption = adoptionsService.getAdoption(adoptionId);
5149

5250
//Update Adoption
53-
AdoptionWrapper adoptionWrapper = adoptionsService.updateAdoption("1", adoption);
51+
adoptionsService.updateAdoption("0", adoption);
5452

5553
//Remove Adoption
5654
adoptionsService.deleteAdoption(adoption.getId().toString());

src/main/java/com/mastercard/app/petstore/examples/EmployeeFlowExample.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import org.openapitools.client.ApiException;
66
import org.openapitools.client.model.*;
77
import org.springframework.beans.factory.annotation.Autowired;
8-
import org.springframework.beans.factory.annotation.Value;
98
import org.springframework.context.annotation.ComponentScan;
109
import org.springframework.stereotype.Component;
1110

@@ -17,25 +16,15 @@
1716
@Component("EmployeeFlowExample")
1817
public class EmployeeFlowExample {
1918

20-
/**
21-
* The Base path. Set in application.properties
22-
*/
23-
@Value("${mastercard.basePath}")
24-
String basePath;
25-
2619
@Autowired
2720
private EmployeeService employeeService;
2821

2922
/**
3023
* Employee use case. Show add a new employee, searching for their information, then removing them.
3124
*
32-
* @throws ApiException the api exception
25+
* @throws ApiException thrown whenever there is an issue sending a request
3326
*/
3427
public void employeeUseCase() throws ApiException {
35-
//Skipping test if applications.properties isn't set
36-
if(basePath == null){
37-
return;
38-
}
3928
//Add employee
4029
NewEmployee newEmployee = MockDataBuilders.buildNewEmployee();
4130
NewEmployeeData newEmployeeData = new NewEmployeeData().addNewEmployeesItem(newEmployee);
@@ -47,6 +36,7 @@ public void employeeUseCase() throws ApiException {
4736
EmployeeWrapper employeeWrapper = employeeService.searchEmployee(employeeSearch);
4837

4938
//Remove employee
50-
employeeService.deleteEmployee(employee.getId().toString());
39+
employeeService.deleteEmployee(employeeWrapper.getUsername());
5140
}
41+
5242
}

src/main/java/com/mastercard/app/petstore/examples/PetFlowExample.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,13 @@
88
import org.openapitools.client.model.NewCat;
99
import org.openapitools.client.model.PetStatus;
1010
import org.springframework.beans.factory.annotation.Autowired;
11-
import org.springframework.beans.factory.annotation.Value;
1211
import org.springframework.context.annotation.ComponentScan;
1312
import org.springframework.stereotype.Component;
1413

1514
@ComponentScan(basePackages = {"com.mastercard.app.petstore.utils"})
1615
@Component("PetFlowExample")
1716
public class PetFlowExample {
1817

19-
/**
20-
* The Base path.
21-
*/
22-
@Value("${mastercard.basePath}")
23-
String basePath;
24-
2518
@Autowired
2619
private CatService catService;
2720
@Autowired
@@ -30,14 +23,18 @@ public class PetFlowExample {
3023
/**
3124
* Pet use case flow. Shows creating a cat, updating their status and then removing them
3225
*
33-
* @throws ApiException the api exception
26+
* @throws ApiException thrown whenever there is an issue sending a request
3427
*/
35-
public void petUseCaseFlow () throws ApiException {
28+
public void petUseCaseFlow() throws ApiException {
3629
//Add pet
3730
NewCat newCat = MockDataBuilders.buildNewCat();
3831
Cat cat = catService.addCat(newCat);
3932
cat = catService.getCat(cat.getId().toString());
4033

34+
//Update cats name
35+
cat.setName("Catso");
36+
catService.updateCat(cat, "0");
37+
4138
//Set pet status
4239
PetStatus status = new PetStatus().value("RESERVED");
4340
petService.updatePetStatus(cat.getId(), status, "1");

0 commit comments

Comments
 (0)