Core java 12 improvements (#11090)

* Commit source code to branch

* Fix to BAEL-5072
Change package definition and implementation of compactValues junit

* BAEL-5053 Compare file contents
This commit is contained in:
mbarriola
2021-08-05 15:50:37 -04:00
committed by GitHub
parent bc575d1917
commit b623297829
27 changed files with 1014 additions and 51 deletions
@@ -0,0 +1,22 @@
package com.baeldung.simplehexagonalex.repository.primaryQuoteProvider;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
import com.baeldung.simplehexagonalex.reposity.mock.quoteadapter.MockQuoteAdapter;
public class MockAccessProviderUnitTest {
@Test
public void givenProvider_whenConnect_thenResponse() throws Exception {
MockQuoteAdapter provider = new MockQuoteAdapter();
QuoteOfTheDay quote = provider.getQuote();
assertNotNull(quote);
assertEquals("Mock quote of the day", quote.getQuote());
assertEquals("Mock Provider", quote.getProvider());
}
}
@@ -0,0 +1,28 @@
package com.baeldung.simplehexagonalex.repository.primaryQuoteProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider;
@SpringBootTest
public class PrimaryAccessProviderIntegrationTest {
@Autowired
@Qualifier("providerQuoteAdapter")
QuoteOfTheDayFromProvider provider;
@Test
public void whenQuoteProvider_thenResponse() throws Exception {
QuoteOfTheDay quote = provider.getQuote();
assertNotNull(quote);
assertThat(quote.getProvider()).contains("theysaidso");
}
}
@@ -0,0 +1,36 @@
package com.baeldung.simplehexagonalex.repository.primaryQuoteProvider;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;
@SpringBootTest
@AutoConfigureMockMvc
public class QuoteRequestIntegrationTest {
@Autowired
private MockMvc mockMvc;
@Test
public void whenRestQuoteRequest_thenResponse() throws Exception {
MvcResult result = this.mockMvc.perform(get("/quote/tester"))
.andDo(print())
.andExpect(status().isOk())
.andReturn();
String content = result.getResponse()
.getContentAsString();
assertThat(content).contains("tester");
assertThat(content).contains("theysaidso");
}
}
@@ -0,0 +1 @@
theysayso.quote.provider.url=https://quotes.rest/qod?language=en