Package org.sonar.core.qualitygate.db

Examples of org.sonar.core.qualitygate.db.QualityGateDto


    long qGateId = 42L;
    final Metric metric = mock(Metric.class);
    when(metric.getKey()).thenReturn("new_coverage");
    when(metric.getType()).thenReturn(ValueType.BOOL);
    when(metricFinder.findByKey(anyString())).thenReturn(metric);
    when(dao.selectById(qGateId)).thenReturn(new QualityGateDto().setId(qGateId));
    qGates.createCondition(qGateId, "alert_status", "EQ", null, "90", 6);
  }
View Full Code Here


  @Test
  public void should_associate_project() {
    Long qGateId = 42L;
    Long projectId = 24L;
    when(dao.selectById(qGateId)).thenReturn(new QualityGateDto().setId(qGateId));
    qGates.associateProject(qGateId, projectId);
    verify(dao).selectById(qGateId);
    ArgumentCaptor<PropertyDto> propertyCaptor = ArgumentCaptor.forClass(PropertyDto.class);
    verify(propertiesDao).setProperty(propertyCaptor.capture());
    PropertyDto property = propertyCaptor.getValue();
View Full Code Here

  public void associate_project_with_project_admin_permission() {
    UserSessionTestUtils.setUserSession(authorizedProjectAdminUserSession);

    Long qGateId = 42L;
    Long projectId = 24L;
    when(dao.selectById(qGateId)).thenReturn(new QualityGateDto().setId(qGateId));
    qGates.associateProject(qGateId, projectId);
    verify(dao).selectById(qGateId);
    ArgumentCaptor<PropertyDto> propertyCaptor = ArgumentCaptor.forClass(PropertyDto.class);
    verify(propertiesDao).setProperty(propertyCaptor.capture());
    PropertyDto property = propertyCaptor.getValue();
View Full Code Here

  @Test
  public void should_dissociate_project() {
    Long qGateId = 42L;
    Long projectId = 24L;
    when(dao.selectById(qGateId)).thenReturn(new QualityGateDto().setId(qGateId));
    qGates.dissociateProject(qGateId, projectId);
    verify(dao).selectById(qGateId);
    verify(propertiesDao).deleteProjectProperty("sonar.qualitygate", projectId);
  }
View Full Code Here

  public void dissociate_project_with_project_admin_permission() {
    UserSessionTestUtils.setUserSession(authorizedProjectAdminUserSession);

    Long qGateId = 42L;
    Long projectId = 24L;
    when(dao.selectById(qGateId)).thenReturn(new QualityGateDto().setId(qGateId));
    qGates.dissociateProject(qGateId, projectId);
    verify(dao).selectById(qGateId);
    verify(propertiesDao).deleteProjectProperty("sonar.qualitygate", projectId);
  }
View Full Code Here

    long metric2Id = 2L;
    QualityGateConditionDto cond1 = new QualityGateConditionDto().setMetricId(metric1Id);
    QualityGateConditionDto cond2 = new QualityGateConditionDto().setMetricId(metric2Id);
    Collection<QualityGateConditionDto> conditions = ImmutableList.of(cond1, cond2);

    when(dao.selectById(sourceId)).thenReturn(new QualityGateDto().setId(sourceId).setName("SG-1"));
    DbSession session = mock(DbSession.class);
    when(myBatis.openSession(false)).thenReturn(session);
    Mockito.doAnswer(new Answer<Object>() {
      @Override
      public Object answer(InvocationOnMock invocation) throws Throwable {
        ((QualityGateDto) invocation.getArguments()[0]).setId(destId);
        return null;
      }
    }).when(dao).insert(any(QualityGateDto.class), eq(session));
    when(conditionDao.selectForQualityGate(anyLong(), eq(session))).thenReturn(conditions);
    QualityGateDto atlantis = qGates.copy(sourceId, name);
    assertThat(atlantis.getName()).isEqualTo(name);
    verify(dao).selectByName(name);
    verify(dao).insert(atlantis, session);
    verify(conditionDao).selectForQualityGate(anyLong(), eq(session));
    verify(conditionDao, times(conditions.size())).insert(any(QualityGateConditionDto.class), eq(session));
  }
View Full Code Here

  @Test
  public void should_register_default_gate() {
    String templateType = "QUALITY_GATE";
    String templateName = "SonarQube way";
    when(templateDao.countByTypeAndKey(templateType, templateName)).thenReturn(0);
    when(qualityGates.create(templateName)).thenReturn(new QualityGateDto().setId(42L));

    task.start();

    verify(templateDao).countByTypeAndKey(templateType, templateName);
    verify(qualityGates).create(templateName);
View Full Code Here

  }

  public QualityGateDto create(String name) {
    checkPermission(UserSession.get());
    validateQualityGate(null, name);
    QualityGateDto newQualityGate = new QualityGateDto().setName(name);
    dao.insert(newQualityGate);
    return newQualityGate;
  }
View Full Code Here

    return getNonNullQgate(qGateName);
  }

  public QualityGateDto rename(long idToRename, String name) {
    checkPermission(UserSession.get());
    QualityGateDto toRename = getNonNullQgate(idToRename);
    validateQualityGate(idToRename, name);
    toRename.setName(name);
    dao.update(toRename);
    return toRename;
  }
View Full Code Here

    JsonWriter writer = response.newJsonWriter().beginObject().name("qualitygates").beginArray();
    for (QualityGateDto qgate : qualityGates.list()) {
      QGatesWs.writeQualityGate(qgate, writer);
    }
    writer.endArray();
    QualityGateDto defaultQgate = qualityGates.getDefault();
    if (defaultQgate != null) {
      writer.prop("default", defaultQgate.getId());
    }
    writer.endObject().close();
  }
View Full Code Here

TOP

Related Classes of org.sonar.core.qualitygate.db.QualityGateDto

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.