Package org.sonar.api.server.debt.internal

Examples of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction


    assertThat(function.offset()).isEqualTo("10h");
  }

  @Test
  public void sanitize_remediation_coefficient_and_offset() {
    DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "  1  h   ", "  10   min");

    assertThat(function.coefficient()).isEqualTo("1h");
    assertThat(function.offset()).isEqualTo("10min");
  }
View Full Code Here


  }

  @Test
  public void fail_to_when_no_type() {
    try {
      new DefaultDebtRemediationFunction(null, "5min", "10h");
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("Remediation function type cannot be null");
    }
  }
View Full Code Here

  }

  @Test
  public void fail_to_create_linear_when_no_coefficient() {
    try {
      new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, null, "10h");
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("Linear functions must only have a non empty coefficient");
    }
  }
View Full Code Here

  }

  @Test
  public void fail_to_create_linear_when_offset() {
    try {
      new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "5min", "10h");
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("Linear functions must only have a non empty coefficient");
    }
  }
View Full Code Here

  }

  @Test
  public void fail_to_create_constant_per_issue_when_no_offset() {
    try {
      new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, "10h", null);
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("Constant/issue functions must only have a non empty offset");
    }
  }
View Full Code Here

  }

  @Test
  public void fail_to_create_constant_per_issue_when_coefficient() {
    try {
      new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, "5min", "10h");
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("Constant/issue functions must only have a non empty offset");
    }
  }
View Full Code Here

  }

  @Test
  public void fail_to_create_linear_with_offset_when_no_coefficient() {
    try {
      new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "", "10h");
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("Linear with offset functions must have both non null coefficient and offset");
    }
  }
View Full Code Here

  }

  @Test
  public void fail_to_create_linear_with_offset_when_no_offset() {
    try {
      new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "5min", "");
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("Linear with offset functions must have both non null coefficient and offset");
    }
  }
View Full Code Here

    }
  }

  @Test
  public void test_equals_and_hashcode() {
    DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "10h", "5min");
    DebtRemediationFunction functionWithSameValue = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "10h", "5min");
    DebtRemediationFunction functionWithDifferentType = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "5min");

    assertThat(function).isEqualTo(function);
    assertThat(function).isEqualTo(functionWithSameValue);
    assertThat(function).isNotEqualTo(functionWithDifferentType);

    assertThat(function).isNotEqualTo(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "11h", "5min"));
    assertThat(function).isNotEqualTo(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "10h", "6min"));
    assertThat(function).isNotEqualTo(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "10h", null));
    assertThat(function).isNotEqualTo(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "6min"));

    assertThat(function.hashCode()).isEqualTo(function.hashCode());
    assertThat(function.hashCode()).isEqualTo(functionWithSameValue.hashCode());
    assertThat(function.hashCode()).isNotEqualTo(functionWithDifferentType.hashCode());
  }
View Full Code Here

    assertThat(function.hashCode()).isNotEqualTo(functionWithDifferentType.hashCode());
  }

  @Test
  public void test_to_string() {
    assertThat(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "10h", "5min").toString())
      .isEqualTo("DebtRemediationFunction{type=LINEAR_OFFSET, coefficient=10h, offset=5min}");
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction

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.