Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Jayran development#1071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
jayran-d wants to merge36 commits intoscribejava:master
base:master
Choose a base branch
Loading
fromYBushi:jayran-development
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
36 commits
Select commitHold shift + click to select a range
c422241
add jacoco plugin
YBushiJun 8, 2024
9aa0841
Create .gitattributes
YBushiJun 8, 2024
759e955
Normalize all line endings to LF
YBushiJun 8, 2024
56f0a96
Normalize all line endings to LF
YBushiJun 8, 2024
f389b08
Revert "Normalize all line endings to LF"
YBushiJun 8, 2024
e84040a
Revert "Normalize all line endings to LF"
YBushiJun 8, 2024
49d6ffe
.picked functions to cover
YBushiJun 9, 2024
ac025a4
added readme which we should use for the report of our assignment
YBushiJun 9, 2024
22ff531
Update README.md
YBushiJun 9, 2024
30ddaf0
.added my 2 methods that I covered into the report
YBushiJun 9, 2024
8385a7b
.disabled checkstyles so its easier to code without having to worry a…
YBushiJun 9, 2024
99b6a14
Update README.md - Jayran 2 functions
jayran-dJun 9, 2024
d865301
Update README.md
nikola20145Jun 9, 2024
0983313
.disable programming mistake detector
YBushiJun 10, 2024
c97456e
.added before/after coverage
YBushiJun 10, 2024
8fa3da5
Update README.md
nikola20145Jun 10, 2024
0976235
Update README.md
nikola20145Jun 10, 2024
3884fad
Update README.md
nikola20145Jun 10, 2024
f959b03
Update README.md
nikola20145Jun 10, 2024
322bdc7
Update README.md
nikola20145Jun 10, 2024
95bd2b6
Update README.md
nikola20145Jun 10, 2024
900eed3
Update README.md
nikola20145Jun 10, 2024
b0a2945
Update README.md
nikola20145Jun 10, 2024
e5e333d
Update README.md
nikola20145Jun 10, 2024
8d78943
Update README.md
nikola20145Jun 10, 2024
95aa70d
Update README.md
nikola20145Jun 10, 2024
9758f32
Update README.md
nikola20145Jun 10, 2024
2b635b1
added my branch coverage instrument for getHttpRequest
jayran-dJun 10, 2024
9eab4c3
implemented the coverage for the 2nd function
jayran-dJun 10, 2024
3719a1d
Applied changes to second function and updated somethings
jayran-dJun 10, 2024
d56a2cc
fixed my ID's and made it cleaner
jayran-dJun 12, 2024
3b8e67b
fixed some things. commened out manual coverage code for now
jayran-dJun 12, 2024
ed5c663
uncommented my stuff
jayran-dJun 12, 2024
582e001
implementd by code for testing
jayran-dJun 16, 2024
2d3c514
got rid of some import
jayran-dJun 16, 2024
8ebf0b7
got rid of some print statements
jayran-dJun 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions.gitattributes
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
*.java text eol=lf
3 changes: 3 additions & 0 deletions.vscode/settings.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}
259 changes: 79 additions & 180 deletionsREADME.md
View file
Open in desktop

Large diffs are not rendered by default.

180 changes: 180 additions & 0 deletionsREADME_original.md
View file
Open in desktop

Large diffs are not rendered by default.

Binary file addedimage-1.png
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file addedimage.png
View file
Open in desktop
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 69 additions & 6 deletionspom.xml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,6 +63,11 @@
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.scribejava</groupId>
<artifactId>scribejava-apis</artifactId>
<version>8.3.3</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
Expand All@@ -87,6 +92,64 @@
</execution>
</executions>
</plugin>
<!-- <plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin> -->
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.12</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand All@@ -97,7 +160,7 @@
</archive>
</configuration>
</plugin>
<plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.2.0</version>
Expand All@@ -108,7 +171,7 @@
<version>10.4</version>
</dependency>
</dependencies>
</plugin>
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand DownExpand Up@@ -200,7 +263,7 @@
</execution>
</executions>
</plugin>
<plugin>
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<executions>
Expand All@@ -220,8 +283,8 @@
</goals>
</execution>
</executions>
</plugin>
<plugin>
</plugin> -->
<!-- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.19.0</version>
Expand DownExpand Up@@ -264,7 +327,7 @@
</goals>
</execution>
</executions>
</plugin>
</plugin> -->
</plugins>
</build>

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -100,7 +100,8 @@ private <T> Future<T> doExecuteAsync(String userAgent, Map<String, String> heade
final Future<HttpResponse> future = client.execute(builder.build(), handler);
return new ApacheHttpFuture<>(future, handler);
}


//branch coverage: Tomas
private static RequestBuilder getRequestBuilder(Verb httpVerb) {
switch (httpVerb) {
case GET:
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,6 +34,7 @@ public OAuthAsyncCompletionHandler(OAuthAsyncRequestCallback<T> callback, Respon
this.latch = new CountDownLatch(1);
}

//branch coverage Tomas
@Override
public void completed(HttpResponse httpResponse) {
try {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -44,7 +44,8 @@ public class ArmeriaHttpClient extends AbstractAsyncOnlyHttpClient {
*/
private final ArmeriaWebClientBuilder clientBuilder;
/**
* A list of cached Endpoints. It helps avoiding building a new Endpoint per each request.
* A list of cached Endpoints. It helps avoiding building a new Endpoint per
* each request.
*/
private final Map<String, WebClient> httpClients = new HashMap<>();
/**
Expand DownExpand Up@@ -149,7 +150,8 @@ private <T> CompletableFuture<T> doExecuteAsync(String userAgent, Map<String, St
}

/**
* Provides an instance of {@link WebClient} for a given endpoint {@link URI} based on an endpoint as
* Provides an instance of {@link WebClient} for a given endpoint {@link URI}
* based on an endpoint as
* {@code scheme://authority}.
*
* @param uri an endpoint {@link URI}
Expand DownExpand Up@@ -192,56 +194,102 @@ private WebClient getClient(URI uri) {
/**
* Extracts {@code scheme} and {@code authority} portion of the {@link URI}.
*
* Assuming the {@link URI} as the following: {@code URI = scheme:[//authority]path[?query][#fragment]}
* Assuming the {@link URI} as the following:
* {@code URI = scheme:[//authority]path[?query][#fragment]}
*/
private static String getEndPoint(URI uri) {
return requireNonNull(uri.getScheme(), "scheme") + "://" + requireNonNull(uri.getAuthority(), "authority");
}

private static boolean[] getServiceCaseCoverage = new boolean[2]; // Data structure

/**
* Extracts {@code path}, {@code query} and {@code fragment} portion of the {@link URI}.
* Extracts {@code path}, {@code query} and {@code fragment} portion of the
* {@link URI}.
*
* Assuming the {@link URI} as the following: {@code URI = scheme:[//authority]path[?query][#fragment]}
* Assuming the {@link URI} as the following:
* {@code URI = scheme:[//authority]path[?query][#fragment]}
*/
private static String getServicePath(URI uri) {
public static String getServicePath(URI uri) {
final StringBuilder builder = new StringBuilder()
.append(requireNonNull(uri.getPath(), "path"));
final String query = uri.getQuery();
if (query != null) {
getServiceCaseCoverage[0] = true; // ID: ArmeriaHttpClient.getServicePath.branch_1
builder.append('?').append(query);
}
final String fragment = uri.getFragment();
if (fragment != null) {
getServiceCaseCoverage[1] = true; // ID: ArmeriaHttpClient.getServicePath.branch_2
builder.append('#').append(fragment);
}
return builder.toString();
}

private static void printCoverage() {
System.out.println("GetHttpMethod Coverage report:");
for (int i = 0; i < getHttpCaseCoverage.length; i++) {
System.out.println("ArmeriaHttpClient.getHttpMethod.branch_" + (i + 1) + ": "
+ getHttpCaseCoverage[i]);
}

System.out.println("GetService Coverage report:");
for (int i = 0; i < getServiceCaseCoverage.length; i++) {
System.out.println("ArmeriaHttpClient.getServicePath.branch_" + (i + 1) + ":" + getServiceCaseCoverage[i]);
}
}

static {
// Ensure the coverage report is printed when the class is loaded
Runtime.getRuntime().addShutdownHook(new Thread(ArmeriaHttpClient::printCoverage));
}

/**
* Maps {@link Verb} to {@link HttpMethod}
*
* @param httpVerb a {@link Verb} to match with {@link HttpMethod}
* @return {@link HttpMethod} corresponding to the parameter
*/
private static HttpMethod getHttpMethod(Verb httpVerb) {

private static boolean[] getHttpCaseCoverage = new boolean[9];

public static HttpMethod getHttpMethod(Verb httpVerb) {
switch (httpVerb) {
case GET:
// ID: ArmeriaHttpClient.getHttpMethod.branch_1
getHttpCaseCoverage[0] = true;
return HttpMethod.GET;
case POST:
// ID: ArmeriaHttpClient.getHttpMethod.branch_2
getHttpCaseCoverage[1] = true;
return HttpMethod.POST;
case PUT:
// ID: ArmeriaHttpClient.getHttpMethod.branch_3
getHttpCaseCoverage[2] = true;
return HttpMethod.PUT;
case DELETE:
// ID: ArmeriaHttpClient.getHttpMethod.branch_4
getHttpCaseCoverage[3] = true;
return HttpMethod.DELETE;
case HEAD:
// ID: ArmeriaHttpClient.getHttpMethod.branch_5
getHttpCaseCoverage[4] = true;
return HttpMethod.HEAD;
case OPTIONS:
// ID: ArmeriaHttpClient.getHttpMethod.branch_6
getHttpCaseCoverage[5] = true;
return HttpMethod.OPTIONS;
case TRACE:
// ID: ArmeriaHttpClient.getHttpMethod.branch_7
getHttpCaseCoverage[6] = true;
return HttpMethod.TRACE;
case PATCH:
// ID: ArmeriaHttpClient.getHttpMethod.branch_8
getHttpCaseCoverage[7] = true;
return HttpMethod.PATCH;
default:
// ID: ArmeriaHttpClient.getHttpMethod.branch_9
getHttpCaseCoverage[8] = true;
throw new IllegalArgumentException(
"message build error: unsupported HTTP method: " + httpVerb.name());
}
Expand All@@ -251,7 +299,8 @@ private static HttpMethod getHttpMethod(Verb httpVerb) {
/**
* Converts {@link AggregatedHttpResponse} to {@link Response}
*
* @param aggregatedResponse an instance of {@link AggregatedHttpResponse} to convert to {@link Response}
* @param aggregatedResponse an instance of {@link AggregatedHttpResponse} to
* convert to {@link Response}
* @return a {@link Response} converted from {@link AggregatedHttpResponse}
*/
private Response convertResponse(AggregatedHttpResponse aggregatedResponse) {
Expand All@@ -265,14 +314,19 @@ private Response convertResponse(AggregatedHttpResponse aggregatedResponse) {
}

/**
* Converts {@link AggregatedHttpResponse} to {@link Response} upon its aggregation completion and invokes
* Converts {@link AggregatedHttpResponse} to {@link Response} upon its
* aggregation completion and invokes
* {@link OAuthAsyncRequestCallback} for it.
*
* @param callback a {@link OAuthAsyncRequestCallback} callback to invoke upon response completion
* @param converter an optional {@link OAuthRequest.ResponseConverter} result converter for {@link Response}
* @param callback a {@link OAuthAsyncRequestCallback} callback to
* invoke upon response completion
* @param converter an optional {@link OAuthRequest.ResponseConverter}
* result converter for {@link Response}
* @param aggregatedResponse a source {@link AggregatedHttpResponse} to handle
* @param <T> converter {@link OAuthRequest.ResponseConverter} specific type or {@link Response}
* @return either instance of {@link Response} or converted result based on {@link OAuthRequest.ResponseConverter}
* @param <T> converter {@link OAuthRequest.ResponseConverter}
* specific type or {@link Response}
* @return either instance of {@link Response} or converted result based on
* {@link OAuthRequest.ResponseConverter}
*/
private <T> T whenResponseComplete(OAuthAsyncRequestCallback<T> callback,
OAuthRequest.ResponseConverter<T> converter, AggregatedHttpResponse aggregatedResponse) {
Expand All@@ -292,9 +346,11 @@ private <T> T whenResponseComplete(OAuthAsyncRequestCallback<T> callback,
/**
* Invokes {@link OAuthAsyncRequestCallback} upon {@link Throwable} error result
*
* @param callback a {@link OAuthAsyncRequestCallback} callback to invoke upon response completion
* @param callback a {@link OAuthAsyncRequestCallback} callback to invoke upon
* response completion
* @param throwable a {@link Throwable} error result
* @param <T> converter {@link OAuthRequest.ResponseConverter} specific type or {@link Response}
* @param <T> converter {@link OAuthRequest.ResponseConverter} specific
* type or {@link Response}
* @return null
*/
private <T> T completeExceptionally(OAuthAsyncRequestCallback<T> callback, Throwable throwable) {
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp