diff --git a/pom.xml b/pom.xml index 77b3fdf..fa75205 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.kitteh paste-gg-api - 0.9.1 + 1.0.0-SNAPSHOT paste.gg Java API @@ -45,14 +45,13 @@ GitHub https://github.com/KittehOrg/PasteGGAPI/issues - com.google.code.gson gson - 2.8.5 + 2.8.6 jar - provided + compile junit @@ -98,6 +97,11 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.0.0-M1 + diff --git a/src/main/java/org/kitteh/pastegg/ConnectionProvider.java b/src/main/java/org/kitteh/pastegg/ConnectionProvider.java index a1f1640..3233575 100644 --- a/src/main/java/org/kitteh/pastegg/ConnectionProvider.java +++ b/src/main/java/org/kitteh/pastegg/ConnectionProvider.java @@ -23,15 +23,12 @@ */ package org.kitteh.pastegg; -import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.io.Reader; import java.net.HttpURLConnection; -import java.net.InetSocketAddress; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -39,29 +36,79 @@ * Created by Narimm on 28/02/2020. */ public class ConnectionProvider { + private static Integer responseCode = null; - static String processPasteRequest(String output) throws IOException{ + public static Integer getLastResponseCode() { + return responseCode; + } + + static String processPasteRequest(String key, String output) throws IOException { + return processPasteRequest(key, output,false); + } + + static String processPasteRequest(String key, String output, boolean debug) throws IOException { URL url = new URL("https://api.paste.gg/v1/pastes"); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setRequestMethod("POST"); - conn.setRequestProperty("Content-Type", "application/json; charset="+StandardCharsets.UTF_8); - conn.setDoOutput(true); - conn.setRequestProperty("Accept", "application/json"); - try (OutputStream os = conn.getOutputStream()) { - byte[] input = output.getBytes(StandardCharsets.UTF_8); - os.write(input, 0, input.length); - } - StringBuilder content = new StringBuilder(); - try ( - InputStream stream = conn.getInputStream(); - InputStreamReader reader = new InputStreamReader(stream,StandardCharsets.UTF_8); - BufferedReader in = new BufferedReader(reader)) { + conn.setRequestMethod("POST"); + conn.setRequestProperty("Content-Type", "application/json; charset=" + StandardCharsets.UTF_8); + conn.setDoOutput(true); + if (key != null) { + conn.setRequestProperty("Authorization", "Key " + key); + } + conn.setRequestProperty("Accept", "application/json"); + if (debug) { + System.out.println("----------Connection--------------"); + System.out.println(conn.toString()); + System.out.println("----------Output--------------"); + System.out.println(output); + System.out.println("------------------------------"); + } + try (OutputStream os = conn.getOutputStream()) { + byte[] input = output.getBytes(StandardCharsets.UTF_8); + os.write(input, 0, input.length); + } + StringBuilder content = new StringBuilder(); + try { + responseCode = conn.getResponseCode(); + }catch (IOException e){ + InputStream in = conn.getErrorStream(); + if (in != null) { + InputStreamReader reader = new InputStreamReader(in,StandardCharsets.UTF_8); + BufferedReader errorIn = new BufferedReader(reader); String inputLine; - while ((inputLine = in.readLine()) != null) { + while ((inputLine = errorIn.readLine()) != null) { content.append(inputLine); } + if ( debug ) { + System.out.println("----------Error Response--------------"); + System.out.println(content.toString()); + System.out.println("------------------------------"); + } + throw new IOException(e.getMessage() + " Error Data: " + content.toString()); + } + throw e; + } + try ( + InputStream stream = conn.getInputStream(); + InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8); + BufferedReader in = new BufferedReader(reader)) { + String inputLine; + while ((inputLine = in.readLine()) != null) { + content.append(inputLine); } + } return content.toString(); } + public static boolean deletePaste(String pasteId, String deletionKey) throws IOException{ + URL url = new URL("https://api.paste.gg/v1/pastes/"+pasteId); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("DELETE"); + String key = "Key "+deletionKey; + conn.setRequestProperty("Authorization",key); + conn.connect(); + int responseCode = conn.getResponseCode(); + return responseCode == 204; + } + } diff --git a/src/main/java/org/kitteh/pastegg/GsonProviderLol.java b/src/main/java/org/kitteh/pastegg/GsonProviderLol.java index b0b7c00..ab0cf98 100644 --- a/src/main/java/org/kitteh/pastegg/GsonProviderLol.java +++ b/src/main/java/org/kitteh/pastegg/GsonProviderLol.java @@ -24,10 +24,13 @@ package org.kitteh.pastegg; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; /** * I'm a temporary class! */ public class GsonProviderLol { - public static final Gson GSON = new Gson(); + public static final Gson GSON = new GsonBuilder() + .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") + .create(); } diff --git a/src/main/java/org/kitteh/pastegg/InvalidPasteException.java b/src/main/java/org/kitteh/pastegg/InvalidPasteException.java new file mode 100644 index 0000000..1a2238d --- /dev/null +++ b/src/main/java/org/kitteh/pastegg/InvalidPasteException.java @@ -0,0 +1,41 @@ +/* + * * Copyright (C) 2018-2020 Matt Baxter https://kitteh.org + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kitteh.pastegg; + +/** + * Created by Narimm on 4/03/2020. + */ +public class InvalidPasteException extends RuntimeException { + private final String message; + + public InvalidPasteException(String message) { + this.message = message; + } + + @Override + public String getMessage() { + return message; + } + +} diff --git a/src/main/java/org/kitteh/pastegg/Paste.java b/src/main/java/org/kitteh/pastegg/Paste.java index 4ee29fb..1b5c358 100644 --- a/src/main/java/org/kitteh/pastegg/Paste.java +++ b/src/main/java/org/kitteh/pastegg/Paste.java @@ -24,13 +24,20 @@ package org.kitteh.pastegg; +import com.google.gson.annotations.SerializedName; + +import java.util.Date; import java.util.Optional; public class Paste { private final String id; private final String deletion_key; private final Visibility visibility; - + private Date expires; + @SerializedName("created_at") + private Date createdAt; + @SerializedName("updated_at") + private Date updatedAt; /** * Constructs a paste without a deletion key. @@ -40,22 +47,33 @@ public class Paste { public Paste(String id) { this(id, null); } - /** * Constructs a paste. * - * @param id id + * @param id id * @param deletionKey deletion key, or null */ public Paste(String id, String deletionKey) { - this(id,deletionKey,Visibility.PUBLIC); + this(id, deletionKey, Visibility.PUBLIC); } - public Paste(String id, String deletionKey, Visibility visibility) { this.id = id; this.deletion_key = deletionKey; this.visibility = visibility; } + + public Date getExpires() { + return expires; + } + + public Date getCreatedAt() { + return createdAt; + } + + public Date getUpdatedAt() { + return updatedAt; + } + /** * Gets the paste's id. * diff --git a/src/main/java/org/kitteh/pastegg/PasteBuilder.java b/src/main/java/org/kitteh/pastegg/PasteBuilder.java index 9998da9..d480cc2 100644 --- a/src/main/java/org/kitteh/pastegg/PasteBuilder.java +++ b/src/main/java/org/kitteh/pastegg/PasteBuilder.java @@ -40,6 +40,7 @@ public static class PasteResult { private Paste result; private String message; + public Optional getPaste() { return Optional.ofNullable(this.result); } @@ -47,13 +48,19 @@ public Optional getPaste() { public Optional getMessage() { return Optional.ofNullable(this.message); } + + public String getStatus() { + return status; + } } private Visibility visibility = Visibility.getDefault(); private String name; + private String expires = null; + private boolean debug = false; + private String apiKey; @SuppressWarnings({"TypeMayBeWeakened", "MismatchedQueryAndUpdateOfCollection"}) - private List files = new LinkedList<>(); - private String expires; + private final List files = new LinkedList<>(); public PasteBuilder name(String name) { this.name = name; @@ -66,24 +73,51 @@ public PasteBuilder expires(ZonedDateTime when) { return this; } + public PasteBuilder setApiKey(String key) { + this.apiKey = key; + return this; + } + public PasteBuilder visibility(Visibility visibility) { this.visibility = visibility; return this; } + /** + * debug the connection. + * @param debug boolean + * @return PasteBuilder + */ + public PasteBuilder debug(boolean debug) { + this.debug = debug; + return this; + } + + public PasteBuilder addFile(PasteFile file) { files.add(file); return this; } - public PasteResult build() { + public PasteResult build() throws InvalidPasteException { + if (visibility == Visibility.PRIVATE && apiKey == null) { + throw new InvalidPasteException("No API Key Provided for Private Paste..."); + } String toString = GsonProviderLol.GSON.toJson(this); try { - String result = ConnectionProvider.processPasteRequest(toString); - return GsonProviderLol.GSON.fromJson(result, PasteResult.class); + String result = ConnectionProvider.processPasteRequest(apiKey, toString,debug); + PasteResult pasteResult = GsonProviderLol.GSON.fromJson(result, PasteResult.class); + if (pasteResult.getPaste().isPresent()) { + PasteManager.addPaste(pasteResult.getPaste().get()); + } + return pasteResult; } catch (IOException e) { - e.printStackTrace(); + + InvalidPasteException invalid = + new InvalidPasteException("Paste could not be sent to past.gg: " + + e.getMessage()); + invalid.addSuppressed(e); + throw invalid; } - return null; } } diff --git a/src/main/java/org/kitteh/pastegg/PasteContent.java b/src/main/java/org/kitteh/pastegg/PasteContent.java index aeb8730..eb40ab1 100644 --- a/src/main/java/org/kitteh/pastegg/PasteContent.java +++ b/src/main/java/org/kitteh/pastegg/PasteContent.java @@ -81,8 +81,10 @@ public Function getProcessor() { } } - private ContentType format; - private String value; + @SuppressWarnings("unused") + private final ContentType format; + @SuppressWarnings("unused") + private final String value; private transient String processedValue; diff --git a/src/main/java/org/kitteh/pastegg/PasteFile.java b/src/main/java/org/kitteh/pastegg/PasteFile.java index 1d2282b..7277b69 100644 --- a/src/main/java/org/kitteh/pastegg/PasteFile.java +++ b/src/main/java/org/kitteh/pastegg/PasteFile.java @@ -23,10 +23,11 @@ */ package org.kitteh.pastegg; +@SuppressWarnings("CanBeFinal") public class PasteFile { - private String id; - private String name; - private PasteContent content; + private final String id; + private final String name; + private final PasteContent content; public PasteFile(String id, String name, PasteContent content) { this.id = id; diff --git a/src/main/java/org/kitteh/pastegg/PasteManager.java b/src/main/java/org/kitteh/pastegg/PasteManager.java new file mode 100644 index 0000000..03a51a7 --- /dev/null +++ b/src/main/java/org/kitteh/pastegg/PasteManager.java @@ -0,0 +1,111 @@ +/* + * * Copyright (C) 2018-2020 Matt Baxter https://kitteh.org + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.kitteh.pastegg; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * Created by Narimm on 4/03/2020. + */ +public class PasteManager { + private static final Map sessionPastes = new HashMap<>(); + private static String apiKey; + + /** + * Return the API key. + * @return the key + */ + public static String getApiKey() { + return apiKey; + } + + /** + * Set the managers API key. + * @param key api Key + */ + public static void setApiKey(String key) { + apiKey = key; + } + + /** + * Clear all stored pastes. + */ + public static void clearPastes() { + sessionPastes.clear(); + } + + /** + * Add a paste. + * @param paste the paste to add + * @return always null - Paste if the paste ID was already taken (should never happen.) + */ + static Paste addPaste(Paste paste) { + return sessionPastes.put(paste.getId(), paste); + } + + /** + * This method will search for a paste id made this session and remove it - either using a stored + * deletion key OR the api key if provided - if neither are present it will return false. + * + * @param id the paste ID + * @return boolean + */ + public static boolean deletePaste(String id) { + Paste paste = sessionPastes.get(id); + if (paste == null) { + return false; + } + String pasteKey; + if (paste.getDeletionKey().isPresent()) { + pasteKey = paste.getDeletionKey().get(); + } else { + if (apiKey != null) { + pasteKey = apiKey; + } else { + return false; + } + } + return deletePaste(paste.getId(),pasteKey); + } + + /** + * Attempt to delete a paste. + * + * @param id String + * @param deletionKey String + * @return boolean + */ + public static boolean deletePaste(String id,String deletionKey) { + try { + return ConnectionProvider.deletePaste(id, deletionKey); + } catch (IOException e) { + InvalidPasteException inv = new InvalidPasteException("Paste could not be deleted: " + + ConnectionProvider.getLastResponseCode()); + inv.addSuppressed(e); + throw inv; + } + } +} diff --git a/src/test/java/org/kitteh/pastegg/PasteBuilderTest.java b/src/test/java/org/kitteh/pastegg/PasteBuilderTest.java index e87cfa4..add72d5 100644 --- a/src/test/java/org/kitteh/pastegg/PasteBuilderTest.java +++ b/src/test/java/org/kitteh/pastegg/PasteBuilderTest.java @@ -1,26 +1,121 @@ package org.kitteh.pastegg; -import static org.junit.Assert.*; +import org.junit.Test; + +import java.time.ZonedDateTime; +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 java.io.IOException; +import java.util.Calendar; +import java.util.Date; /** - * Created for the Charlton IT Project. - * Created by benjicharlton on 28/02/2020. + * Created by Narimm on 28/02/2020. */ public class PasteBuilderTest { - @org.junit.Test + @Test public void build() { PasteContent content = new PasteContent(PasteContent.ContentType.TEXT, "HELLO WORLD"); assertEquals(content.getValue(),"HELLO WORLD"); + ZonedDateTime time = ZonedDateTime.now().plusMinutes(1); PasteBuilder.PasteResult result = new PasteBuilder().name("TEST!").addFile( new PasteFile("jkcclemens.txt", new PasteContent(PasteContent.ContentType.TEXT, "HELLO WORLD"))) .visibility(Visibility.UNLISTED) + .expires(time) + .debug(true) .build(); assertTrue(result.getPaste().isPresent()); + assertFalse(result.getMessage().isPresent()); Paste paste = result.getPaste().get(); assertNotNull(paste.getId()); + assertNotNull(paste.getExpires()); assert(paste.getVisibility().equals(Visibility.UNLISTED)); assertTrue(paste.getDeletionKey().isPresent()); + Integer val = 201; + assertEquals(val,ConnectionProvider.getLastResponseCode()); + try { + boolean yes = ConnectionProvider.deletePaste(paste.getId(), paste.getDeletionKey().get()); + assertTrue(yes); + }catch (IOException ignored){} + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.HOUR_OF_DAY,1); + time = ZonedDateTime.ofInstant(cal.toInstant(),cal.getTimeZone().toZoneId()); + Date localDate = cal.getTime(); + PasteBuilder builder = new PasteBuilder().name("TEST!").addFile( + new PasteFile("jkcclemens.txt", + new PasteContent(PasteContent.ContentType.TEXT, "HELLO WORLD"))) + .visibility(Visibility.UNLISTED) + .expires(time); + PasteBuilder.PasteResult result1 = builder.build(); + assertTrue(result1.getPaste().isPresent()); + assertEquals(localDate.toString(),result1.getPaste().get().getExpires().toString()); + assertNotNull(result1.getPaste().get().getCreatedAt()); + assertNotNull(result1.getPaste().get().getUpdatedAt()); + assertEquals(result1.getPaste().get().getCreatedAt().toString(), + result1.getPaste().get().getUpdatedAt().toString()); + } + + @Test + public void buildWithAuthentication(){ + try { + String apiKey = System.getenv("PasteGGAPIKey"); + if((apiKey == null) || apiKey.length()>0) { + Logger.getAnonymousLogger().info("No ApI Key given for testing"); + return; + } + PasteContent content = new PasteContent(PasteContent.ContentType.TEXT,"Hello World"); + PasteBuilder.PasteResult result = new PasteBuilder() + .name("Test") + .addFile(new PasteFile("Test.txt",content)) + .setApiKey(apiKey) + .visibility(Visibility.PRIVATE) + .debug(true) + .build(); + assertNotNull(result); + assertTrue(result.getPaste().isPresent()); + Paste paste = result.getPaste().get(); + assert(paste.getVisibility().equals(Visibility.PRIVATE)); + assertFalse(paste.getDeletionKey().isPresent()); + assertNotNull(paste.getId()); + }catch (SecurityException e){ + e.printStackTrace(); + } + } + @Test(expected = InvalidPasteException.class) + public void buildNullKeyPrivate(){ + InvalidPasteException e = new InvalidPasteException("Some Message"); + assertEquals("Some Message", e.getMessage()); + PasteContent content = new PasteContent(PasteContent.ContentType.TEXT,"Hello World"); + new PasteBuilder() + .name("Test") + .addFile(new PasteFile("Test.txt",content)) + .setApiKey(null) + .visibility(Visibility.PRIVATE) + .build(); + } + + + + @Test(expected = InvalidPasteException.class) + public void buildWithBadKey(){ + PasteContent content = new PasteContent(PasteContent.ContentType.TEXT,"Hello World"); + new PasteBuilder() + .name("Test") + .addFile(new PasteFile("Test.txt",content)) + .setApiKey("someKey") + .visibility(Visibility.PRIVATE) + .build(); + } + @Test + public void testPasteResult(){ + PasteBuilder.PasteResult pasteResult = new PasteBuilder.PasteResult(); + assertFalse(pasteResult.getMessage().isPresent()); } -} \ No newline at end of file +} diff --git a/src/test/java/org/kitteh/pastegg/PasteContentTest.java b/src/test/java/org/kitteh/pastegg/PasteContentTest.java index 8459be4..ca4e931 100644 --- a/src/test/java/org/kitteh/pastegg/PasteContentTest.java +++ b/src/test/java/org/kitteh/pastegg/PasteContentTest.java @@ -2,11 +2,10 @@ import org.junit.Test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** - * Created for the Charlton IT Project. - * Created by benjicharlton on 28/02/2020. + * Created by Narimm on 28/02/2020. */ public class PasteContentTest { @@ -15,7 +14,32 @@ public void getValue() { PasteContent content = new PasteContent(PasteContent.ContentType.TEXT, "HELLO WORLD"); assertEquals(content.getValue(),"HELLO WORLD"); } + @Test + public void getGZIPValue() { + PasteContent content = new PasteContent(PasteContent.ContentType.GZIP, "HELLO WORLD"); + assertEquals(content.getValue(),"HELLO WORLD"); + } + + @Test + public void testGzip() { + PasteContent content = new PasteContent(PasteContent.ContentType.GZIP, "HELLO WORLD"); + assertEquals(content.getValue(),"HELLO WORLD"); + String out = GsonProviderLol.GSON.toJson(content); + assert(out.equals("{\"format\":\"gzip\",\"value\":\"H4sIAAAAAAAAAPNw9fHxVwj3D_JxAQBbhuWHCwAAAA\\u003d\\u003d\"}")); + } + @Test + public void testBase64() { + PasteContent content = new PasteContent(PasteContent.ContentType.BASE64, "HELLO WORLD"); + assertEquals(content.getValue(),"HELLO WORLD"); + String out = GsonProviderLol.GSON.toJson(content); + assert(out.equals("{\"format\":\"base64\",\"value\":\"SEVMTE8gV09STEQ\\u003d\"}")); + } + @Test + public void getBase64Value() { + PasteContent content = new PasteContent(PasteContent.ContentType.BASE64, "HELLO WORLD"); + assertEquals(content.getValue(),"HELLO WORLD"); + } @Test(expected = UnsupportedOperationException.class) public void getException() { new PasteContent(PasteContent.ContentType.XZ, "HELLO WORLD"); diff --git a/src/test/java/org/kitteh/pastegg/PasteFileTest.java b/src/test/java/org/kitteh/pastegg/PasteFileTest.java new file mode 100644 index 0000000..7623b8c --- /dev/null +++ b/src/test/java/org/kitteh/pastegg/PasteFileTest.java @@ -0,0 +1,32 @@ +package org.kitteh.pastegg; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Created by Narimm on 4/03/2020. + */ +public class PasteFileTest { + private PasteFile test; + @Before + public void Setup(){ + test = new PasteFile("1","Test", + new PasteContent(PasteContent.ContentType.TEXT,"HELLO WORLD")); + } + @Test + public void getContent() { + assertEquals(test.getContent().getValue(),"HELLO WORLD"); + } + + @Test + public void getId() { + assertEquals(test.getId(),"1"); + } + + @Test + public void getName() { + assertEquals("Test",test.getName()); + } +} \ No newline at end of file diff --git a/src/test/java/org/kitteh/pastegg/PasteTest.java b/src/test/java/org/kitteh/pastegg/PasteTest.java new file mode 100644 index 0000000..ffcd896 --- /dev/null +++ b/src/test/java/org/kitteh/pastegg/PasteTest.java @@ -0,0 +1,33 @@ +package org.kitteh.pastegg; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +/** + * Created by Narimm on 4/03/2020. + */ +public class PasteTest { + private Paste paste; + @Before + public void Setup(){ + paste = new Paste("1"); + } + + @Test + public void getId() { + assertEquals("1",paste.getId()); + } + + @Test + public void getDeletionKey() { + assertFalse(paste.getDeletionKey().isPresent()); + } + + @Test + public void getVisibility() { + assertEquals(Visibility.PUBLIC,paste.getVisibility()); + } +} \ No newline at end of file