package com.master.demo.msdemo;

import com.master.demo.msdemo.resources.FibonacciResource;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;

import static org.assertj.core.api.Assertions.assertThat;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class MsDemoApplicationTests {

	@Test
	void contextLoads() {
	}
	@Value(value="${local.server.port}")
	private int port;
	@Autowired
	private TestRestTemplate restTemplate;

	@Test
	public void greetingShouldReturnDefaultMessage() throws Exception {
		for (int i=0;i<30;++i) {
			String s = this.restTemplate.getForObject("http://localhost:" + port + "/fib/"+i, String.class);
			System.out.println(s);
		}
	}
//	@Test
//	void testFibo(){
//		FibonacciResource fibonacciResource = new FibonacciResource();
//		System.out.println(fibonacciResource.fibonacci(15));
//	}



}
