public ProjectStatusResponse.ProjectStatus format() {
    if (!optionalMeasureData.isPresent()) {
      return newResponseWithoutQualityGateDetails();
    }

    JsonObject json = JsonParser.parseString(optionalMeasureData.get()).getAsJsonObject();

    ProjectStatusResponse.Status qualityGateStatus = measureLevelToQualityGateStatus(json.get("level").getAsString());
    projectStatusBuilder.setStatus(qualityGateStatus);
    projectStatusBuilder.setCaycStatus(caycStatus.toString());

    formatIgnoredConditions(json);
    formatConditions(json.getAsJsonArray("conditions"));
    formatPeriods();

    return projectStatusBuilder.build();
  }
@Test
  public void map_level_conditions_and_period() throws IOException {
    String measureData = IOUtils.toString(getClass().getResource("QualityGateDetailsFormatterTest/quality_gate_details.json"));
    SnapshotDto snapshot = new SnapshotDto()
      .setPeriodMode("last_version")
      .setPeriodParam("2015-12-07")
      .setPeriodDate(1449404331764L);
    underTest = newQualityGateDetailsFormatter(measureData, snapshot);

    ProjectStatus result = underTest.format();

    assertThat(result.getStatus()).isEqualTo(ProjectStatusResponse.Status.ERROR);
    assertEquals(NON_COMPLIANT.toString(), result.getCaycStatus());
    // check conditions
    assertThat(result.getConditionsCount()).isEqualTo(3);
    List<ProjectStatusResponse.Condition> conditions = result.getConditionsList();
    assertThat(conditions).extracting("status").containsExactly(
      ProjectStatusResponse.Status.ERROR,
      ProjectStatusResponse.Status.WARN,
      ProjectStatusResponse.Status.OK);
    assertThat(conditions).extracting("metricKey").containsExactly("new_coverage", "new_blocker_violations", "new_critical_violations");
    assertThat(conditions).extracting("comparator").containsExactly(
      ProjectStatusResponse.Comparator.LT,
      ProjectStatusResponse.Comparator.GT,
      ProjectStatusResponse.Comparator.GT);
    assertThat(conditions).extracting("warningThreshold").containsOnly("80", "");
    assertThat(conditions).extracting("errorThreshold").containsOnly("85", "0", "0");
    assertThat(conditions).extracting("actualValue").containsExactly("82.2985024398452", "1", "0");

    // check period
    ProjectStatusResponse.NewCodePeriod period = result.getPeriod();
    assertThat(period).extracting("mode").isEqualTo("last_version");
    assertThat(period).extracting("parameter").isEqualTo("2015-12-07");
    assertThat(period.getDate()).isEqualTo(formatDateTime(snapshot.getPeriodDate()));
  }