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

Nikola development Pull Request for merging my work into the master branch#1072

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
nikola20145 wants to merge28 commits intoscribejava:master
base:master
Choose a base branch
Loading
fromYBushi:nikola-development
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
28 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
e4efa5c
Update NingHttpClient.java
nikola20145Jun 10, 2024
3015c50
Update pom.xml
nikola20145Jun 10, 2024
31761ff
Update settings.json
nikola20145Jun 10, 2024
de3bbe5
Update ArmeriaHttpClient.java
nikola20145Jun 10, 2024
b7de5fe
Last updates for Assignment 1
nikola20145Jun 18, 2024
d040a99
Changing Armeria file to the same as it is in master
nikola20145Jun 20, 2024
292d26f
Update NingHttpClient.java
nikola20145Jun 20, 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
4 changes: 4 additions & 0 deletions.vscode/settings.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
{
"java.configuration.updateBuildConfiguration": "automatic",
"liveServer.settings.port": 5501
}
242 changes: 62 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@@ -4,7 +4,9 @@
import com.github.scribejava.core.model.Response;
import java.io.IOException;
import java.util.Objects;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* non standard Facebook replace for {@link com.github.scribejava.core.model.OAuth2AccessTokenErrorResponse}
*
Expand All@@ -25,6 +27,32 @@ public class FacebookAccessTokenErrorResponse extends OAuthResponseException {
private final int codeInt;
private final String fbtraceId;

// Branch coverage data structure Nikola
private static final ConcurrentHashMap<String, AtomicBoolean> branchCoverage = new ConcurrentHashMap<>();

static {
branchCoverage.put("FacebookAccessTokenErrorResponse.equals.branch_1", new AtomicBoolean(false));
branchCoverage.put("FacebookAccessTokenErrorResponse.equals.branch_2", new AtomicBoolean(false));
branchCoverage.put("FacebookAccessTokenErrorResponse.equals.branch_3", new AtomicBoolean(false));
branchCoverage.put("FacebookAccessTokenErrorResponse.equals.branch_4", new AtomicBoolean(false));
branchCoverage.put("FacebookAccessTokenErrorResponse.equals.branch_5", new AtomicBoolean(false));
branchCoverage.put("FacebookAccessTokenErrorResponse.equals.branch_6", new AtomicBoolean(false));
branchCoverage.put("FacebookAccessTokenErrorResponse.equals.branch_7", new AtomicBoolean(false));


Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
@Override
public void run() {
synchronized (System.out) {
System.out.println("FacebookAccessTokenErrorResponse equals method coverage:");
for (Map.Entry<String, AtomicBoolean> entry : branchCoverage.entrySet()) {
System.out.println(entry.getKey() + ": " + (entry.getValue().get() ? "Taken" : "Not taken"));
}
}
}
}));
}

public FacebookAccessTokenErrorResponse(String errorMessage, String type, int code, String fbtraceId,
Response response)
throws IOException {
Expand DownExpand Up@@ -61,33 +89,39 @@ public int hashCode() {
return hash;
}

// branch coverage Nikola
@Override
public boolean equals(Object obj) {
if (this == obj) {
branchCoverage.get("FacebookAccessTokenErrorResponse.equals.branch_1").set(true);
return true;
}
if (obj == null) {
branchCoverage.get("FacebookAccessTokenErrorResponse.equals.branch_2").set(true);
return false;
}
if (getClass() != obj.getClass()) {
branchCoverage.get("FacebookAccessTokenErrorResponse.equals.branch_3").set(true);
return false;
}
if (!super.equals(obj)) {
FacebookAccessTokenErrorResponse other = (FacebookAccessTokenErrorResponse) obj;
if (!Objects.equals(errorMessage, other.errorMessage)) {
branchCoverage.get("FacebookAccessTokenErrorResponse.equals.branch_4").set(true);
return false;
}

final FacebookAccessTokenErrorResponse other = (FacebookAccessTokenErrorResponse) obj;

if (!Objects.equals(errorMessage, other.getErrorMessage())) {
if (!Objects.equals(type, other.type)) {
branchCoverage.get("FacebookAccessTokenErrorResponse.equals.branch_5").set(true);
return false;
}
if (!Objects.equals(type, other.getType())) {
if (codeInt != other.codeInt) {
branchCoverage.get("FacebookAccessTokenErrorResponse.equals.branch_6").set(true);
return false;
}
if (codeInt != other.getCodeInt()) {
if (!Objects.equals(fbtraceId, other.fbtraceId)) {
branchCoverage.get("FacebookAccessTokenErrorResponse.equals.branch_7").set(true);
return false;
}
returnObjects.equals(fbtraceId, other.getFbtraceId());
returntrue;
}

@Override
Expand Down
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
package com.github.scribejava.apis.facebook;

import com.github.scribejava.core.model.Response;
import java.io.IOException;
import java.util.Collections;
import static org.junit.Assert.*;
import org.junit.Test;

public class FacebookAccessTokenErrorResponseTest {

@Test
public void testEquals_Self() throws IOException {
Response response = new Response(200, "OK", Collections.<String, String>emptyMap(), "Body content here");
FacebookAccessTokenErrorResponse errorResponse = new FacebookAccessTokenErrorResponse(
"Message", "Type", 100, "TraceID", response);

assertTrue("Should return true when comparing to itself.",
errorResponse.equals(errorResponse));
}

@Test
public void testEquals_NullObject() throws IOException {
Response response = new Response(200, "OK", Collections.<String, String>emptyMap(), "Body content here");
FacebookAccessTokenErrorResponse errorResponse = new FacebookAccessTokenErrorResponse(
"Message", "Type", 100, "TraceID", response);

assertFalse("Should return false when comparing to null.",
errorResponse.equals(null));
}

@Test
public void testEquals_DifferentClass() throws IOException {
Response response = new Response(200, "OK", Collections.<String, String>emptyMap(), "Body content here");
FacebookAccessTokenErrorResponse errorResponse = new FacebookAccessTokenErrorResponse(
"Message", "Type", 100, "TraceID", response);
Object otherObject = new Object();

assertFalse("Should return false when comparing different classes.",
errorResponse.equals(otherObject));
}

@Test
public void testEquals_DifferentErrorMessage() throws IOException {
Response response = new Response(200, "OK", Collections.<String, String>emptyMap(), "Body content here");
FacebookAccessTokenErrorResponse errorResponse1 = new FacebookAccessTokenErrorResponse(
"Message1", "Type", 100, "TraceID", response);
FacebookAccessTokenErrorResponse errorResponse2 = new FacebookAccessTokenErrorResponse(
"Message2", "Type", 100, "TraceID", response);

assertFalse("Should return false when errorMessages are different.",
errorResponse1.equals(errorResponse2));
}

@Test
public void testEquals_DifferentType() throws IOException {
Response response = new Response(200, "OK", Collections.<String, String>emptyMap(), "Body content here");
FacebookAccessTokenErrorResponse errorResponse1 = new FacebookAccessTokenErrorResponse(
"Message", "Type1", 100, "TraceID", response);
FacebookAccessTokenErrorResponse errorResponse2 = new FacebookAccessTokenErrorResponse(
"Message", "Type2", 100, "TraceID", response);

assertFalse("Should return false when types are different.",
errorResponse1.equals(errorResponse2));
}

@Test
public void testEquals_DifferentCode() throws IOException {
Response response = new Response(200, "OK", Collections.<String, String>emptyMap(), "Body content here");
FacebookAccessTokenErrorResponse errorResponse1 = new FacebookAccessTokenErrorResponse(
"Message", "Type", 100, "TraceID", response);
FacebookAccessTokenErrorResponse errorResponse2 = new FacebookAccessTokenErrorResponse(
"Message", "Type", 101, "TraceID", response);

assertFalse("Should return false when codes are different.",
errorResponse1.equals(errorResponse2));
}

@Test
public void testEquals_DifferentFbtraceId() throws IOException {
Response response = new Response(200, "OK", Collections.<String, String>emptyMap(), "Body content here");
FacebookAccessTokenErrorResponse errorResponse1 = new FacebookAccessTokenErrorResponse(
"Message", "Type", 100, "TraceID1", response);
FacebookAccessTokenErrorResponse errorResponse2 = new FacebookAccessTokenErrorResponse(
"Message", "Type", 100, "TraceID2", response);

assertFalse("Should return false when fbtraceIds are different.",
errorResponse1.equals(errorResponse2));
}
}
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
Loading

[8]ページ先頭

©2009-2025 Movatter.jp