package ua.dp.radiator.client.jenkins;

import static org.mockito.Mockito.verify;
import static ua.dp.radiator.Helper.mockWebClient;

import org.junit.Test;
import org.springframework.web.reactive.function.client.WebClient;

import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
import ua.dp.radiator.config.properties.RadiatorProperties;


public class ReactiveJenkinsRestApiTest {

	@Test
	public void loadLastBuildNumber() throws Exception {
		//given
		Mono<String> response = Mono.just("7");

		WebClient webClientMock = mockWebClient(response);

		Mono<String> baseUrl = Mono.just("http://localhost:8080");

		//when
		Mono<Integer> actual = new ReactiveJenkinsRestApi(webClientMock, newProperties())
				.loadLastBuildNumber(baseUrl);

		//then
		verify(webClientMock.get()).uri("http://localhost:8080/lastBuild/buildNumber");


		StepVerifier.create(actual)
				.expectNext(7)
				.expectComplete()
				.verify();
	}

	private RadiatorProperties newProperties() {
		RadiatorProperties properties = new RadiatorProperties();
		properties.buildState.auth = new RadiatorProperties.BuildState.Authorisation();
		properties.buildState.auth.username = "user";
		properties.buildState.auth.password = "secret";
		return properties;
	}

}
@@ -765,92 +765,8 @@
 hen%0A
-%09%09verify(webClientMock.get()).uri(%22http://localhost:8080/lastBuild/buildNumber%22);%0A%0A%0A
 %09%09St
@@ -846,21 +846,105 @@
 erify();
+%0A%0A%09%09verify(webClientMock.get()).uri(%22http://localhost:8080/lastBuild/buildNumber%22);
 %0A%09%7D%0A%0A
+%0A
 %09private

Add tests