Package org.sonar.core.qualitygate.db

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


  @Test
  public void should_get_qgate_by_id() throws Exception {
    long id = 42L;
    final String name = "Golden";
    QualityGateDto existing = new QualityGateDto().setId(id).setName(name);
    when(dao.selectById(id)).thenReturn(existing);
    assertThat(qGates.get(id)).isEqualTo(existing);
    verify(dao).selectById(id);
  }
View Full Code Here


  @Test
  public void should_get_qgate_by_name() throws Exception {
    long id = 42L;
    final String name = "Golden";
    QualityGateDto existing = new QualityGateDto().setId(id).setName(name);
    when(dao.selectByName(name)).thenReturn(existing);
    assertThat(qGates.get(name)).isEqualTo(existing);
    verify(dao).selectByName(name);
  }
View Full Code Here

  @Test
  public void should_rename_qgate() throws Exception {
    long id = 42L;
    String name = "SG-1";
    QualityGateDto existing = new QualityGateDto().setId(id).setName("Golden");
    when(dao.selectById(id)).thenReturn(existing);
    QualityGateDto sg1 = qGates.rename(id, name);
    assertThat(sg1.getName()).isEqualTo(name);
    verify(dao).selectById(id);
    verify(dao).selectByName(name);
    verify(dao).update(sg1);
  }
View Full Code Here

  @Test
  public void should_allow_rename_with_same_name() throws Exception {
    long id = 42L;
    String name = "SG-1";
    QualityGateDto existing = new QualityGateDto().setId(id).setName(name);
    when(dao.selectById(id)).thenReturn(existing);
    QualityGateDto sg1 = qGates.rename(id, name);
    assertThat(sg1.getName()).isEqualTo(name);
    verify(dao).selectById(id);
    verify(dao).selectByName(name);
    verify(dao).update(sg1);
  }
View Full Code Here

  @Test(expected = BadRequestException.class)
  public void should_fail_rename_on_duplicate_name() throws Exception {
    long id = 42L;
    String name = "SG-1";
    QualityGateDto existing = new QualityGateDto().setId(id).setName("Golden");
    when(dao.selectById(id)).thenReturn(existing);
    when(dao.selectByName(name)).thenReturn(new QualityGateDto().setId(666L).setName(name));
    qGates.rename(id, name);
  }
View Full Code Here

  @Test
  public void should_select_default_qgate() throws Exception {
    long defaultId = 42L;
    String defaultName = "Default Name";
    when(dao.selectById(defaultId)).thenReturn(new QualityGateDto().setId(defaultId).setName(defaultName));
    qGates.setDefault(defaultId);
    verify(dao).selectById(defaultId);
    ArgumentCaptor<PropertyDto> propertyCaptor = ArgumentCaptor.forClass(PropertyDto.class);
    verify(propertiesDao).setProperty(propertyCaptor.capture());
    assertThat(propertyCaptor.getValue().getKey()).isEqualTo("sonar.qualitygate");
View Full Code Here

  @Test
  public void should_delete_qgate() throws Exception {
    long idToDelete = 42L;
    String name = "To Delete";
    QualityGateDto toDelete = new QualityGateDto().setId(idToDelete).setName(name);
    when(dao.selectById(idToDelete)).thenReturn(toDelete);
    DbSession session = mock(DbSession.class);
    when(myBatis.openSession(false)).thenReturn(session);
    qGates.delete(idToDelete);
    verify(dao).selectById(idToDelete);
View Full Code Here

  @Test
  public void should_delete_qgate_if_non_default() throws Exception {
    long idToDelete = 42L;
    String name = "To Delete";
    QualityGateDto toDelete = new QualityGateDto().setId(idToDelete).setName(name);
    when(dao.selectById(idToDelete)).thenReturn(toDelete);
    when(propertiesDao.selectGlobalProperty("sonar.qualitygate")).thenReturn(new PropertyDto().setValue("666"));
    DbSession session = mock(DbSession.class);
    when(myBatis.openSession(false)).thenReturn(session);
    qGates.delete(idToDelete);
View Full Code Here

  @Test
  public void should_delete_qgate_even_if_default() throws Exception {
    long idToDelete = 42L;
    String name = "To Delete";
    QualityGateDto toDelete = new QualityGateDto().setId(idToDelete).setName(name);
    when(dao.selectById(idToDelete)).thenReturn(toDelete);
    when(propertiesDao.selectGlobalProperty("sonar.qualitygate")).thenReturn(new PropertyDto().setValue("42"));
    DbSession session = mock(DbSession.class);
    when(myBatis.openSession(false)).thenReturn(session);
    qGates.delete(idToDelete);
View Full Code Here

  @Test
  public void should_return_default_qgate_if_set() throws Exception {
    String defaultName = "Sonar way";
    long defaultId = 42L;
    when(propertiesDao.selectGlobalProperty("sonar.qualitygate")).thenReturn(new PropertyDto().setValue(Long.toString(defaultId)));
    QualityGateDto defaultQgate = new QualityGateDto().setId(defaultId).setName(defaultName);
    when(dao.selectById(defaultId)).thenReturn(defaultQgate);
    assertThat(qGates.getDefault()).isEqualTo(defaultQgate);
  }
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.