Package org.sonar.wsclient.internal

Examples of org.sonar.wsclient.internal.HttpRequestFactory


    }
   
    public Rule getRule(UserCredentials userCredentials, String key) {
        Map<String, Object> params=new HashMap<>();
        params.put("key", key);
        HttpRequestFactory httpRequestFactory = new HttpRequestFactory(baseUrl);
        if(userCredentials != null) {
            httpRequestFactory.setLogin(userCredentials.getUsername()).setPassword(PassEncoder.decodeAsString(userCredentials.getPassword()));
        }
        String jsonRule = httpRequestFactory.get("/api/rules/show", params);
        try{
            JsonElement jsonElement = new JsonParser().parse(new StringReader(jsonRule));
            JsonObject rule = (JsonObject) ((JsonObject)jsonElement).get("rule");
            Rule rule1 = new Rule();
            rule1.setKey(rule.get("key").getAsString());
View Full Code Here


  @Rule
  public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor();

  @Before
  public void setUp() {
    requestFactory = new HttpRequestFactory(httpServer.url());
    client = new DefaultPermissionClient(requestFactory);
  }
View Full Code Here

  @Rule
  public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor();

  @Test
  public void should_create_project() {
    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());

    httpServer.stubResponseBody("{\"id\":\"1\",\"k\":\"polop\",\"nm\":\"Polop\",\"sc\":\"PRJ\",\"qu\":\"TRK\"}");

    ProjectClient client = new DefaultProjectClient(requestFactory);
    Project result = client.create(NewProject.create().key("polop").name("Polop"));
View Full Code Here

    }
  }

  @Test
  public void fail_if_null_property_key() throws Exception {
    HttpRequestFactory requestFactory = mock(HttpRequestFactory.class);
    SonarClient client = new SonarClient(requestFactory);

    try {
      client.post("api/foo", "max", 10, null, 5);
      fail();
View Full Code Here

  @Rule
  public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor();

  @Test
  public void restore_default_profiles() {
    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());

    httpServer.stubResponseBody("{\"infos\":[\"Some info\"],\"warnings\":[\"Some warnings\"]}");

    DefaultQProfileClient client = new DefaultQProfileClient(requestFactory);
    QProfileResult result = client.restoreDefault("java");
View Full Code Here

  @Rule
  public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor();

  @Test
  public void start_migration_asynchronously() {
    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
    httpServer.stubResponseBody(RUNNING_JSON);

    DefaultSystemClient client = new DefaultSystemClient(requestFactory);
    Migration migration = client.migrate();
View Full Code Here

    }
  }

  @Test
  public void stop_synchronous_migration_on_timeout() {
    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
    httpServer.stubResponseBody(RUNNING_JSON);

    DefaultSystemClient client = new DefaultSystemClient(requestFactory);
    Migration migration = client.migrate(50L, 5L);
View Full Code Here

    assertThat(migration.operationalWebapp()).isFalse();
  }

  @Test
  public void return_result_before_timeout_of_synchronous_migration() {
    HttpRequestFactory requestFactory = mock(HttpRequestFactory.class);
    when(requestFactory.post(eq("/api/server/setup"), anyMap())).thenReturn(
      RUNNING_JSON, DONE_JSON
    );

    DefaultSystemClient client = new DefaultSystemClient(requestFactory);
    Migration migration = client.migrate(500L, 5L);
View Full Code Here

  }

  @Test
  public void fail_if_missing_state() {
    // should never occur
    HttpRequestFactory requestFactory = mock(HttpRequestFactory.class);
    when(requestFactory.post(eq("/api/server/setup"), anyMap())).thenReturn(
      "{\"status\": \"ko\", \"message\": \"done\"}"
    );

    DefaultSystemClient client = new DefaultSystemClient(requestFactory);
    try {
View Full Code Here

    }
  }

  @Test
  public void restart() {
    HttpRequestFactory requestFactory = mock(HttpRequestFactory.class);
    DefaultSystemClient client = new DefaultSystemClient(requestFactory);
    client.restart();
    verify(requestFactory).post("/api/system/restart", Collections.<String, Object>emptyMap());
  }
View Full Code Here

TOP

Related Classes of org.sonar.wsclient.internal.HttpRequestFactory

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.