### Question:
DistroHelper { public static Artifact parseDistroArtifact(String distro, VersionsHelper versionsHelper) throws MojoExecutionException { String[] split = distro.split(":"); if (split.length > 3) { throw new MojoExecutionException("Invalid distro: " + distro); } String groupId = split.length == 3 ? split[0] : Artifact.GROUP_DISTRO; String artifactId = split[split.length - 2]; String version = split[split.length - 1]; if (versionsHelper != null && version.contains(SDKConstants.LATEST_VERSION_BATCH_KEYWORD)) { if (version.toLowerCase().equals(SDKConstants.LATEST_SNAPSHOT_BATCH_KEYWORD.toLowerCase())) { version = versionsHelper.getLatestSnapshotVersion(new Artifact(artifactId, version, groupId)); } else if (version.toLowerCase().equals((SDKConstants.LATEST_VERSION_BATCH_KEYWORD).toLowerCase())) { version = versionsHelper.getLatestReleasedVersion(new Artifact(artifactId, version, groupId)); } } Artifact artifact = new Artifact(inferDistroArtifactId(artifactId, groupId), version, groupId); if(artifact.getGroupId().equals(Artifact.GROUP_MODULE)){ artifact.setArtifactId(artifact.getArtifactId()+"-omod"); } return artifact; } DistroHelper(MavenProject mavenProject, MavenSession mavenSession, BuildPluginManager pluginManager, Wizard wizard); static DistroProperties getDistroPropertiesFromDir(); static DistroProperties getDistroPropertiesFromFile(File distroFile); void savePropertiesToServer(DistroProperties properties, Server server); static Artifact parseDistroArtifact(String distro, VersionsHelper versionsHelper); static boolean isRefapp2_3_1orLower(String artifactId, String version); static boolean isRefapp2_3_1orLower(Artifact artifact); static boolean isRefappBelow2_1(String artifactId, String version); static boolean isRefappBelow2_1(Artifact artifact); File downloadDistro(File path, Artifact artifact); File extractFileFromDistro(File path, Artifact artifact, String filename); DistroProperties downloadDistroProperties(File path, Artifact artifact); DistroProperties downloadDistroProperties(File serverPath, Server server); DistroProperties retrieveDistroProperties(String distro, VersionsHelper versionsHelper); void saveDistroPropertiesTo(File destination, String distro); static UpgradeDifferential calculateUpdateDifferential(DistroHelper distroHelper, Server server, DistroProperties distroProperties);  }### Answer:
@Test public void parseDistroArtifactShouldInferArtifactIdForRefapp() throws Exception{ String distro = "referenceapplication:2.3"; Artifact artifact = DistroHelper.parseDistroArtifact(distro, null); assertThat(artifact.getGroupId(), is(Artifact.GROUP_DISTRO)); assertThat(artifact.getArtifactId(), is(SDKConstants.REFERENCEAPPLICATION_ARTIFACT_ID)); }
@Test public void parseDistroArtifactShouldSetDefaultGroupIdIfNotSpecified() throws Exception{ String distro = "otherdistro:2.3"; Artifact artifact = DistroHelper.parseDistroArtifact(distro, null); assertThat(artifact.getGroupId(), is(Artifact.GROUP_DISTRO)); }
@Test(expected = MojoExecutionException.class) public void parseDistroArtifactShouldReturnNullIfInvalidFormat() throws Exception{ String distro = "referenceapplication:2.3:fsf:444"; DistroHelper.parseDistroArtifact(distro, null); }
@Test public void parseDistroArtifactShouldCreateProperArtifact() throws Exception{ String distro = "org.openmrs.distromock:refapp:2.3"; Artifact artifact = DistroHelper.parseDistroArtifact(distro, null); assertThat(artifact.getGroupId(), is("org.openmrs.distromock")); assertThat(artifact.getArtifactId(), is("refapp")); assertThat(artifact.getVersion(), is("2.3")); }