Package org.sonar.wsclient.services

Examples of org.sonar.wsclient.services.TimeMachine


    }
    Object cells = utils.getField(json, "cells");
    if (cells == null) {
      throw new IllegalArgumentException("cells must be set");
    }
    return new TimeMachine(toColumns(cols), toCells(cells));
  }
View Full Code Here


public class TimeMachineUnmarshallerTest extends UnmarshallerTestCase {

  @Test
  public void test_to_model() throws Exception {
    TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(loadFile("/timemachine/timemachine.json"));

    // columns
    assertThat(timeMachine.getColumns().length).isEqualTo(2);
    assertThat(timeMachine.getColumns()[0].getIndex()).isEqualTo(0);
    assertThat(timeMachine.getColumns()[0].getMetricKey()).isEqualTo("ncloc");
    assertThat(timeMachine.getColumns()[1].getIndex()).isEqualTo(1);
    assertThat(timeMachine.getColumns()[1].getMetricKey()).isEqualTo("coverage");

    // values sorted by date
    assertThat(timeMachine.getCells().length).isEqualTo(3); // 3 days
    assertThat(getDayOfMonth(timeMachine.getCells()[0].getDate())).isEqualTo(19);
    assertThat(getDayOfMonth(timeMachine.getCells()[1].getDate())).isEqualTo(21);
    assertThat(getDayOfMonth(timeMachine.getCells()[2].getDate())).isEqualTo(25);

    assertThat(timeMachine.getCells()[0].getValues()).hasSize(2);
    assertThat((Double) timeMachine.getCells()[0].getValues()[0]).isEqualTo(21.0);
    assertThat((Double) timeMachine.getCells()[0].getValues()[1]).isEqualTo(80.0);
  }
View Full Code Here

    assertThat((Double) timeMachine.getCells()[0].getValues()[1]).isEqualTo(80.0);
  }

  @Test
  public void should_accept_null_values() throws Exception {
    TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(loadFile("/timemachine/null-values.json"));

    assertThat(timeMachine.getCells()[0].getValues().length).isEqualTo(2);
    assertThat(timeMachine.getCells()[0].getValues()[0]).isNull();
    assertThat((Double) timeMachine.getCells()[0].getValues()[1]).isEqualTo(80.0);

    assertThat((Double) timeMachine.getCells()[1].getValues()[0]).isEqualTo(29.0);
    assertThat(timeMachine.getCells()[1].getValues()[1]).isNull();
  }
View Full Code Here

    assertThat(timeMachine.getCells()[1].getValues()[1]).isNull();
  }

  @Test
  public void should_cast_values() throws Exception {
    TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(loadFile("/timemachine/typed-values.json"));

    assertThat(timeMachine.getCells()[0].getValues().length).isEqualTo(2);
    assertThat((String) timeMachine.getCells()[0].getValues()[0]).isEqualTo("Sonar way");
    assertThat((Double) timeMachine.getCells()[0].getValues()[1]).isEqualTo(80.0);
  }
View Full Code Here

TOP

Related Classes of org.sonar.wsclient.services.TimeMachine

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.