* Archietecture Diagram added * Added pom.xml * Architecture Diagram Updated * Added Microservices and kafka * ReadME File Added * ReadME file Updated * #1329 ReadMe file updated and working pattern code added * #1329 readme file updated * #1329 readme file updated and java documentation added * #1329 repository merged * Update claim-check-pattern/ReadME.md #1329 Real world description updated Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/ReadME.md Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Applicability section in ReadMe file updated Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Tutorial section in ReadMe file updated Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Storage Data section in ReadMe File updated Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 workflow section Update claim-check-pattern/ReadME.md Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/pom.xml Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 deleted mvnw.cmd file * #1329 deleted drawio file * #1329 deleted mvnw file * #1329 deleted mvnw file * #1329 mvnw.cmd file deleted * #1329 Update claim-check-pattern/usage-cost-processor/src/main/java/com/callusage/domain/MessageHeader.java Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/usage-cost-processor/src/main/java/com/callusage/domain/UsageCostDetail.java Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/usage-cost-processor/src/main/java/com/callusage/domain/UsageDetail.java Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 deleted mvnw file * #1329 deleted mvnw.cmd file * #1329 Update claim-check-pattern/usage-detail-sender/src/main/java/com/callusage/domain/Message.java Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 Update claim-check-pattern/ReadME.md Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> * #1329 pom file dependencies fixed, readmeflie updated, removed unused imports * #1329 Readfile updated, class javadoc added * #1329 UML class diagrams added, readme file updated * #1329 lombok annotations used on model classes, common dependencies moved to parent pom * #1329 test cases added * include claim-check-pattern in parent pom * #1329 code smells fixed * #1329 code smells removed * #1329 security issues fixed * #1329 updated pom files and refactored packages name * #1329 checkstyle warning fixed * #1329 code coverage increased * #1329 minor changed. * checkpoint created with common utility * Claim-Check-Pattern | Shrirang97 | Implemented using Java Azure Functions * Claim-Check-Pattern | Shrirang97 | Updated Functions logic * Update MessageHandlerUtility.java * Update UsageCostProcessorFunction.java * claim-check-pattern | Shrirang97 | Added test cases * claim-check-pattern | Shrirang97 | Test cases for Azure functions fixed * Claim-Check-Pattern | Shrirang | Used string as request body * claim-check-pattern | Shrirang | Working test cases * claim-check-pattern | Shrirang | Issue fixed while deserializing * claim-check-pattern | Shrirang | removed unused import * claim-check-pattern | Shrirang | fixed refactoring * claim-chek-pattern | Shrirang | added lombok | fixed dependencies & test cases * Delete .DS_Store * claim-check-pattern | Shrirang | Fixed unrelated file * Update BookService.java * Update BookService.java * claim-check-pattern | Shrirang | Fixed unrelated files * claim-check-pattern | Shrirang | Fixed review comments * Update UsageCostProcessorFunction.java * Update ReadME.md * Rename ReadME.md to README.md * claim-check-pattern | Shrirang | Incorporated review comments. * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Update cloud-claim-check-pattern/README.md Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com> * Updated readme file * Read me file updated | Added more description Co-authored-by: Subhrodip Mohanta <subhrodipmohanta@gmail.com> Co-authored-by: Subhrodip Mohanta <hello@subho.xyz> Co-authored-by: Ilkka Seppälä <iluwatar@users.noreply.github.com>
106 lines
3.4 KiB
Java
106 lines
3.4 KiB
Java
/*
|
|
* The MIT License
|
|
* Copyright © 2014-2021 Ilkka Seppälä
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
|
|
package com.iluwatar.claimcheckpattern;
|
|
|
|
import com.microsoft.azure.functions.HttpResponseMessage;
|
|
import com.microsoft.azure.functions.HttpStatus;
|
|
import com.microsoft.azure.functions.HttpStatusType;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/**
|
|
* The mock for HttpResponseMessage, can be used in unit tests to verify if the
|
|
* returned response by HTTP trigger function is correct or not.
|
|
*/
|
|
public class HttpResponseMessageMock implements HttpResponseMessage {
|
|
private int httpStatusCode;
|
|
private HttpStatusType httpStatus;
|
|
private Object body;
|
|
private Map<String, String> headers;
|
|
|
|
public HttpResponseMessageMock(HttpStatusType status, Map<String, String> headers, Object body) {
|
|
this.httpStatus = status;
|
|
this.httpStatusCode = status.value();
|
|
this.headers = headers;
|
|
this.body = body;
|
|
}
|
|
|
|
@Override
|
|
public HttpStatusType getStatus() {
|
|
return this.httpStatus;
|
|
}
|
|
|
|
@Override
|
|
public int getStatusCode() {
|
|
return httpStatusCode;
|
|
}
|
|
|
|
@Override
|
|
public String getHeader(String key) {
|
|
return this.headers.get(key);
|
|
}
|
|
|
|
@Override
|
|
public Object getBody() {
|
|
return this.body;
|
|
}
|
|
|
|
public static class HttpResponseMessageBuilderMock implements HttpResponseMessage.Builder {
|
|
private Object body;
|
|
private int httpStatusCode;
|
|
private Map<String, String> headers = new HashMap<>();
|
|
private HttpStatusType httpStatus;
|
|
|
|
public Builder status(HttpStatus status) {
|
|
this.httpStatusCode = status.value();
|
|
this.httpStatus = status;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public Builder status(HttpStatusType httpStatusType) {
|
|
this.httpStatusCode = httpStatusType.value();
|
|
this.httpStatus = httpStatusType;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public HttpResponseMessage.Builder header(String key, String value) {
|
|
this.headers.put(key, value);
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public HttpResponseMessage.Builder body(Object body) {
|
|
this.body = body;
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public HttpResponseMessage build() {
|
|
return new HttpResponseMessageMock(this.httpStatus, this.headers, this.body);
|
|
}
|
|
}
|
|
}
|