org.hl7.fhir.utilities.tests.CacheVerificationLogger Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.hl7.fhir.utilities Show documentation
Show all versions of org.hl7.fhir.utilities Show documentation
Builds the hapi fhir utilities. Requires the hapi-fhir-base be built first and be excluded
from any other poms requiring it.
The newest version!
package org.hl7.fhir.utilities.tests;
import java.nio.charset.StandardCharsets;
import java.util.List;
import org.hl7.fhir.utilities.ToolingClientLogger;
import lombok.Getter;
public class CacheVerificationLogger implements ToolingClientLogger {
@Getter
int requests = 0;
@Override
public void logRequest(String method, String url, List headers, byte[] body) {
if (!TestConfig.getInstance().isRebuildCache()) {
System.err.println("Unexpected request to server");
System.err.println(method);
System.err.println(url);
if (headers != null) {
for (String header : headers) {
System.err.println("Header: " + header);
}
}
if (body != null) {
System.err.println("Body");
System.err.println("----");
System.err.println(new String(body, StandardCharsets.UTF_8));
}
}
requests++;
}
@Override
public void logResponse(String outcome, List headers, byte[] body) {
}
@Override
public String getLastId() {
return null;
}
@Override
public void clearLastId() {
}
public boolean verifyHasNoRequests() {
if (TestConfig.getInstance().isRebuildCache()) {
return true;
} else {
if (requests != 0) {
System.err.println(requests + " unexpected TX server requests logged. If a new test has been added, you may need to " +
"rebuild the TX Cache for the test using the 'mvn test -D" + TestConfig.FHIR_TXCACHE_REBUILD + "=true' option");
return false;
} else {
return true;
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy