Package org.sonatype.nexus.rest.model

Examples of org.sonatype.nexus.rest.model.RepositoryRouteResource


  {
    // EXPLANATION
    // When no groupId sent with route, Nexus _defaults_ it to '*', meaning
    // all repositories to "mimic" the pre-this-change behaviour

    RepositoryRouteResource resource = new RepositoryRouteResource();
    // resource.setGroupId( "nexus-test" );
    resource.setPattern(".*createNoGroupIdTest.*");
    resource.setRuleType("exclusive");

    RepositoryRouteMemberRepository memberRepo1 = new RepositoryRouteMemberRepository();
    memberRepo1.setId("nexus-test-harness-repo");
    resource.addRepository(memberRepo1);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    String responseText = response.getEntity().getText();
    if (response.getStatus().getCode() != 201 || !responseText.contains("<groupId>*</groupId>")) {
View Full Code Here


  @Test
  public void createNoRuleTypeTest()
      throws IOException
  {

    RepositoryRouteResource resource = new RepositoryRouteResource();
    resource.setGroupId("nexus-test");
    resource.setPattern(".*createNoRuleTypeTest.*");
    // resource.setRuleType( "exclusive" );

    RepositoryRouteMemberRepository memberRepo1 = new RepositoryRouteMemberRepository();
    memberRepo1.setId("nexus-test-harness-repo");
    resource.addRepository(memberRepo1);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    String responseText = response.getEntity().getText();
    if (response.getStatus().getCode() != 400) {
View Full Code Here

  @Test
  public void createNoPatternTest()
      throws IOException
  {
    RepositoryRouteResource resource = new RepositoryRouteResource();
    resource.setGroupId("nexus-test");
    // resource.setPattern( ".*createNoPatternTest.*" );
    resource.setRuleType("exclusive");

    RepositoryRouteMemberRepository memberRepo1 = new RepositoryRouteMemberRepository();
    memberRepo1.setId("nexus-test-harness-repo");
    resource.addRepository(memberRepo1);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    String responseText = response.getEntity().getText();
    if (response.getStatus().getCode() != 400) {
View Full Code Here

  @Test
  public void createWithInvalidPatternTest()
      throws IOException
  {
    RepositoryRouteResource resource = new RepositoryRouteResource();
    resource.setGroupId("nexus-test");
    resource.setPattern("*.createWithInvalidPatternTest.*");
    resource.setRuleType("exclusive");

    RepositoryRouteMemberRepository memberRepo1 = new RepositoryRouteMemberRepository();
    memberRepo1.setId("nexus-test-harness-repo");
    resource.addRepository(memberRepo1);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    String responseText = response.getEntity().getText();
    if (response.getStatus().getCode() != 400) {
View Full Code Here

  @Test
  public void createWithInvalidGroupTest()
      throws IOException
  {
    RepositoryRouteResource resource = new RepositoryRouteResource();
    resource.setGroupId("INVALID");
    resource.setPattern("*.createWithInvalidPatternTest.*");
    resource.setRuleType("exclusive");

    RepositoryRouteMemberRepository memberRepo1 = new RepositoryRouteMemberRepository();
    memberRepo1.setId("nexus-test-harness-repo");
    resource.addRepository(memberRepo1);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    String responseText = response.getEntity().getText();
    if (response.getStatus().getCode() != 400) {
View Full Code Here

  @Test
  public void createWithInvalidRuleTypeTest()
      throws IOException
  {

    RepositoryRouteResource resource = new RepositoryRouteResource();
    resource.setGroupId("nexus-test");
    resource.setPattern("*.createWithInvalidRuleTypeTest.*");
    resource.setRuleType("createWithInvalidRuleTypeTest");

    RepositoryRouteMemberRepository memberRepo1 = new RepositoryRouteMemberRepository();
    memberRepo1.setId("nexus-test-harness-repo");
    resource.addRepository(memberRepo1);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    String responseText = response.getEntity().getText();
    if (response.getStatus().getCode() != 400) {
View Full Code Here

  @Test
  public void createNoReposTest()
      throws IOException
  {
    RepositoryRouteResource resource = new RepositoryRouteResource();
    resource.setGroupId("nexus-test");
    resource.setPattern("*.createWithInvalidRuleTypeTest.*");
    resource.setRuleType("exclusive");

    // RepositoryRouteMemberRepository memberRepo1 = new RepositoryRouteMemberRepository();
    // memberRepo1.setId( "nexus-test-harness-repo" );
    // resource.addRepository( memberRepo1 );

View Full Code Here

  @Test
  public void createWithInvalidReposTest()
      throws IOException
  {
    RepositoryRouteResource resource = new RepositoryRouteResource();
    resource.setGroupId("nexus-test");
    resource.setPattern("*.createWithInvalidRuleTypeTest.*");
    resource.setRuleType("exclusive");

    RepositoryRouteMemberRepository memberRepo1 = new RepositoryRouteMemberRepository();
    memberRepo1.setId("INVALID");
    resource.addRepository(memberRepo1);

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    String responseText = response.getEntity().getText();
    if (response.getStatus().getCode() != 400) {
View Full Code Here

  @SuppressWarnings("unchecked")
  private RepositoryRouteResource runCreateTest(String ruleType)
      throws IOException
  {
    RepositoryRouteResource resource = new RepositoryRouteResource();
    resource.setGroupId("nexus-test");
    resource.setPattern(".*" + ruleType + ".*");
    resource.setRuleType(ruleType);

    if (!"blocking".equals(ruleType)) {
      RepositoryRouteMemberRepository memberRepo1 = new RepositoryRouteMemberRepository();
      memberRepo1.setId("nexus-test-harness-repo");
      resource.addRepository(memberRepo1);
    }

    Response response = this.messageUtil.sendMessage(Method.POST, resource);

    if (!response.getStatus().isSuccess()) {
      String responseText = response.getEntity().getText();
      try {
        Assert.fail("Could not create privilege: " + response.getStatus() + "\nresponse:\n" + responseText);
      }
      catch (NullPointerException e) {
        Assert.fail(new XStream().toXML(response));
      }
    }

    // get the Resource object
    RepositoryRouteResource resourceResponse = this.messageUtil.getResourceFromResponse(response);

    Assert.assertNotNull(resourceResponse.getId());

    Assert.assertEquals(resourceResponse.getGroupId(), resource.getGroupId());
    Assert.assertEquals(resourceResponse.getPattern(), resource.getPattern());
    Assert.assertEquals(resourceResponse.getRuleType(), resource.getRuleType());
    this.messageUtil.validateSame(resource.getRepositories(), resourceResponse.getRepositories());

    // now check the nexus config
    this.messageUtil.validateRoutesConfig(resourceResponse);

    return resourceResponse;
View Full Code Here

  @Test
  public void readTest()
      throws IOException
  {
    // create
    RepositoryRouteResource resource = this.runCreateTest("exclusive");

    Response response = this.messageUtil.sendMessage(Method.GET, resource);

    if (!response.getStatus().isSuccess()) {
      String responseText = response.getEntity().getText();
      Assert.fail("Could not create privilege: " + response.getStatus() + "\nresponse:\n" + responseText);
    }

    // get the Resource object
    RepositoryRouteResource resourceResponse = this.messageUtil.getResourceFromResponse(response);

    Assert.assertNotNull(resourceResponse.getId());

    Assert.assertEquals(resourceResponse.getGroupId(), resource.getGroupId());
    Assert.assertEquals(resourceResponse.getPattern(), resource.getPattern());
    Assert.assertEquals(resourceResponse.getRuleType(), resource.getRuleType());
    this.messageUtil.validateSame(resource.getRepositories(), resourceResponse.getRepositories());

    // now check the nexus config
    this.messageUtil.validateRoutesConfig(resourceResponse);

  }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.rest.model.RepositoryRouteResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.