← Back to team overview

slub.team team mailing list archive

[Merge] lp:~ralf-claussnitzer/goobi-production/rest-api-refactored into lp:goobi-production

 

Ralf Claussnitzer has proposed merging lp:~ralf-claussnitzer/goobi-production/rest-api-refactored into lp:goobi-production.

Requested reviews:
  Henning Gerhardt (henning-gerhardt)

For more details, see:
https://code.launchpad.net/~ralf-claussnitzer/goobi-production/rest-api-refactored/+merge/117267
-- 
https://code.launchpad.net/~ralf-claussnitzer/goobi-production/rest-api-refactored/+merge/117267
Your team Saxon State Library Team is subscribed to branch lp:goobi-production.
=== modified file 'WEB-INF/web.xml'
--- WEB-INF/web.xml	2012-07-26 16:41:08 +0000
+++ WEB-INF/web.xml	2012-07-30 13:25:24 +0000
@@ -317,4 +317,20 @@
 		<location>/newpages/error.jsf</location>
 	</error-page>
 
+    <servlet>
+        <servlet-name>Goobi REST Service based on Jersey</servlet-name>
+        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+        <init-param>
+            <param-name>com.sun.jersey.config.property.packages</param-name>
+            <param-value>org.goobi.webapi.resources; org.goobi.webapi.provider</param-value>
+        </init-param>
+        <!-- explanation of load-on-startup: http://stackoverflow.com/a/1298984 -->
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>Goobi REST Service based on Jersey</servlet-name>
+        <url-pattern>/rest/*</url-pattern>
+    </servlet-mapping>
+
 </web-app>

=== added file 'lib/asm-3.1.jar'
Binary files lib/asm-3.1.jar	1970-01-01 00:00:00 +0000 and lib/asm-3.1.jar	2012-07-30 13:25:24 +0000 differ
=== added file 'lib/jersey-bundle-1.12.jar'
Binary files lib/jersey-bundle-1.12.jar	1970-01-01 00:00:00 +0000 and lib/jersey-bundle-1.12.jar	2012-07-30 13:25:24 +0000 differ
=== added file 'lib/jersey-client-1.12.jar'
Binary files lib/jersey-client-1.12.jar	1970-01-01 00:00:00 +0000 and lib/jersey-client-1.12.jar	2012-07-30 13:25:24 +0000 differ
=== added file 'lib/jersey-core-1.12.jar'
Binary files lib/jersey-core-1.12.jar	1970-01-01 00:00:00 +0000 and lib/jersey-core-1.12.jar	2012-07-30 13:25:24 +0000 differ
=== added file 'lib/jersey-json-1.12.jar'
Binary files lib/jersey-json-1.12.jar	1970-01-01 00:00:00 +0000 and lib/jersey-json-1.12.jar	2012-07-30 13:25:24 +0000 differ
=== added file 'lib/jersey-multipart-1.12.jar'
Binary files lib/jersey-multipart-1.12.jar	1970-01-01 00:00:00 +0000 and lib/jersey-multipart-1.12.jar	2012-07-30 13:25:24 +0000 differ
=== added file 'lib/jersey-server-1.12.jar'
Binary files lib/jersey-server-1.12.jar	1970-01-01 00:00:00 +0000 and lib/jersey-server-1.12.jar	2012-07-30 13:25:24 +0000 differ
=== added file 'lib/jersey-servlet-1.12.jar'
Binary files lib/jersey-servlet-1.12.jar	1970-01-01 00:00:00 +0000 and lib/jersey-servlet-1.12.jar	2012-07-30 13:25:24 +0000 differ
=== added file 'lib/jsr311-api-1.1.1.jar'
Binary files lib/jsr311-api-1.1.1.jar	1970-01-01 00:00:00 +0000 and lib/jsr311-api-1.1.1.jar	2012-07-30 13:25:24 +0000 differ
=== added directory 'src/org/goobi/webapi'
=== added directory 'src/org/goobi/webapi/beans'
=== added file 'src/org/goobi/webapi/beans/GoobiProcess.java'
--- src/org/goobi/webapi/beans/GoobiProcess.java	1970-01-01 00:00:00 +0000
+++ src/org/goobi/webapi/beans/GoobiProcess.java	2012-07-30 13:25:24 +0000
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ *     - http://gdz.sub.uni-goettingen.de
+ *     - http://www.goobi.org
+ *     - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.goobi.webapi.beans;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class GoobiProcess {
+
+    private String identifier;
+
+    private String title;
+
+    public GoobiProcess() {
+    }
+
+    public GoobiProcess(String identifier, String title) {
+        this.identifier = identifier;
+        this.title = title;
+    }
+
+    public String getIdentifier() {
+        return identifier;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setIdentifier(String identifier) {
+        this.identifier = identifier;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+}

=== added file 'src/org/goobi/webapi/beans/GoobiProcessStep.java'
--- src/org/goobi/webapi/beans/GoobiProcessStep.java	1970-01-01 00:00:00 +0000
+++ src/org/goobi/webapi/beans/GoobiProcessStep.java	2012-07-30 13:25:24 +0000
@@ -0,0 +1,66 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ *     - http://gdz.sub.uni-goettingen.de
+ *     - http://www.goobi.org
+ *     - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.goobi.webapi.beans;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class GoobiProcessStep {
+
+    private Integer sequence;
+    private Integer state;
+    private String title;
+
+    public GoobiProcessStep() {
+    }
+
+    public GoobiProcessStep(Integer sequence, Integer state, String title) {
+        this.sequence = sequence;
+        this.state = state;
+        this.title = title;
+    }
+
+    public Integer getSequence() {
+        return sequence;
+    }
+
+    public void setSequence(Integer sequence) {
+        this.sequence = sequence;
+    }
+
+    public Integer getState() {
+        return state;
+    }
+
+    public void setState(Integer state) {
+        this.state = state;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+}

=== added file 'src/org/goobi/webapi/beans/IdentifierPPN.java'
--- src/org/goobi/webapi/beans/IdentifierPPN.java	1970-01-01 00:00:00 +0000
+++ src/org/goobi/webapi/beans/IdentifierPPN.java	2012-07-30 13:25:24 +0000
@@ -0,0 +1,61 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ *     - http://gdz.sub.uni-goettingen.de
+ *     - http://www.goobi.org
+ *     - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.goobi.webapi.beans;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class IdentifierPPN {
+
+    private String ppn;
+
+    public IdentifierPPN(String ppn) {
+        if (!isValid(ppn)) {
+            throw new IllegalArgumentException("Given string is not a valid PPN identifier.");
+        }
+        this.ppn = ppn;
+    }
+
+    public static boolean isValid(String identifier) {
+        Boolean result;
+        int flags = Pattern.CASE_INSENSITIVE;
+        Pattern pattern;
+        Matcher matcher;
+
+        if ((identifier == null) || (identifier.length() == 0)) {
+            result = false;
+        } else {
+            pattern = Pattern.compile("^[0-9]{8}[0-9LXYZ]{1}$", flags);
+            matcher = pattern.matcher(identifier);
+            result = matcher.matches();
+        }
+
+        return result;
+    }
+
+    public String toString() {
+        return ppn;
+    }
+
+
+}

=== added directory 'src/org/goobi/webapi/models'
=== added file 'src/org/goobi/webapi/models/GoobiProcess.java'
--- src/org/goobi/webapi/models/GoobiProcess.java	1970-01-01 00:00:00 +0000
+++ src/org/goobi/webapi/models/GoobiProcess.java	2012-07-30 13:25:24 +0000
@@ -0,0 +1,153 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ *     - http://gdz.sub.uni-goettingen.de
+ *     - http://www.goobi.org
+ *     - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.goobi.webapi.models;
+
+import de.sub.goobi.beans.Prozess;
+import de.sub.goobi.beans.Schritt;
+import de.sub.goobi.helper.Helper;
+import org.apache.log4j.Logger;
+import org.goobi.webapi.beans.GoobiProcessStep;
+import org.goobi.webapi.beans.IdentifierPPN;
+import org.hibernate.Criteria;
+import org.hibernate.HibernateException;
+import org.hibernate.Session;
+import org.hibernate.criterion.Order;
+import org.hibernate.criterion.Projections;
+import org.hibernate.criterion.Restrictions;
+import org.hibernate.transform.Transformers;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class GoobiProcess {
+
+    private static final Logger myLogger = Logger.getLogger(GoobiProcess.class);
+
+    public static org.goobi.webapi.beans.GoobiProcess getProcessByPPN(IdentifierPPN PPN) {
+        Session session;
+        org.goobi.webapi.beans.GoobiProcess result = null;
+
+        session = Helper.getHibernateSession();
+
+        try {
+
+            Criteria criteria = session
+                    .createCriteria(Prozess.class)
+                    .createAlias("vorlagen", "v")
+                    .createAlias("vorlagen.eigenschaften", "ve")
+                    .createAlias("werkstuecke", "w")
+                    .createAlias("werkstuecke.eigenschaften", "we")
+                    .add(Restrictions.or(Restrictions.eq("we.titel", "PPN digital a-Satz"), Restrictions.eq("we.titel", "PPN digital f-Satz")))
+                    .add(Restrictions.eq("ve.titel", "Titel"))
+                    .add(Restrictions.eq("we.wert", PPN.toString()))
+                    .addOrder(Order.asc("we.wert"))
+                    .setProjection(Projections.projectionList()
+                            .add(Projections.property("we.wert"), "identifier")
+                            .add(Projections.property("ve.wert"), "title")
+                    )
+                    .setResultTransformer(Transformers.aliasToBean(org.goobi.webapi.beans.GoobiProcess.class));
+
+            result = (org.goobi.webapi.beans.GoobiProcess) criteria.uniqueResult();
+
+        } catch (HibernateException he) {
+            myLogger.error("Catched Hibernate exception: " + he.getMessage());
+        }
+
+        return result;
+    }
+
+    public static List<org.goobi.webapi.beans.GoobiProcess> getAllProcesses() {
+        Session session;
+        List<org.goobi.webapi.beans.GoobiProcess> result;
+
+        result = new ArrayList<org.goobi.webapi.beans.GoobiProcess>();
+        session = Helper.getHibernateSession();
+
+        try {
+
+            Criteria criteria = session
+                    .createCriteria(Prozess.class)
+                    .createAlias("vorlagen", "v")
+                    .createAlias("vorlagen.eigenschaften", "ve")
+                    .createAlias("werkstuecke", "w")
+                    .createAlias("werkstuecke.eigenschaften", "we")
+                    .add(Restrictions.or(Restrictions.eq("we.titel", "PPN digital a-Satz"), Restrictions.eq("we.titel", "PPN digital f-Satz")))
+                    .add(Restrictions.eq("ve.titel", "Titel"))
+                    .addOrder(Order.asc("we.wert"))
+                    .setProjection(Projections.projectionList()
+                            .add(Projections.property("we.wert"), "identifier")
+                            .add(Projections.property("ve.wert"), "title")
+                    )
+                    .setResultTransformer(Transformers.aliasToBean(org.goobi.webapi.beans.GoobiProcess.class));
+
+            @SuppressWarnings(value = "unchecked")
+            List<org.goobi.webapi.beans.GoobiProcess> list = (List<org.goobi.webapi.beans.GoobiProcess>) criteria.list();
+
+            if ((list != null) && (list.size() > 0)) {
+                result.addAll(list);
+            }
+        } catch (HibernateException he) {
+            myLogger.error("Catched Hibernate exception: " + he.getMessage());
+        }
+
+        return result;
+    }
+
+    public static List<GoobiProcessStep> getAllProcessSteps(IdentifierPPN PPN) {
+        List<GoobiProcessStep> result;
+        Session session;
+
+        result = new ArrayList<GoobiProcessStep>();
+        session = Helper.getHibernateSession();
+
+        try {
+
+            Criteria criteria = session
+                    .createCriteria(Schritt.class)
+                    .createAlias("prozess", "p")
+                    .createAlias("prozess.werkstuecke", "w")
+                    .createAlias("prozess.werkstuecke.eigenschaften", "we")
+                    .add(Restrictions.or(Restrictions.eq("we.titel", "PPN digital a-Satz"), Restrictions.eq("we.titel", "PPN digital f-Satz")))
+                    .add(Restrictions.eq("we.wert", PPN.toString()))
+                    .addOrder(Order.asc("reihenfolge"))
+                    .setProjection(Projections.projectionList()
+                            .add(Projections.property("reihenfolge"), "sequence")
+                            .add(Projections.property("bearbeitungsstatus"), "state")
+                            .add(Projections.property("titel"), "title")
+                    )
+                    .setResultTransformer(Transformers.aliasToBean(GoobiProcessStep.class));
+
+            @SuppressWarnings(value = "unchecked")
+            List<GoobiProcessStep> list = (List<GoobiProcessStep>) criteria.list();
+
+            if ((list != null) && (!list.isEmpty())) {
+                result.addAll(list);
+            }
+        } catch (HibernateException he) {
+            myLogger.error("Catched Hibernate exception: " + he.getMessage());
+        }
+
+        return result;
+    }
+
+}

=== added directory 'src/org/goobi/webapi/provider'
=== added file 'src/org/goobi/webapi/provider/ParamExceptionMapper.java'
--- src/org/goobi/webapi/provider/ParamExceptionMapper.java	1970-01-01 00:00:00 +0000
+++ src/org/goobi/webapi/provider/ParamExceptionMapper.java	2012-07-30 13:25:24 +0000
@@ -0,0 +1,39 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ *     - http://gdz.sub.uni-goettingen.de
+ *     - http://www.goobi.org
+ *     - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.goobi.webapi.provider;
+
+import com.sun.jersey.api.ParamException;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.Provider;
+
+@Provider
+public class ParamExceptionMapper implements javax.ws.rs.ext.ExceptionMapper<ParamException> {
+    public Response toResponse(ParamException e) {
+        return Response.status(Response.Status.BAD_REQUEST)
+                .entity(e.getCause().getMessage())
+                .type(MediaType.TEXT_PLAIN)
+                .build();
+    }
+}

=== added directory 'src/org/goobi/webapi/resources'
=== added file 'src/org/goobi/webapi/resources/Processes.java'
--- src/org/goobi/webapi/resources/Processes.java	1970-01-01 00:00:00 +0000
+++ src/org/goobi/webapi/resources/Processes.java	2012-07-30 13:25:24 +0000
@@ -0,0 +1,77 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ *     - http://gdz.sub.uni-goettingen.de
+ *     - http://www.goobi.org
+ *     - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.goobi.webapi.resources;
+
+import com.sun.jersey.api.NotFoundException;
+import org.goobi.webapi.beans.GoobiProcess;
+import org.goobi.webapi.beans.GoobiProcessStep;
+import org.goobi.webapi.beans.IdentifierPPN;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import java.util.ArrayList;
+import java.util.List;
+
+@Path("/processes")
+public class Processes {
+
+    @GET
+    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
+    public List<GoobiProcess> getProcesses() {
+        List<GoobiProcess> processes = new ArrayList<GoobiProcess>();
+
+        processes.addAll(org.goobi.webapi.models.GoobiProcess.getAllProcesses());
+
+        return processes;
+    }
+
+    @GET
+    @Path("{ppnIdentifier}")
+    public GoobiProcess getProcess(@PathParam("ppnIdentifier") IdentifierPPN ippn) {
+
+        GoobiProcess process = org.goobi.webapi.models.GoobiProcess.getProcessByPPN(ippn);
+
+        if (process == null) {
+            throw new NotFoundException("No such process.");
+        }
+
+        return process;
+    }
+
+    @GET
+    @Path("{ppnIdentifier}/steps")
+    public List<GoobiProcessStep> getProcessSteps(@PathParam("ppnIdentifier") IdentifierPPN ippn) {
+
+        List<GoobiProcessStep> resultList = org.goobi.webapi.models.GoobiProcess.getAllProcessSteps(ippn);
+
+        if (resultList.isEmpty()) {
+            throw new NotFoundException("No such process.");
+        }
+
+        return resultList;
+    }
+
+}

=== added directory 'test/src/org/goobi/webapi'
=== added directory 'test/src/org/goobi/webapi/validators'
=== added file 'test/src/org/goobi/webapi/validators/IdentifierPpnTest.java'
--- test/src/org/goobi/webapi/validators/IdentifierPpnTest.java	1970-01-01 00:00:00 +0000
+++ test/src/org/goobi/webapi/validators/IdentifierPpnTest.java	2012-07-30 13:25:24 +0000
@@ -0,0 +1,79 @@
+/*
+ * This file is part of the Goobi Application - a Workflow tool for the support of
+ * mass digitization.
+ *
+ * Visit the websites for more information.
+ *     - http://gdz.sub.uni-goettingen.de
+ *     - http://www.goobi.org
+ *     - http://launchpad.net/goobi-production
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. You
+ * should have received a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+ * Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.goobi.webapi.validators;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+public class IdentifierPpnTest {
+
+	@Test
+	public void givenValidePpnShouldCorrect() {
+		String identifier = "32578597X";
+
+		Assert.assertTrue("Given PPN " + identifier + " should be correct.", IdentifierPpn.isValid(identifier));
+	}
+
+	@Test
+	public void lowerCaseValidPpnShouldBeCorrect() {
+		String identifier = "32578597x";
+
+		Assert.assertTrue("Given lowercase PPN " + identifier + " should be correct.", IdentifierPpn.isValid(identifier));
+
+	}
+
+	@Test
+	public void invalidPpnShouldBeFalse() {
+		String identifier = "32578597A";
+
+		Assert.assertFalse("Given PPN " + identifier + " should be invalid.", IdentifierPpn.isValid(identifier));
+	}
+
+	@Test
+	public void emptyStringValueShouldBeFalse() {
+		String identifier = "";
+
+		Assert.assertFalse("Empty string value should be invalid.", IdentifierPpn.isValid(identifier));
+	}
+
+	@Test
+	public void nullValueValidatedAsFalse() {
+		String identifier = null;
+
+		Assert.assertFalse("Null value should be invalid.", IdentifierPpn.isValid(identifier));
+	}
+
+	@Test
+	public void toShortPpnShouldNotBeCorrect() {
+		String identifier = "123";
+
+		Assert.assertFalse("To short PPN " + identifier + " should be invalid.", IdentifierPpn.isValid(identifier));
+	}
+
+	@Test
+	public void toLongPpnShouldNotBeCorrect() {
+		String identifier = "1234567890";
+
+		Assert.assertFalse("To long PPN " + identifier + " should be invalid.", IdentifierPpn.isValid(identifier));
+	}
+}


Follow ups