package com.oguerreiro.resilient;

import java.math.BigDecimal;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import com.oguerreiro.resilient.domain.Organization;
import com.oguerreiro.resilient.domain.PeriodVersion;
import com.oguerreiro.resilient.repository.OrganizationRepository;
import com.oguerreiro.resilient.repository.OutputDataRepository;
import com.oguerreiro.resilient.repository.PeriodVersionRepository;

@ActiveProfiles("testdev") // Replace "dev" with your desired profile
@SpringBootTest
class OutputDataSumTest {
  @Autowired
  private OutputDataRepository outputDataRepository;

  @Autowired
  private OrganizationRepository organizationRepository;

  @Autowired
  private PeriodVersionRepository periodVersionRepository;

  @Test
  void sumLikeQuery() {
    Organization org = organizationRepository.getReferenceById(4L);
    PeriodVersion periodVersion = periodVersionRepository.getReferenceById(1511L);
    BigDecimal sum = outputDataRepository.sumAllOutputsFor(org, periodVersion, "5301%");

    System.out.println(sum.toString());
  }
}
