Package org.sonar.api.server.debt

Examples of org.sonar.api.server.debt.DebtCharacteristic


  @CheckForNull
  private static RuleDebt toRuleDebt(RuleDto rule, DebtModel debtModel) {
    RuleDebt ruleDebt = new RuleDebt().setRuleKey(RuleKey.of(rule.getRepositoryKey(), rule.getRuleKey()));
    Integer effectiveSubCharacteristicId = rule.getSubCharacteristicId() != null ? rule.getSubCharacteristicId() : rule.getDefaultSubCharacteristicId();
    DebtCharacteristic subCharacteristic = (effectiveSubCharacteristicId != null && !RuleDto.DISABLED_CHARACTERISTIC_ID.equals(effectiveSubCharacteristicId)) ?
      debtModel.characteristicById(effectiveSubCharacteristicId) : null;
    if (subCharacteristic != null) {
      ruleDebt.setSubCharacteristicKey(subCharacteristic.key());

      String overriddenFunction = rule.getRemediationFunction();
      String defaultFunction = rule.getDefaultRemediationFunction();
      if (overriddenFunction != null) {
        ruleDebt.setFunction(overriddenFunction);
View Full Code Here


    when(dao.selectEnabledRootCharacteristics(session)).thenReturn(newArrayList(
      new CharacteristicDto().setId(2).setKey("PORTABILITY").setOrder(1),
      new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2)
    ));

    DebtCharacteristic result = service.moveUp(10);

    verify(dao, times(2)).update(characteristicCaptor.capture(), eq(session));

    assertThat(result.order()).isEqualTo(1);
    assertThat(characteristicCaptor.getAllValues().get(0).getOrder()).isEqualTo(2);
    assertThat(characteristicCaptor.getAllValues().get(0).getUpdatedAt()).isEqualTo(now);
    assertThat(characteristicCaptor.getAllValues().get(1).getOrder()).isEqualTo(1);
    assertThat(characteristicCaptor.getAllValues().get(1).getUpdatedAt()).isEqualTo(now);
  }
View Full Code Here

    when(dao.selectEnabledRootCharacteristics(session)).thenReturn(newArrayList(
      new CharacteristicDto().setId(10).setKey("MEMORY_EFFICIENCY").setOrder(2),
      new CharacteristicDto().setId(2).setKey("PORTABILITY").setOrder(3)
    ));

    DebtCharacteristic result = service.moveDown(10);

    verify(dao, times(2)).update(characteristicCaptor.capture(), eq(session));

    assertThat(result.order()).isEqualTo(3);
    assertThat(characteristicCaptor.getAllValues().get(0).getOrder()).isEqualTo(2);
    assertThat(characteristicCaptor.getAllValues().get(0).getUpdatedAt()).isEqualTo(now);
    assertThat(characteristicCaptor.getAllValues().get(1).getOrder()).isEqualTo(3);
    assertThat(characteristicCaptor.getAllValues().get(1).getUpdatedAt()).isEqualTo(now);
  }
View Full Code Here

    return null;
  }

  private void addCharacteristics(Rule rule, JsonWriter json) {
    String subCharacteristicKey = rule.debtCharacteristicKey();
    DebtCharacteristic subCharacteristic = characteristicByKey(subCharacteristicKey);
    if (subCharacteristic != null) {
      json.prop("subCharacteristic", subCharacteristic.name());
      DebtCharacteristic characteristic = characteristicById(((DefaultDebtCharacteristic) subCharacteristic).parentId());
      json.prop("characteristic", characteristic != null ? characteristic.name() : null);
    }
  }
View Full Code Here

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

    DebtModelService debtModelService = serverTester.get(DebtModelService.class);
    int nb = debtModelService.characteristics().size();

    DebtCharacteristic result = debtModelService.create("New characteristic", null);

    assertThat(result.name()).isEqualTo("New characteristic");
    assertThat(result.key()).isEqualTo("NEW_CHARACTERISTIC");
    assertThat(result.isSub()).isFalse();
    assertThat(result.order()).isEqualTo(nb + 1);

    assertThat(debtModelService.characteristicByKey(result.key())).isNotNull();
  }
View Full Code Here

    DebtModelService debtModelService = serverTester.get(DebtModelService.class);

    DefaultDebtCharacteristic parent = (DefaultDebtCharacteristic) debtModelService.characteristicByKey("REUSABILITY");

    DebtCharacteristic result = debtModelService.create("New characteristic", parent.id());

    assertThat(result.name()).isEqualTo("New characteristic");
    assertThat(result.key()).isEqualTo("NEW_CHARACTERISTIC");
    assertThat(result.isSub()).isTrue();
    assertThat(result.order()).isNull();

    assertThat(debtModelService.characteristicByKey(result.key())).isNotNull();
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.server.debt.DebtCharacteristic

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.