# Build an end-to-end application source: https://developer.mastercard.com/track-search/documentation/tutorials-and-guides/build-an-end-to-end-application-tutorial/index.md ## Overview {#overview} This tutorial walks you through the steps to create a simple Java application that makes an API call to the Search API in the Sandbox environment. > > #### What you will learn {#what-you-will-learn} > * How to set up the environment to develop a simple Java application * How to generate an API client using the OpenAPI Generator * How to make an API call ## Technologies used {#technologies-used} * [JDK 8](https://www.java.com/en/) or later * Any IDE of your choice. ## Before you start {#before-you-start} Before starting this tutorial, ensure that you have already completed the following: * Created your project and retrieved the required credentials. * Obtained the [Track Search open API specification](https://developer.mastercard.com/track-search/documentation/api-reference/index.md).
APIs used in this tutorial: * Search [View Documentation](https://developer.mastercard.com/track-search/documentation/index.md) ## What you will achieve {#what-you-will-achieve} At the end of this tutorial, you will successfully complete the payment cancellation process in CDP. ## Next steps {#next-steps} Click **Next** to get started. ## Create a Maven Project {#create-a-maven-project} * Create a Maven project using [Spring Initializr](https://start.spring.io/) which sets your directory structure automatically. * Select the appropriate option for each of the following fields: * Project * Language * Spring Boot * complete the required metadata for the information provided below.: * Group * ArtifactId * Name * Description * Package name * Packaging * Java version ## Add Resources {#add-resources} To add resources: * Add the Search Open API specification to your Maven project resources folder. * Add the generated Sandbox key (.p12 file) to your Maven project resources folder. The .p12 file is generated while creating your project on Mastercard Developers. Your Maven project directory structure should appear as shown in the below screen shot: ![Maven-resources](https://static.developer.mastercard.com/content/track-search/uploads/maven-resources-updated.png) ## Update pom.xml file {#update-pomxml-file} To update pom.xml file: * In your IDE, add the [OpenAPI Generator maven plugin](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-maven-plugin) to your project pom.xml file using the below Plugin configurations: ```java org.openapitools openapi-generator-maven-plugin 5.2.1 generate ${project.basedir}/src/main/resources/track-search.yaml java okhttp-gson false false false src/gen/java/main com.mastercard.developer track-search-client com.mastercard.developer.track-search-reference-application com.mastercard.developer.track-search-reference-application.api com.mastercard.developer.track-search-reference-application.model java8 true ``` Note: The [OpenAPI Generator](https://openapi-generator.tech/) generates API client libraries using OpenAPI Specification. It provides multiple generators and library templates to support multiple languages and frameworks. We will be using the java generator for this project. * Add the following dependencies to your pom.xml file: ```java 1.8 ${java.version} ${java.version} UTF-8 com.mastercard.developer oauth1-signer 1.5.1 org.openapitools openapi-generator-cli 5.2.1 provided com.squareup.okhttp3 okhttp 4.9.1 com.squareup.okhttp3 logging-interceptor 4.9.1 com.google.code.gson gson 2.8.8 io.gsonfire gson-fire 1.8.3 javax.annotation javax.annotation.api 1.3.1 organisationIdentifications = new ArrayList<>(); OrganisationIdentification organisationIdentification = new OrganisationIdentification(); organisationIdentification.setIdentification("12345789"); organisationIdentification.setType("TXID"); organisationIdentifications.add(organisationIdentification); BusinessAddress businessAddress = new BusinessAddress(); businessAddress.setAddressLine1("10 Main St, Apt 3"); businessAddress.setCountry("USA"); businessAddress.setCountrySubDivision("NY"); businessAddress.setPostCode("10577"); businessAddress.setTownName("Fairfax"); SearchRequestEntity searchRequestEntity = new SearchRequestEntity(); searchRequestEntity.setSearchRequestId("434534"); searchRequestEntity.setBusinessName("Starbucks"); searchRequestEntity.setPhoneNumber("9175763488"); searchRequestEntity.setEmailAddress(info@starbucks.com); searchRequestEntity.setCurrency("USD"); searchRequestEntity.setPaymentMethod("CARD"); searchRequestEntity.setPaymentTerms("Net 30"); searchRequestEntity.setAnnualInvoiceCount("100"); searchRequestEntity.setAnnualTransactionAmount("100000"); searchRequestEntity.setAnnualNumberOfTransactions("100"); searchRequestEntity.setBusinessAddress(businessAddress); searchRequestEntity.setOrganisationIdentifications(organisationIdentifications); List requestEntityList = new ArrayList<>(); requestEntityList.add(searchRequestEntity); List requesterOrganisationIdentifications = new ArrayList<>(); OrganisationIdentification requesterOrganisationIdentification = new OrganisationIdentification(); requesterOrganisationIdentification.setIdentification("52345785"); requesterOrganisationIdentification.setType("TXID"); requesterOrganisationIdentifications.add(requesterOrganisationIdentification); RequestingBusinessAddress requestingBusinessAddress = new RequestingBusinessAddress(); requestingBusinessAddress.setAddressLine1("25 Main St, Apt 3"); requestingBusinessAddress.setCountry("USA"); requestingBusinessAddress.setCountrySubDivision("VA"); requestingBusinessAddress.setPostCode("10577"); requestingBusinessAddress.setTownName("Fairfax"); RequesterInformation requesterInformation = new RequesterInformation(); requesterInformation.setOrganisationIdentifications(requesterOrganisationIdentifications); requesterInformation.setBusinessAddress(requestingBusinessAddress); return getNewBulkSearch(requestEntityList, requesterInformation); } static NewBulkSearch getNewBulkSearch(List requestEntityList, RequesterInformation requesterInformation) { requesterInformation.setBpsProfileId(bestbuy.pay@track); requesterInformation.setEmailAddress(info@bestbuy.com); requesterInformation.setPhoneNumber("9175763489"); NewBulkSearch newBulkSearch = new NewBulkSearch(); newBulkSearch.setLookupType("BUYERS"); newBulkSearch.setMaximumMatches(1); newBulkSearch.setMinimumConfidenceThreshold("0.6"); newBulkSearch.setSearches(requestEntityList); newBulkSearch.setRequestingEntity(requesterInformation); return newBulkSearch; } } ```