@Override
  public void execute(Context context) {
    long count = 0;
    try (StreamWriter<ProjectDump.Rule> writer = dumpWriter.newStreamWriter(DumpElement.RULES)) {
      ProjectDump.Rule.Builder ruleBuilder = ProjectDump.Rule.newBuilder();
      for (Rule rule : ruleRepository.getAll()) {
        ProjectDump.Rule ruleMessage = toRuleMessage(ruleBuilder, rule);
        writer.write(ruleMessage);
        count++;
      }
      LoggerFactory.getLogger(getClass()).debug("{} rules exported", count);
    } catch (Exception e) {
      throw new IllegalStateException(format("Rule Export failed after processing %d rules successfully", count), e);
    }
  }
@Test
  public void execute_writes_no_rules_when_repository_is_empty() {
    underTest.execute(new TestComputationStepContext());

    assertThat(dumpWriter.getWrittenMessagesOf(DumpElement.RULES)).isEmpty();
  }