Package org.sonar.core.properties

Examples of org.sonar.core.properties.PropertyDto


    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();
    assertThat(property.getKey()).isEqualTo("sonar.qualitygate");
    assertThat(property.getResourceId()).isEqualTo(projectId);
    assertThat(property.getValue()).isEqualTo("42");
  }
View Full Code Here


    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();
    assertThat(property.getKey()).isEqualTo("sonar.qualitygate");
    assertThat(property.getResourceId()).isEqualTo(projectId);
    assertThat(property.getValue()).isEqualTo("42");
  }
View Full Code Here

  @Before
  public void init() {
    MockitoAnnotations.initMocks(this);

    when(dao.selectGlobalProperty(CoreProperties.PERMANENT_SERVER_ID)).thenReturn(new PropertyDto().setValue("123456789"));
    when(dao.selectGlobalProperty(CoreProperties.ORGANISATION)).thenReturn(new PropertyDto().setValue("SonarSource"));
    when(dao.selectGlobalProperty(CoreProperties.SERVER_ID_IP_ADDRESS)).thenReturn(new PropertyDto().setValue("1.2.3.4"));

    logServerId = new LogServerId(dao);
  }
View Full Code Here

  public void execute(DbSession session, AnalysisReportDto analysisReportDto, ComponentDto project) {
    propertiesDao.setProperty(newProjectPreviewCacheProperty(project), session);
  }

  private PropertyDto newProjectPreviewCacheProperty(ComponentDto project) {
    return new PropertyDto()
      .setKey(PreviewCache.SONAR_PREVIEW_CACHE_LAST_UPDATE_KEY)
      .setResourceId(project.getId())
      .setValue(String.valueOf(System.currentTimeMillis()));
  }
View Full Code Here

    checkPermission(UserSession.get());
    if (idToUseAsDefault == null) {
      propertiesDao.deleteGlobalProperty(SONAR_QUALITYGATE_PROPERTY);
    } else {
      QualityGateDto newDefault = getNonNullQgate(idToUseAsDefault);
      propertiesDao.setProperty(new PropertyDto().setKey(SONAR_QUALITYGATE_PROPERTY).setValue(newDefault.getId().toString()));
    }
  }
View Full Code Here

  public void associateProject(Long qGateId, Long projectId) {
    DbSession session = myBatis.openSession(false);
    try {
      getNonNullQgate(qGateId);
      checkPermission(UserSession.get(), projectId, session);
      propertiesDao.setProperty(new PropertyDto().setKey(SONAR_QUALITYGATE_PROPERTY).setResourceId(projectId).setValue(qGateId.toString()));
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

  private boolean isDefault(QualityGateDto qGate) {
    return qGate.getId().equals(getDefaultId());
  }

  private Long getDefaultId() {
    PropertyDto defaultQgate = propertiesDao.selectGlobalProperty(SONAR_QUALITYGATE_PROPERTY);
    if (defaultQgate == null || StringUtils.isBlank(defaultQgate.getValue())) {
      return null;
    } else {
      return Long.valueOf(defaultQgate.getValue());
    }
  }
View Full Code Here

  @Test
  public void return_global_settings() throws Exception {
    MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.SCAN_EXECUTION, GlobalPermissions.DRY_RUN_EXECUTION);

    when(propertiesDao.selectGlobalProperties(session)).thenReturn(newArrayList(
      new PropertyDto().setKey("foo").setValue("bar"),
      new PropertyDto().setKey("foo.secured").setValue("1234"),
      new PropertyDto().setKey("foo.license.secured").setValue("5678")
    ));

    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
    request.execute().assertJson(getClass(), "return_global_settings.json");
  }
View Full Code Here

  @Test
  public void return_only_license_settings_without_scan_but_with_preview_permission() throws Exception {
    MockUserSession.set().setLogin("john").setGlobalPermissions(GlobalPermissions.DRY_RUN_EXECUTION);

    when(propertiesDao.selectGlobalProperties(session)).thenReturn(newArrayList(
      new PropertyDto().setKey("foo").setValue("bar"),
      new PropertyDto().setKey("foo.secured").setValue("1234"),
      new PropertyDto().setKey("foo.license.secured").setValue("5678")
    ));

    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
    request.execute().assertJson(getClass(), "return_only_license_settings_without_scan_but_with_preview_permission.json");
  }
View Full Code Here

  @Test
  public void return_no_secured_settings_without_scan_and_preview_permission() throws Exception {
    MockUserSession.set().setLogin("john").setGlobalPermissions();

    when(propertiesDao.selectGlobalProperties(session)).thenReturn(newArrayList(
      new PropertyDto().setKey("foo").setValue("bar"),
      new PropertyDto().setKey("foo.secured").setValue("1234"),
      new PropertyDto().setKey("foo.license.secured").setValue("5678")
    ));

    WsTester.TestRequest request = tester.newGetRequest("batch", "global");
    request.execute().assertJson(getClass(), "return_no_secured_settings_without_scan_and_preview_permission.json");
  }
View Full Code Here

TOP

Related Classes of org.sonar.core.properties.PropertyDto

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.