Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c422241
add jacoco plugin
YBushi Jun 8, 2024
9aa0841
Create .gitattributes
YBushi Jun 8, 2024
759e955
Normalize all line endings to LF
YBushi Jun 8, 2024
56f0a96
Normalize all line endings to LF
YBushi Jun 8, 2024
f389b08
Revert "Normalize all line endings to LF"
YBushi Jun 8, 2024
e84040a
Revert "Normalize all line endings to LF"
YBushi Jun 8, 2024
49d6ffe
.picked functions to cover
YBushi Jun 9, 2024
ac025a4
added readme which we should use for the report of our assignment
YBushi Jun 9, 2024
22ff531
Update README.md
YBushi Jun 9, 2024
30ddaf0
.added my 2 methods that I covered into the report
YBushi Jun 9, 2024
8385a7b
.disabled checkstyles so its easier to code without having to worry a…
YBushi Jun 9, 2024
99b6a14
Update README.md - Jayran 2 functions
jayran-d Jun 9, 2024
d865301
Update README.md
nikola20145 Jun 9, 2024
0983313
.disable programming mistake detector
YBushi Jun 10, 2024
c97456e
.added before/after coverage
YBushi Jun 10, 2024
8fa3da5
Update README.md
nikola20145 Jun 10, 2024
0976235
Update README.md
nikola20145 Jun 10, 2024
3884fad
Update README.md
nikola20145 Jun 10, 2024
f959b03
Update README.md
nikola20145 Jun 10, 2024
322bdc7
Update README.md
nikola20145 Jun 10, 2024
95bd2b6
Update README.md
nikola20145 Jun 10, 2024
e4efa5c
Update NingHttpClient.java
nikola20145 Jun 10, 2024
3015c50
Update pom.xml
nikola20145 Jun 10, 2024
31761ff
Update settings.json
nikola20145 Jun 10, 2024
de3bbe5
Update ArmeriaHttpClient.java
nikola20145 Jun 10, 2024
b7de5fe
Last updates for Assignment 1
nikola20145 Jun 18, 2024
d040a99
Changing Armeria file to the same as it is in master
nikola20145 Jun 20, 2024
292d26f
Update NingHttpClient.java
nikola20145 Jun 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.java text eol=lf
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.configuration.updateBuildConfiguration": "automatic",
"liveServer.settings.port": 5501
}
242 changes: 62 additions & 180 deletions README.md

Large diffs are not rendered by default.

180 changes: 180 additions & 0 deletions README_original.md

Large diffs are not rendered by default.

Binary file added image-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image.png
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 deletions pom.xml
Original file line number Diff line number Diff 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 Down Expand 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 Down Expand Up @@ -264,7 +327,7 @@
</goals>
</execution>
</executions>
</plugin>
</plugin> -->
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff 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 Down Expand 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;
}
return Objects.equals(fbtraceId, other.getFbtraceId());
return true;
}

@Override
Expand Down
Original file line number Diff line number Diff 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 number Diff line number Diff 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 number Diff line number Diff 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