From 8cb715014c813150c87b1f4d7579f23ebf7fc560 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Wed, 5 Dec 2018 15:00:00 +0000 Subject: [PATCH] More concise handling of optional `migratedFromId` in test --- .../state/SnapshotAPIStateBuilder.java | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIStateBuilder.java b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIStateBuilder.java index cdc305f2c6..179985f1ea 100644 --- a/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIStateBuilder.java +++ b/services/git-bridge/src/main/java/uk/ac/ic/wlgitbridge/snapshot/servermock/state/SnapshotAPIStateBuilder.java @@ -83,30 +83,21 @@ public class SnapshotAPIStateBuilder { String projectName, JsonObject jsonGetDoc ) { + String migratedFromId = null; if (jsonGetDoc.has("migratedFromId")) { - getDoc.put( - projectName, - new GetDocResult( - jsonGetDoc.get("error"), - jsonGetDoc.get("versionID").getAsInt(), - jsonGetDoc.get("createdAt").getAsString(), - jsonGetDoc.get("email").getAsString(), - jsonGetDoc.get("name").getAsString(), - jsonGetDoc.get("migratedFromId").getAsString() - ) - ); - } else { - getDoc.put( - projectName, - new GetDocResult( - jsonGetDoc.get("error"), - jsonGetDoc.get("versionID").getAsInt(), - jsonGetDoc.get("createdAt").getAsString(), - jsonGetDoc.get("email").getAsString(), - jsonGetDoc.get("name").getAsString() - ) - ); + migratedFromId = jsonGetDoc.get("migratedFromId").getAsString(); } + getDoc.put( + projectName, + new GetDocResult( + jsonGetDoc.get("error"), + jsonGetDoc.get("versionID").getAsInt(), + jsonGetDoc.get("createdAt").getAsString(), + jsonGetDoc.get("email").getAsString(), + jsonGetDoc.get("name").getAsString(), + migratedFromId + ) + ); } private void addGetSavedVersForProject(