Package org.sonar.server.ws

Examples of org.sonar.server.ws.WsTester$TestResponse$TestStream


  @Mock
  RuleService ruleService;

  @Before
  public void setUp() throws Exception {
    tester = new WsTester(new RulesWebService(mock(SearchAction.class), mock(ShowAction.class), mock(TagsAction.class), mock(CreateAction.class), mock(AppAction.class),
      mock(UpdateAction.class), new DeleteAction(ruleService)));
  }
View Full Code Here


      mock(ActionPlanService.class), mock(UserFinder.class),
      debtModelService, mock(RuleService.class), i18n, durations);
    SearchAction searchAction = new SearchAction(mock(DbClient.class), mock(IssueChangeDao.class), mock(IssueService.class), mock(IssueActionsWriter.class),
      mock(IssueQueryService.class), mock(RuleService.class),
      mock(ActionPlanService.class), mock(UserFinder.class), mock(I18n.class), mock(Durations.class), mock(Languages.class));
    tester = new WsTester(new IssuesWs(showAction, searchAction));
  }
View Full Code Here

  QProfileLoader profileLoader;

  @Test
  public void should_generate_app_init_info() throws Exception {
    AppAction app = new AppAction(languages, ruleRepositories, i18n, debtModel, profileLoader);
    WsTester tester = new WsTester(new RulesWebService(
      mock(SearchAction.class), mock(ShowAction.class), mock(TagsAction.class), mock(CreateAction.class),
      app, mock(UpdateAction.class), mock(DeleteAction.class)));

    MockUserSession.set().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);

    QualityProfileDto profile1 = QProfileTesting.newXooP1();
    QualityProfileDto profile2 = QProfileTesting.newXooP2().setParentKee(QProfileTesting.XOO_P1_KEY);
    when(profileLoader.findAll()).thenReturn(ImmutableList.of(profile1, profile2));

    Language xoo = mock(Language.class);
    when(xoo.getKey()).thenReturn("xoo");
    when(xoo.getName()).thenReturn("Xoo");
    Language whitespace = mock(Language.class);
    when(whitespace.getKey()).thenReturn("ws");
    when(whitespace.getName()).thenReturn("Whitespace");
    when(languages.get("xoo")).thenReturn(xoo);
    when(languages.all()).thenReturn(new Language[]{xoo, whitespace});

    RuleRepositories.Repository repo1 = mock(RuleRepositories.Repository.class);
    when(repo1.key()).thenReturn("xoo");
    when(repo1.name()).thenReturn("SonarQube");
    when(repo1.language()).thenReturn("xoo");
    RuleRepositories.Repository repo2 = mock(RuleRepositories.Repository.class);
    when(repo2.key()).thenReturn("squid");
    when(repo2.name()).thenReturn("SonarQube");
    when(repo2.language()).thenReturn("ws");
    when(ruleRepositories.repositories()).thenReturn(ImmutableList.of(repo1, repo2));

    when(i18n.message(isA(Locale.class), anyString(), anyString())).thenAnswer(new Answer<String>() {
      @Override
      public String answer(InvocationOnMock invocation) throws Throwable {
        return (String) invocation.getArguments()[1];
      }
    });

    int parentId = 42;
    DefaultDebtCharacteristic char1 = new DefaultDebtCharacteristic();
    char1.setId(parentId).setKey("REUSABILITY").setName("Reusability");
    DefaultDebtCharacteristic char2 = new DefaultDebtCharacteristic();
    char2.setId(24).setParentId(parentId).setKey("MODULARITY").setName("Modularity");
    when(debtModel.allCharacteristics()).thenReturn(ImmutableList.<DebtCharacteristic>of(char1, char2));

    tester.newGetRequest("api/rules", "app").execute().assertJson(this.getClass(), "app.json");
  }
View Full Code Here

  WebService.Controller controller;

  @Before
  public void setUp() throws Exception {
    WsTester tester = new WsTester(new ComponentsWs(new ComponentAppAction(mock(DbClient.class), mock(IssueService.class), mock(Views.class),
      mock(RuleService.class), mock(Periods.class), mock(Durations.class), mock(I18n.class))));
    controller = tester.controller("api/components");
  }
View Full Code Here

    when(issueService.findSeveritiesByComponent(anyString(), any(Date.class), eq(session))).thenReturn(mock(Multiset.class));
    when(issueService.findRulesByComponent(anyString(), any(Date.class), eq(session))).thenReturn(mock(RulesAggregation.class));
    when(measureDao.findByComponentKeyAndMetricKeys(anyString(), anyListOf(String.class), eq(session))).thenReturn(measures);

    tester = new WsTester(new ComponentsWs(new ComponentAppAction(dbClient, issueService, views, ruleService, periods, durations, i18n)));
  }
View Full Code Here

  WsTester tester;

  @Before
  public void setUp() throws Exception {
    when(dbClient.openSession(false)).thenReturn(session);
    tester = new WsTester(new DuplicationsWs(new ShowAction(dbClient, componentDao, measureDao, parser, duplicationsJsonWriter)));
  }
View Full Code Here

  WsTester tester;

  @Before
  public void setUp() {
    tester = new WsTester(new ProfilesWs());
  }
View Full Code Here

    issueCreationDate = DateUtils.parseDateTime("2014-01-22T19:10:03+0100");
    when(i18n.formatDateTime(any(Locale.class), eq(issueCreationDate))).thenReturn("Jan 22, 2014 10:03 AM");

    when(i18n.message(any(Locale.class), eq("created"), eq((String) null))).thenReturn("Created");

    tester = new WsTester(new IssuesWs(
      new IssueShowAction(dbClient, issueService, issueChangelogService, commentService,
        new IssueActionsWriter(issueService, actionService), actionPlanService, userFinder, debtModel, ruleService, i18n, durations),
      new SearchAction(mock(DbClient.class), mock(IssueChangeDao.class), mock(IssueService.class), mock(IssueActionsWriter.class), mock(IssueQueryService.class),
        mock(RuleService.class),
        mock(ActionPlanService.class), mock(UserFinder.class), mock(I18n.class), mock(Durations.class), mock(Languages.class))));
View Full Code Here

  @Before
  public void setUp() throws Exception {
    when(dbClient.componentDao()).thenReturn(componentDao);
    when(dbClient.openSession(false)).thenReturn(session);
    tester = new WsTester(new SourcesWs(mock(ShowAction.class), new RawAction(dbClient, sourceService), mock(ScmAction.class)));
  }
View Full Code Here

  WebService.Controller controller;

  @Before
  public void setUp() throws Exception {
    WsTester tester = new WsTester(new TimeMachineWs());
    controller = tester.controller("api/timemachine");
  }
View Full Code Here

TOP

Related Classes of org.sonar.server.ws.WsTester$TestResponse$TestStream

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.