Permalink
Browse files

APPNG-2201 support digest when creating a repository

  • Loading branch information...
madness-inc committed Jul 24, 2018
1 parent 5309cfb commit 8ec55d6d8455d9e5e8608926d1c56c56a77e2e7f
@@ -43,7 +43,8 @@
* The repository description.
* -e
* Enable repository.
* Default: true
* -g
* The digest for the repository.
* -m
* The repository mode (ALL, STABLE, SNAPSHOT).
* Default: ALL
@@ -88,6 +89,9 @@
@Parameter(names = "-r", required = false, description = "The name of the remote repository (required for repository type REMOTE).")
private String remoteRepositoryName;
@Parameter(names = "-g", required = false, description = "The digest for the repository.")
private String digest;
@Parameter(names = "-e", description = "Enable repository.", arity = 1)
private boolean isActive = true;
@@ -103,7 +107,8 @@ public CreateRepository() {
public void execute(CliEnvironment cle) throws BusinessException {
try {
if (type.equals(RepositoryType.REMOTE) && StringUtils.isBlank(remoteRepositoryName)) {
boolean isRemote = RepositoryType.REMOTE.equals(type);
if (isRemote && StringUtils.isBlank(remoteRepositoryName)) {
throw new BusinessException("The missing parameter -r must contain the name of the remote repository.");
}
URI uri = new URI(uriString);
@@ -127,9 +132,13 @@ public void execute(CliEnvironment cle) throws BusinessException {
repository.setDescription(description);
repository.setRepositoryType(type);
repository.setRepositoryMode(mode);
repository.setRemoteRepositoryName(remoteRepositoryName);
if (isRemote) {
repository.setRemoteRepositoryName(remoteRepositoryName);
} else {
repository.setPublished(isPublished);
}
repository.setDigest(digest);
repository.setActive(isActive);
repository.setPublished(isPublished);
repository.setStrict(isStrict);
repository.setUri(uri);
@@ -18,12 +18,14 @@
import java.io.File;
import java.net.URI;
import org.appng.api.BusinessException;
import org.appng.cli.ExecutableCliCommand;
import org.appng.cli.commands.AbstractCommandTest;
import org.appng.core.model.Repository;
import org.appng.core.model.RepositoryMode;
import org.appng.core.model.RepositoryType;
import org.junit.Assert;
import org.junit.Test;
public class CommandCreateRepositoryTest extends AbstractCommandTest {
@@ -46,6 +48,29 @@ public void validate() {
Assert.assertTrue(repo.isActive());
Assert.assertFalse(repo.isPublished());
Assert.assertFalse(repo.isStrict());
Assert.assertNull(repo.getRemoteRepositoryName());
}
@Test
public void testCreateRemote() throws BusinessException {
String remoteUrl = "https://appng.org/service/manager/appng-manager/soap/repositoryService";
String[] args = new String[] { "-n", "remoterepo", "-d", "a remote repository", "-g", "digest", "-t",
RepositoryType.REMOTE.name(), "-r", "appNG-Stable", "-m", RepositoryMode.ALL.name(), "-u",
remoteUrl };
parse(new CreateRepository(), args).execute(cliEnv);
Repository repo = cliEnv.getCoreService().getApplicationRepositoryByName("remoterepo");
Assert.assertEquals("remoterepo", repo.getName());
Assert.assertEquals("a remote repository", repo.getDescription());
Assert.assertEquals("appNG-Stable", repo.getRemoteRepositoryName());
Assert.assertEquals(RepositoryMode.ALL, repo.getRepositoryMode());
Assert.assertEquals(RepositoryType.REMOTE, repo.getRepositoryType());
Assert.assertEquals(remoteUrl, repo.getUri().toString());
Assert.assertEquals("digest", repo.getDigest());
Assert.assertTrue(repo.isActive());
Assert.assertFalse(repo.isPublished());
Assert.assertFalse(repo.isStrict());
}
}

0 comments on commit 8ec55d6

Please sign in to comment.