<commit_before>package uk.gov.digital.ho.proving.financialstatus.api.test

import groovy.json.JsonSlurper
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.web.WebAppConfiguration
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.result.MockMvcResultHandlers
import spock.lang.Specification
import uk.gov.digital.ho.proving.financialstatus.acl.BarclaysBankService
import uk.gov.digital.ho.proving.financialstatus.api.DailyBalanceService
import uk.gov.digital.ho.proving.financialstatus.api.ServiceConfiguration

import java.time.LocalDate

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup

/**
 * @Author Home Office Digital
 */
@WebAppConfiguration
@ContextConfiguration(classes = ServiceConfiguration.class)
class DailyBalanceServiceSpec extends Specification {

    def barlcaysBankService = Mock(BarclaysBankService)

    def dailyBalanceService = new DailyBalanceService(barlcaysBankService)
    MockMvc mockMvc = standaloneSetup(dailyBalanceService).setMessageConverters(new ServiceConfiguration().mappingJackson2HttpMessageConverter()).build()


    def setup() {

    }

    def "daily balance threshold check pass"() {

        1 * barlcaysBankService.fetchAccountDailyBalances(_, _, _) >> DataUtils.randomBankResponseOK(LocalDate.of(2016,6,9), 28, 2560.23, 3500, true, false)

        when:
        def response = mockMvc.perform(
            get("/incomeproving/v1/individual/dailybalancecheck/12-34-56/12345678")
                .param("applicationRaisedDate", "2016-06-09")
                .param("threshold", "2560.23")
                .param("days", "28")
        )

        then:
        response.andDo(MockMvcResultHandlers.print())
        response.andExpect(status().isOk())
        def jsonContent = new JsonSlurper().parseText(response.andReturn().response.getContentAsString())
        jsonContent.dailyBalanceCheck.minimumAboveThreshold == true

    }


    def "daily balance threshold check fail"() {

        1 * barlcaysBankService.fetchAccountDailyBalances(_, _, _) >> DataUtils.randomBankResponseOK(LocalDate.of(2016,6,9), 28, 2560.22, 3500, true, false)

        when:
        def response = mockMvc.perform(
            get("/incomeproving/v1/individual/dailybalancecheck/12-34-56/12345678")
                .param("applicationRaisedDate", "2016-06-09")
                .param("threshold", "2560.23")
                .param("days", "28")
        )

        then:
        response.andDo(MockMvcResultHandlers.print())
        response.andExpect(status().isOk())
        def jsonContent = new JsonSlurper().parseText(response.andReturn().response.getContentAsString())
        jsonContent.dailyBalanceCheck.minimumAboveThreshold == false

    }


}<commit_msg>Addition failure scenario<commit_after>package uk.gov.digital.ho.proving.financialstatus.api.test

import groovy.json.JsonSlurper
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.web.WebAppConfiguration
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.result.MockMvcResultHandlers
import spock.lang.Specification
import uk.gov.digital.ho.proving.financialstatus.acl.BarclaysBankService
import uk.gov.digital.ho.proving.financialstatus.api.DailyBalanceService
import uk.gov.digital.ho.proving.financialstatus.api.ServiceConfiguration

import java.time.LocalDate

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup

/**
 * @Author Home Office Digital
 */
@WebAppConfiguration
@ContextConfiguration(classes = ServiceConfiguration.class)
class DailyBalanceServiceSpec extends Specification {

    def barlcaysBankService = Mock(BarclaysBankService)

    def dailyBalanceService = new DailyBalanceService(barlcaysBankService)
    MockMvc mockMvc = standaloneSetup(dailyBalanceService).setMessageConverters(new ServiceConfiguration().mappingJackson2HttpMessageConverter()).build()


    def setup() {

    }

    def "daily balance threshold check pass"() {

        1 * barlcaysBankService.fetchAccountDailyBalances(_, _, _) >> DataUtils.randomBankResponseOK(LocalDate.of(2016,6,9), 28, 2560.23, 3500, true, false)

        when:
        def response = mockMvc.perform(
            get("/incomeproving/v1/individual/dailybalancecheck/12-34-56/12345678")
                .param("applicationRaisedDate", "2016-06-09")
                .param("threshold", "2560.23")
                .param("days", "28")
        )

        then:
        response.andDo(MockMvcResultHandlers.print())
        response.andExpect(status().isOk())
        def jsonContent = new JsonSlurper().parseText(response.andReturn().response.getContentAsString())
        jsonContent.dailyBalanceCheck.minimumAboveThreshold == true

    }


    def "daily balance threshold check fail (minimum below threshold)"() {

        1 * barlcaysBankService.fetchAccountDailyBalances(_, _, _) >> DataUtils.randomBankResponseOK(LocalDate.of(2016,6,9), 28, 2560.22, 3500, true, false)

        when:
        def response = mockMvc.perform(
            get("/incomeproving/v1/individual/dailybalancecheck/12-34-56/12345678")
                .param("applicationRaisedDate", "2016-06-09")
                .param("threshold", "2560.23")
                .param("days", "28")
        )

        then:
        response.andDo(MockMvcResultHandlers.print())
        response.andExpect(status().isOk())
        def jsonContent = new JsonSlurper().parseText(response.andReturn().response.getContentAsString())
        jsonContent.dailyBalanceCheck.minimumAboveThreshold == false

    }

    def "daily balance threshold check fail (not enough entries)"() {

        1 * barlcaysBankService.fetchAccountDailyBalances(_, _, _) >> DataUtils.randomBankResponseOK(LocalDate.of(2016,6,9), 26, 2560.23, 3500, true, false)

        when:
        def response = mockMvc.perform(
            get("/incomeproving/v1/individual/dailybalancecheck/12-34-56/12345678")
                .param("applicationRaisedDate", "2016-06-09")
                .param("threshold", "2560.23")
                .param("days", "28")
        )

        then:
        response.andDo(MockMvcResultHandlers.print())
        response.andExpect(status().isOk())
        def jsonContent = new JsonSlurper().parseText(response.andReturn().response.getContentAsString())
        jsonContent.dailyBalanceCheck.minimumAboveThreshold == false

    }


}
{'fraction_non_alphanumeric': 0.11057622173595916, 'fraction_numerical': 0.036761487964989056, 'mean_word_length': 3.6991089787525704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3146277', 'n_tokens_mistral': 2154, 'n_tokens_neox': 1897, 'n_words': 288}