[JAVA-22519] Move articles from generic libraries module to specific library modules (#15416)

This commit is contained in:
panos-kakos
2023-12-21 10:30:26 +02:00
committed by GitHub
parent 51e9f6cf37
commit 5e4ca88972
121 changed files with 729 additions and 518 deletions
@@ -1,18 +0,0 @@
package com.baeldung.cache2k;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class ProductHelperUnitTest {
@Test
public void whenInvokedGetDiscountTwice_thenGetItFromCache() {
ProductHelper productHelper = new ProductHelper();
assertTrue(productHelper.getCacheMissCount() == 0);
assertTrue(productHelper.getDiscount("Sports") == 20);
assertTrue(productHelper.getDiscount("Sports") == 20);
assertTrue(productHelper.getCacheMissCount() == 1);
}
}
@@ -1,21 +0,0 @@
package com.baeldung.cache2k;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class ProductHelperUsingLoaderUnitTest {
@Test
public void whenInvokedGetDiscount_thenPopulateCacheUsingLoader() {
ProductHelperUsingLoader productHelper = new ProductHelperUsingLoader();
assertTrue(productHelper.getCacheMissCount() == 0);
assertTrue(productHelper.getDiscount("Sports") == 20);
assertTrue(productHelper.getCacheMissCount() == 1);
assertTrue(productHelper.getDiscount("Electronics") == 10);
assertTrue(productHelper.getCacheMissCount() == 2);
}
}
@@ -1,15 +0,0 @@
package com.baeldung.cache2k;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class ProductHelperWithEventListenerUnitTest {
@Test
public void whenEntryAddedInCache_thenEventListenerCalled() {
ProductHelperWithEventListener productHelper = new ProductHelperWithEventListener();
assertTrue(productHelper.getDiscount("Sports") == 20);
}
}
@@ -1,22 +0,0 @@
package com.baeldung.cache2k;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class ProductHelperWithExpiryUnitTest {
@Test
public void whenInvokedGetDiscountAfterExpiration_thenDiscountCalculatedAgain() throws InterruptedException {
ProductHelperWithExpiry productHelper = new ProductHelperWithExpiry();
assertTrue(productHelper.getCacheMissCount() == 0);
assertTrue(productHelper.getDiscount("Sports") == 20);
assertTrue(productHelper.getCacheMissCount() == 1);
Thread.sleep(20);
assertTrue(productHelper.getDiscount("Sports") == 20);
assertTrue(productHelper.getCacheMissCount() == 2);
}
}
@@ -1,35 +0,0 @@
package com.baeldung.cactoos;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import org.junit.Test;
public class CactoosCollectionUtilsUnitTest {
@Test
public void whenFilteredClassIsCalledWithSpecificArgs_thenCorrespondingFilteredCollectionShouldBeReturned() throws IOException {
CactoosCollectionUtils obj = new CactoosCollectionUtils();
// when
List<String> strings = new ArrayList<String>() {
{
add("Hello");
add("John");
add("Smith");
add("Eric");
add("Dizzy");
}
};
int size = obj.getFilteredList(strings).size();
// then
assertEquals(3, size);
}
}
@@ -1,54 +0,0 @@
package com.baeldung.cactoos;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import org.junit.Test;
public class CactoosStringUtilsUnitTest {
@Test
public void whenFormattedTextIsPassedWithArgs_thenFormattedStringIsReturned() throws IOException {
CactoosStringUtils obj = new CactoosStringUtils();
// when
String formattedString = obj.createdFormattedString("John");
// then
assertEquals("Hello John", formattedString);
}
@Test
public void whenStringIsPassesdToLoweredOrUpperClass_thenCorrespondingStringIsReturned() throws Exception {
CactoosStringUtils obj = new CactoosStringUtils();
// when
String lowerCaseString = obj.toLowerCase("TeSt StrIng");
String upperCaseString = obj.toUpperCase("TeSt StrIng");
// then
assertEquals("test string", lowerCaseString);
assertEquals("TEST STRING", upperCaseString);
}
@Test
public void whenEmptyStringIsPassesd_thenIsBlankReturnsTrue() throws Exception {
CactoosStringUtils obj = new CactoosStringUtils();
// when
boolean isBlankEmptyString = obj.isBlank("");
boolean isBlankNull = obj.isBlank(null);
// then
assertEquals(true, isBlankEmptyString);
assertEquals(true, isBlankNull);
}
}
@@ -1,36 +0,0 @@
package com.baeldung.takes;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
import org.takes.http.FtRemote;
public class TakesAppIntegrationTest {
@Test
public void givenTake_whenRunRemoteServer_thenRespond() throws Exception {
new FtRemote(new TakesContact()).exec(
new FtRemote.Script() {
@Override
public void exec(final URI home) throws IOException {
HttpClient client = HttpClientBuilder.create().build();
HttpResponse response = client.execute(new HttpGet(home));
int statusCode = response.getStatusLine().getStatusCode();
HttpEntity entity = response.getEntity();
String result = EntityUtils.toString(entity);
assertEquals(200, statusCode);
assertEquals("Contact us at https://www.baeldung.com", result);
}
});
}
}
@@ -1,17 +0,0 @@
package com.baeldung.takes;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.takes.rq.RqFake;
import org.takes.rs.RsPrint;
public class TakesContactUnitTest {
@Test
public void givenTake_whenInvokeActMethod_thenRespond() throws Exception {
final String resp = new RsPrint(new TakesContact().act(new RqFake())).printBody();
assertEquals("Contact us at https://www.baeldung.com", resp);
}
}