Witam wszystkich,
zaczynam swoją przygodę ze Spockiem i Groovy. Niestety wyskakuje mi pewien błąd podczas odpalania testu. Czy macie pomysły dlaczego może tak być ?
package pl.ingbank.cms2.collateral.domain.collateral.dictionary
import org.spockframework.spring.SpringBean
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
import org.springframework.context.annotation.Import
import org.springframework.http.MediaType
import org.springframework.test.web.servlet.MockMvc
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
import spock.lang.Specification
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
@WebMvcTest(secure = false)
@Import(value = DictionaryTestController.class)
class DictionaryTestControllerTest extends Specification {
private final String URL = "/collateralTest/currencies"
@SpringBean
private final DictionaryTestRepository dictionaryTestRepository = Mock();
@Autowired
private MockMvc mvc
def "should return status ok when list of currencies is not empty"() {
given:
List<String> currencies = new ArrayList<>();
dictionaryTestRepository.findAll() >> prepareCurrenciesList()
expect:
mvc.perform(MockMvcRequestBuilders.get(URL)
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andReturn()
.getResponse()
}
def prepareCurrenciesList(){
List<String> currencies = Arrays.asList("PLN")
currencies
}
}
- groovy exception.PNG (110 KB) - ściągnięć: 109