Examples of DebtCharacteristic


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

  private DebtCharacteristic effectiveCharacteristic(RuleDto ruleDto, RuleKey ruleKey, DefaultDebtModel debtModel) {
    Integer subCharacteristicId = ruleDto.getSubCharacteristicId();
    Integer defaultSubCharacteristicId = ruleDto.getDefaultSubCharacteristicId();
    Integer effectiveSubCharacteristicId = subCharacteristicId != null ? subCharacteristicId : defaultSubCharacteristicId;
    DebtCharacteristic subCharacteristic = debtModel.characteristicById(effectiveSubCharacteristicId);
    if (subCharacteristic == null) {
      throw new IllegalStateException(String.format("Sub characteristic id '%s' on rule '%s' has not been found", effectiveSubCharacteristicId, ruleKey));
    }
    return subCharacteristic;
  }
View Full Code Here

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

    when(dao.selectEnabledCharacteristics()).thenReturn(newArrayList(rootCharacteristicDto, characteristicDto));

    DebtModel result = provider.provide(dao);
    assertThat(result.characteristics()).hasSize(1);

    DebtCharacteristic characteristic = result.characteristicByKey("MEMORY_EFFICIENCY");
    assertThat(characteristic.key()).isEqualTo("MEMORY_EFFICIENCY");
    assertThat(characteristic.name()).isEqualTo("Memory use");
    assertThat(characteristic.isSub()).isFalse();
    assertThat(characteristic.order()).isEqualTo(1);

    DebtCharacteristic subCharacteristic = result.characteristicByKey("EFFICIENCY");
    assertThat(subCharacteristic.key()).isEqualTo("EFFICIENCY");
    assertThat(subCharacteristic.name()).isEqualTo("Efficiency");
    assertThat(subCharacteristic.isSub()).isTrue();
    assertThat(subCharacteristic.order()).isNull();
  }
View Full Code Here

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

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

    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

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

    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

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

    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

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

    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

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

    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
Copyright © 2018 www.massapi.com. 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.