Skip to content

Commit fd95b33

Browse files
committed
chore: use constant
1 parent e619136 commit fd95b33

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/main/java/io/github/guacsec/trustifyda/impl/ExhortApi.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public final class ExhortApi implements Api {
8080
public static final String TRUST_DA_SOURCE_HEADER = "trust-da-source";
8181
public static final String TRUST_DA_OPERATION_TYPE_HEADER = "trust-da-operation-type";
8282
public static final String TRUSTIFY_DA_REQUEST_ID_HEADER_NAME = "ex-request-id";
83+
public static final String S_API_V_5_ANALYSIS = "%s/api/v5/analysis";
84+
public static final String S_API_V_5_BATCH_ANALYSIS = "%s/api/v5/batch-analysis";
8385

8486
private final String endpoint;
8587

@@ -379,7 +381,7 @@ public CompletableFuture<AnalysisReport> componentAnalysis(
379381
String exClientTraceId = commonHookBeginning(false);
380382
var manifestPath = Path.of(manifest);
381383
var provider = Ecosystem.getProvider(manifestPath);
382-
var uri = URI.create(String.format("%s/api/v5/analysis", this.endpoint));
384+
var uri = URI.create(String.format(S_API_V_5_ANALYSIS, this.endpoint));
383385
var content = provider.provideComponent();
384386
commonHookAfterProviderCreatedSbomAndBeforeExhort();
385387
return getAnalysisReportForComponent(uri, content, exClientTraceId);
@@ -423,7 +425,7 @@ public CompletableFuture<AnalysisReport> componentAnalysis(String manifestFile)
423425
String exClientTraceId = commonHookBeginning(false);
424426
var manifestPath = Path.of(manifestFile);
425427
var provider = Ecosystem.getProvider(manifestPath);
426-
var uri = URI.create(String.format("%s/api/v5/analysis", this.endpoint));
428+
var uri = URI.create(String.format(S_API_V_5_ANALYSIS, this.endpoint));
427429
var content = provider.provideComponent();
428430
commonHookAfterProviderCreatedSbomAndBeforeExhort();
429431
return getAnalysisReportForComponent(uri, content, exClientTraceId);
@@ -464,7 +466,7 @@ private HttpRequest buildStackRequest(final String manifestFile, final MediaType
464466
throws IOException {
465467
var manifestPath = Path.of(manifestFile);
466468
var provider = Ecosystem.getProvider(manifestPath);
467-
var uri = URI.create(String.format("%s/api/v5/analysis", this.endpoint));
469+
var uri = URI.create(String.format(S_API_V_5_ANALYSIS, this.endpoint));
468470
var content = provider.provideStack();
469471
commonHookAfterProviderCreatedSbomAndBeforeExhort();
470472

@@ -543,7 +545,7 @@ <H, T> CompletableFuture<T> performBatchAnalysis(
543545
final String analysisName)
544546
throws IOException {
545547
String exClientTraceId = commonHookBeginning(false);
546-
var uri = URI.create(String.format("%s/api/v5/batch-analysis", this.endpoint));
548+
var uri = URI.create(String.format(S_API_V_5_BATCH_ANALYSIS, this.endpoint));
547549
var sboms = sbomsGenerator.get();
548550
var content =
549551
new Provider.Content(

src/test/java/io/github/guacsec/trustifyda/impl/Exhort_Api_Test.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
@SuppressWarnings("unchecked")
8888
class TRUSTIFY_DA_Api_Test extends ExhortTest {
8989

90+
public static final String S_API_V_5_BATCH_ANALYSIS = "%s/api/v5/batch-analysis";
9091
@Mock Provider mockProvider;
9192

9293
@Mock HttpClient mockHttpClient;
@@ -506,7 +507,7 @@ void test_image_analysis()
506507
.equals(
507508
URI.create(
508509
String.format(
509-
"%s/api/v5/batch-analysis", exhortApiSut.getEndpoint())))
510+
S_API_V_5_BATCH_ANALYSIS, exhortApiSut.getEndpoint())))
510511
&& r.headers().firstValue("Content-Type").get().equals(Api.CYCLONEDX_MEDIA_TYPE)
511512
&& r.headers()
512513
.firstValue("Accept")
@@ -612,7 +613,7 @@ void imageAnalysisHtml() throws IOException, ExecutionException, InterruptedExce
612613
.equals(
613614
URI.create(
614615
String.format(
615-
"%s/api/v5/batch-analysis", exhortApiSut.getEndpoint())))
616+
S_API_V_5_BATCH_ANALYSIS, exhortApiSut.getEndpoint())))
616617
&& r.headers().firstValue("Content-Type").get().equals(Api.CYCLONEDX_MEDIA_TYPE)
617618
&& r.headers()
618619
.firstValue("Accept")
@@ -657,7 +658,7 @@ void test_perform_batch_analysis()
657658
.equals(
658659
URI.create(
659660
String.format(
660-
"%s/api/v5/batch-analysis", exhortApiSut.getEndpoint())))
661+
S_API_V_5_BATCH_ANALYSIS, exhortApiSut.getEndpoint())))
661662
&& r.headers().firstValue("Content-Type").get().equals(Api.CYCLONEDX_MEDIA_TYPE)
662663
&& r.headers()
663664
.firstValue("Accept")

0 commit comments

Comments
 (0)