From f4cd15da65cfa1584e68db9a433f187ecc874080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20K=C3=B6rber?= Date: Sun, 20 Dec 2015 12:21:20 +0100 Subject: [PATCH] Constructor for creating a Registration with a location URI --- .../java/org/shredzone/acme4j/Registration.java | 14 ++++++++++++++ .../org/shredzone/acme4j/RegistrationTest.java | 12 ++++++++++++ 2 files changed, 26 insertions(+) diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/Registration.java b/acme4j-client/src/main/java/org/shredzone/acme4j/Registration.java index a80438da..5920e8fa 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/Registration.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/Registration.java @@ -28,6 +28,20 @@ public class Registration { private URI agreement; private URI location; + /** + * Create an empty {@link Registration}. + */ + public Registration() { + // default constructor + } + + /** + * Create a {@link Registration} for the given location URI. + */ + public Registration(URI location) { + this.location = location; + } + /** * Returns the URI of the agreement document the user is required to accept. */ diff --git a/acme4j-client/src/test/java/org/shredzone/acme4j/RegistrationTest.java b/acme4j-client/src/test/java/org/shredzone/acme4j/RegistrationTest.java index 1358ede6..8102f4f8 100644 --- a/acme4j-client/src/test/java/org/shredzone/acme4j/RegistrationTest.java +++ b/acme4j-client/src/test/java/org/shredzone/acme4j/RegistrationTest.java @@ -49,4 +49,16 @@ public class RegistrationTest { assertThat(registration.getContacts(), contains("mailto:foo@example.com", "mailto:bar@example.com")); } + /** + * Test constructors; + */ + @Test + public void testConstructor() throws URISyntaxException { + Registration registration1 = new Registration(); + assertThat(registration1.getLocation(), is(nullValue())); + + Registration registration2 = new Registration(new URI("http://example.com/acme/12345")); + assertThat(registration2.getLocation(), is(new URI("http://example.com/acme/12345"))); + } + }