Skip to content

Commit

Permalink
Fix deletePaste not working and update to 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MinusKube committed Dec 17, 2019
1 parent f91c2c8 commit c9c1033
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 42 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repositories {
}
dependencies {
compile 'fr.minuskube:jpastee:1.0.1'
compile 'fr.minuskube:jpastee:1.0.2'
}
```

Expand All @@ -19,7 +19,7 @@ dependencies {
<dependency>
<groupId>fr.minuskube</groupId>
<artifactId>jpastee</artifactId>
<version>1.0.1</version>
<version>1.0.2</version>
</dependency>
```

Expand Down
27 changes: 16 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@ plugins {
}

group 'fr.minuskube'
version '1.0.1'
version '1.0.2'

apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'

if (project.hasProperty("signing")) {
apply plugin: 'signing'

signing {
sign configurations.archives
}
}

sourceCompatibility = 1.8

repositories {
Expand Down Expand Up @@ -38,21 +45,19 @@ task sourcesJar(type: Jar) {

artifacts { archives javadocJar, sourcesJar }

signing {
sign configurations.archives
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
if(project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")) {
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
}

pom.project {
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/fr/minuskube/pastee/JPastee.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@
import com.mashape.unirest.http.exceptions.UnirestException;
import fr.minuskube.pastee.data.Paste;
import fr.minuskube.pastee.data.Syntax;
import fr.minuskube.pastee.response.PasteResponse;
import fr.minuskube.pastee.response.Response;
import fr.minuskube.pastee.response.SubmitResponse;
import fr.minuskube.pastee.response.SyntaxResponse;
import fr.minuskube.pastee.response.SyntaxesResponse;
import fr.minuskube.pastee.response.*;
import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.logging.Logger;
Expand All @@ -24,7 +19,7 @@ public class JPastee {
private static final String BASE_URL = "https://api.paste.ee/v1";
private static final Logger LOGGER = Logger.getLogger("JPastee");

private List<Syntax> syntaxes = new ArrayList<>();
private List<Syntax> syntaxes;
private String apiKey;

/**
Expand Down Expand Up @@ -114,7 +109,7 @@ public Response deletePaste(String id) {
final String route = "/pastes/" + id;

try {
return new Response(get(route).getBody().getObject());
return new Response(delete(route).getBody().getObject());
} catch(UnirestException e) {
return new Response(e);
}
Expand Down
39 changes: 18 additions & 21 deletions src/test/java/fr/minuskube/pastee/RequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

import java.util.logging.Logger;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;

public class RequestTest {

Expand All @@ -36,7 +33,7 @@ public void listSyntaxes() {
SyntaxesResponse resp = this.pastee.listSyntaxes();

if(!resp.isSuccess())
logger.severe("Errors: \n" + resp.getErrorString());
this.logger.severe("Errors: \n" + resp.getErrorString());

assertTrue(resp.isSuccess());
assertTrue(resp.getErrors().isEmpty());
Expand All @@ -57,36 +54,36 @@ public void submitPaste() {
.build();

assertTrue(paste.isEncrypted());
assertEquals(paste.getDescription(), "Test for JPastee API");
assertTrue(paste.getSections().size() == 1);
assertEquals("Test for JPastee API", paste.getDescription());
assertEquals(1, paste.getSections().size());

Section section = paste.getSections().get(0);

assertEquals(section.getName(), "JPastee Section Test");
assertEquals(section.getContents(), "This is a test for the JPastee API.");
assertEquals(section.getSyntax(), this.pastee.getSyntaxes().get(0));
assertEquals("JPastee Section Test", section.getName());
assertEquals("This is a test for the JPastee API.", section.getContents());
assertEquals(this.pastee.getSyntaxes().get(0), section.getSyntax());

SubmitResponse resp = this.pastee.submit(paste);

if(!resp.isSuccess())
logger.severe("Errors: \n" + resp.getErrorString());
this.logger.severe("Errors: \n" + resp.getErrorString());

assertTrue(resp.isSuccess());
assertTrue(resp.getErrors().isEmpty());

assertNotNull(resp.getId());
assertNotNull(resp.getLink());

logger.info("Paste created: " + resp.getLink());
this.logger.info("Paste created: " + resp.getLink());

getPaste(resp.getId());
this.getPaste(resp.getId());
}

public void getPaste(String createdPaste) {
PasteResponse resp = pastee.getPaste(createdPaste);
PasteResponse resp = this.pastee.getPaste(createdPaste);

if(!resp.isSuccess())
logger.severe("Errors: \n" + resp.getErrorString());
this.logger.severe("Errors: \n" + resp.getErrorString());

assertTrue(resp.isSuccess());
assertTrue(resp.getErrors().isEmpty());
Expand All @@ -95,17 +92,17 @@ public void getPaste(String createdPaste) {

Paste paste = resp.getPaste();

assertEquals(paste.getId(), createdPaste);
assertEquals(createdPaste, paste.getId());

assertTrue(paste.isEncrypted());
assertEquals(paste.getDescription(), "Test for JPastee API");
assertTrue(paste.getSections().size() == 1);
assertEquals("Test for JPastee API", paste.getDescription());
assertEquals(1, paste.getSections().size());

Section section = paste.getSections().get(0);

assertEquals(section.getName(), "JPastee Section Test");
assertEquals(section.getContents(), "This is a test for the JPastee API.");
assertEquals(section.getSyntax(), this.pastee.getSyntaxes().get(0));
assertEquals("JPastee Section Test", section.getName());
assertEquals("This is a test for the JPastee API.", section.getContents());
assertEquals(this.pastee.getSyntaxes().get(0), section.getSyntax());

assertNotNull(paste.getCreationDate());
}
Expand Down

0 comments on commit c9c1033

Please sign in to comment.