Merge branch 'master' of https://github.com/eugenp/tutorials
This commit is contained in:
commit
4d73d33db8
@ -39,6 +39,3 @@ This tutorials project is being built **[>> HERE](https://rest-security.ci.cloud
|
|||||||
|
|
||||||
- [Apache Maven Standard Directory Layout](http://www.baeldung.com/maven-directory-structure)
|
- [Apache Maven Standard Directory Layout](http://www.baeldung.com/maven-directory-structure)
|
||||||
- [Apache Maven Tutorial](http://www.baeldung.com/maven)
|
- [Apache Maven Tutorial](http://www.baeldung.com/maven)
|
||||||
- [Designing a User Friendly Java Library](http://www.baeldung.com/design-a-user-friendly-java-library)
|
|
||||||
- [Java Service Provider Interface](http://www.baeldung.com/java-spi)
|
|
||||||
- [Java Streams vs Vavr Streams](http://www.baeldung.com/vavr-java-streams)
|
|
||||||
|
@ -148,7 +148,7 @@ public class Board {
|
|||||||
System.out.println("Game Draw");
|
System.out.println("Game Draw");
|
||||||
break;
|
break;
|
||||||
case IN_PROGRESS:
|
case IN_PROGRESS:
|
||||||
System.out.println("Game In rogress");
|
System.out.println("Game In Progress");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import org.jgrapht.traverse.DepthFirstIterator;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class DirectedGraphUnitTests {
|
public class DirectedGraphUnitTest {
|
||||||
DirectedGraph<String, DefaultEdge> directedGraph;
|
DirectedGraph<String, DefaultEdge> directedGraph;
|
||||||
|
|
||||||
@Before
|
@Before
|
@ -5,7 +5,7 @@
|
|||||||
<artifactId>animal-sniffer-mvn-plugin</artifactId>
|
<artifactId>animal-sniffer-mvn-plugin</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>example-animal-sniffer-mvn-plugin</name>
|
<name>animal-sniffer-mvn-plugin</name>
|
||||||
<url>http://maven.apache.org</url>
|
<url>http://maven.apache.org</url>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||||||
import static junit.framework.Assert.assertEquals;
|
import static junit.framework.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
public class CayenneAdvancedOperationIntegrationTest {
|
public class CayenneAdvancedOperationLiveTest {
|
||||||
private static ObjectContext context = null;
|
private static ObjectContext context = null;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
@ -16,7 +16,7 @@ import static junit.framework.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
|
||||||
|
|
||||||
public class CayenneOperationIntegrationTest {
|
public class CayenneOperationLiveTest {
|
||||||
private static ObjectContext context = null;
|
private static ObjectContext context = null;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
@ -8,7 +8,7 @@ import opennlp.tools.tokenize.WhitespaceTokenizer;
|
|||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TokenizerTest {
|
public class TokenizerUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenEnglishModel_whenTokenize_thenTokensAreDetected() throws Exception {
|
public void givenEnglishModel_whenTokenize_thenTokensAreDetected() throws Exception {
|
@ -1,3 +1,4 @@
|
|||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
|
|
||||||
- [Deploy Spring Boot App to Azure]()
|
- [Deploy Spring Boot App to Azure](http://www.baeldung.com/spring-boot-azure)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class AzureApplicationTests {
|
public class AzureApplicationIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void contextLoads() {
|
@ -5,7 +5,6 @@
|
|||||||
<groupId>com.example</groupId>
|
<groupId>com.example</groupId>
|
||||||
<artifactId>spring-boot-camel</artifactId>
|
<artifactId>spring-boot-camel</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>Spring-Boot - Camel API</name>
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-spring</artifactId>
|
<artifactId>parent-spring-4</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-spring</relativePath>
|
<relativePath>../parent-spring-4</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -38,7 +38,6 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<spring.version>4.3.4.RELEASE</spring.version>
|
|
||||||
<aspectjweaver.version>1.8.9</aspectjweaver.version>
|
<aspectjweaver.version>1.8.9</aspectjweaver.version>
|
||||||
<weld-se-core.version>2.4.1.Final</weld-se-core.version>
|
<weld-se-core.version>2.4.1.Final</weld-se-core.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
5
core-java-10/README.md
Normal file
5
core-java-10/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
|
||||||
|
- [Java 10 LocalVariable Type-Inference](http://www.baeldung.com/java-10-local-variable-type-inference)
|
||||||
|
- [Guide to Java 10](http://www.baeldung.com/java-10-overview)
|
@ -50,4 +50,6 @@
|
|||||||
- [Filtering Kotlin Collections](http://www.baeldung.com/kotlin-filter-collection)
|
- [Filtering Kotlin Collections](http://www.baeldung.com/kotlin-filter-collection)
|
||||||
- [How to Find an Element in a List with Java](http://www.baeldung.com/find-list-element-java)
|
- [How to Find an Element in a List with Java](http://www.baeldung.com/find-list-element-java)
|
||||||
- [Measure Elapsed Time in Java](http://www.baeldung.com/java-measure-elapsed-time)
|
- [Measure Elapsed Time in Java](http://www.baeldung.com/java-measure-elapsed-time)
|
||||||
|
- [Java Optional – orElse() vs orElseGet()](http://www.baeldung.com/java-optional-or-else-vs-or-else-get)
|
||||||
|
- [An Introduction to Java.util.Hashtable Class](http://www.baeldung.com/java-hash-table)
|
||||||
|
|
||||||
|
@ -195,6 +195,16 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
<compilerArgument>-parameters</compilerArgument>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
18
core-java-8/src/main/java/com/baeldung/reflect/Person.java
Normal file
18
core-java-8/src/main/java/com/baeldung/reflect/Person.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package com.baeldung.reflect;
|
||||||
|
|
||||||
|
public class Person {
|
||||||
|
|
||||||
|
private String fullName;
|
||||||
|
|
||||||
|
public Person(String fullName) {
|
||||||
|
this.fullName = fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFullName(String fullName) {
|
||||||
|
this.fullName = fullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFullName() {
|
||||||
|
return fullName;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.baeldung.reflect;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.lang.reflect.Parameter;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class MethodParamNameUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetConstructorParams_thenOk()
|
||||||
|
throws NoSuchMethodException, SecurityException {
|
||||||
|
List<Parameter> parameters
|
||||||
|
= Arrays.asList(Person.class.getConstructor(String.class).getParameters());
|
||||||
|
Optional<Parameter> parameter
|
||||||
|
= parameters.stream().filter(Parameter::isNamePresent).findFirst();
|
||||||
|
assertThat(parameter.get().getName()).isEqualTo("fullName");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetMethodParams_thenOk()
|
||||||
|
throws NoSuchMethodException, SecurityException {
|
||||||
|
List<Parameter> parameters
|
||||||
|
= Arrays.asList(
|
||||||
|
Person.class.getMethod("setFullName", String.class).getParameters());
|
||||||
|
Optional<Parameter> parameter
|
||||||
|
= parameters.stream().filter(Parameter::isNamePresent).findFirst();
|
||||||
|
assertThat(parameter.get().getName()).isEqualTo("fullName");
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class StreamIndicesTest {
|
public class StreamIndicesUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCalled_thenReturnListOfEvenIndexedStrings() {
|
public void whenCalled_thenReturnListOfEvenIndexedStrings() {
|
@ -24,3 +24,4 @@
|
|||||||
- [Method Handles in Java](http://www.baeldung.com/java-method-handles)
|
- [Method Handles in Java](http://www.baeldung.com/java-method-handles)
|
||||||
- [Introduction to Chronicle Queue](http://www.baeldung.com/java-chronicle-queue)
|
- [Introduction to Chronicle Queue](http://www.baeldung.com/java-chronicle-queue)
|
||||||
- [A Guide to Java 9 Modularity](http://www.baeldung.com/java-9-modularity)
|
- [A Guide to Java 9 Modularity](http://www.baeldung.com/java-9-modularity)
|
||||||
|
- [Optional orElse Optional](http://www.baeldung.com/java-optional-or-else-optional)
|
||||||
|
@ -0,0 +1,199 @@
|
|||||||
|
package com.baeldung.java9.modules;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
|
import static org.hamcrest.CoreMatchers.nullValue;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||||
|
import static org.hamcrest.collection.IsEmptyCollection.empty;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import java.lang.module.ModuleDescriptor;
|
||||||
|
import java.lang.module.ModuleDescriptor.*;
|
||||||
|
import java.sql.Date;
|
||||||
|
import java.sql.Driver;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class ModuleAPIUnitTest {
|
||||||
|
|
||||||
|
public static final String JAVA_BASE_MODULE_NAME = "java.base";
|
||||||
|
|
||||||
|
private Module javaBaseModule;
|
||||||
|
private Module javaSqlModule;
|
||||||
|
private Module module;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
Class<HashMap> hashMapClass = HashMap.class;
|
||||||
|
javaBaseModule = hashMapClass.getModule();
|
||||||
|
|
||||||
|
Class<Date> dateClass = Date.class;
|
||||||
|
javaSqlModule = dateClass.getModule();
|
||||||
|
|
||||||
|
Class<Person> personClass = Person.class;
|
||||||
|
module = personClass.getModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenCheckingIfNamed_thenModuleIsNamed() {
|
||||||
|
assertThat(javaBaseModule.isNamed(), is(true));
|
||||||
|
assertThat(javaBaseModule.getName(), is(JAVA_BASE_MODULE_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenCheckingIfNamed_thenModuleIsUnnamed() {
|
||||||
|
assertThat(module.isNamed(), is(false));
|
||||||
|
assertThat(module.getName(), is(nullValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenExtractingPackagesContainedInAModule_thenModuleContainsOnlyFewOfThem() {
|
||||||
|
assertTrue(javaBaseModule.getPackages().contains("java.lang.annotation"));
|
||||||
|
assertFalse(javaBaseModule.getPackages().contains("java.sql"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenRetrievingClassLoader_thenClassLoaderIsReturned() {
|
||||||
|
assertThat(
|
||||||
|
module.getClassLoader().getClass().getName(),
|
||||||
|
is("jdk.internal.loader.ClassLoaders$AppClassLoader")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGettingAnnotationsPresentOnAModule_thenNoAnnotationsArePresent() {
|
||||||
|
assertThat(javaBaseModule.getAnnotations().length, is(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGettingLayerOfAModule_thenModuleLayerInformationAreAvailable() {
|
||||||
|
ModuleLayer javaBaseModuleLayer = javaBaseModule.getLayer();
|
||||||
|
|
||||||
|
assertTrue(javaBaseModuleLayer.configuration().findModule(JAVA_BASE_MODULE_NAME).isPresent());
|
||||||
|
assertThat(javaBaseModuleLayer.configuration().modules().size(), is(78));
|
||||||
|
assertTrue(javaBaseModuleLayer.parents().get(0).configuration().parents().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenRetrievingModuleDescriptor_thenTypeOfModuleIsInferred() {
|
||||||
|
ModuleDescriptor javaBaseModuleDescriptor = javaBaseModule.getDescriptor();
|
||||||
|
ModuleDescriptor javaSqlModuleDescriptor = javaSqlModule.getDescriptor();
|
||||||
|
|
||||||
|
assertFalse(javaBaseModuleDescriptor.isAutomatic());
|
||||||
|
assertFalse(javaBaseModuleDescriptor.isOpen());
|
||||||
|
assertFalse(javaSqlModuleDescriptor.isAutomatic());
|
||||||
|
assertFalse(javaSqlModuleDescriptor.isOpen());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenModuleName_whenBuildingModuleDescriptor_thenBuilt() {
|
||||||
|
Builder moduleBuilder = ModuleDescriptor.newModule("baeldung.base");
|
||||||
|
|
||||||
|
ModuleDescriptor moduleDescriptor = moduleBuilder.build();
|
||||||
|
|
||||||
|
assertThat(moduleDescriptor.name(), is("baeldung.base"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenModules_whenAccessingModuleDescriptorRequires_thenRequiresAreReturned() {
|
||||||
|
Set<Requires> javaBaseRequires = javaBaseModule.getDescriptor().requires();
|
||||||
|
Set<Requires> javaSqlRequires = javaSqlModule.getDescriptor().requires();
|
||||||
|
|
||||||
|
Set<String> javaSqlRequiresNames = javaSqlRequires.stream()
|
||||||
|
.map(Requires::name)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
assertThat(javaBaseRequires, empty());
|
||||||
|
assertThat(javaSqlRequires.size(), is(3));
|
||||||
|
assertThat(javaSqlRequiresNames, containsInAnyOrder("java.base", "java.xml", "java.logging"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenModules_whenAccessingModuleDescriptorProvides_thenProvidesAreReturned() {
|
||||||
|
Set<Provides> javaBaseProvides = javaBaseModule.getDescriptor().provides();
|
||||||
|
Set<Provides> javaSqlProvides = javaSqlModule.getDescriptor().provides();
|
||||||
|
|
||||||
|
Set<String> javaBaseProvidesService = javaBaseProvides.stream()
|
||||||
|
.map(Provides::service)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
assertThat(javaBaseProvidesService, contains("java.nio.file.spi.FileSystemProvider"));
|
||||||
|
assertThat(javaSqlProvides, empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenModules_whenAccessingModuleDescriptorExports_thenExportsAreReturned() {
|
||||||
|
Set<Exports> javaBaseExports = javaBaseModule.getDescriptor().exports();
|
||||||
|
Set<Exports> javaSqlExports = javaSqlModule.getDescriptor().exports();
|
||||||
|
|
||||||
|
Set<String> javaSqlExportsSource = javaSqlExports.stream()
|
||||||
|
.map(Exports::source)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
assertThat(javaBaseExports.size(), is(108));
|
||||||
|
assertThat(javaSqlExports.size(), is(3));
|
||||||
|
assertThat(javaSqlExportsSource, containsInAnyOrder("java.sql", "javax.transaction.xa", "javax.sql"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenModules_whenAccessingModuleDescriptorUses_thenUsesAreReturned() {
|
||||||
|
Set<String> javaBaseUses = javaBaseModule.getDescriptor().uses();
|
||||||
|
Set<String> javaSqlUses = javaSqlModule.getDescriptor().uses();
|
||||||
|
|
||||||
|
assertThat(javaBaseUses.size(), is(34));
|
||||||
|
assertThat(javaSqlUses, contains("java.sql.Driver"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenModules_whenAccessingModuleDescriptorOpen_thenOpenAreReturned() {
|
||||||
|
Set<Opens> javaBaseUses = javaBaseModule.getDescriptor().opens();
|
||||||
|
Set<Opens> javaSqlUses = javaSqlModule.getDescriptor().opens();
|
||||||
|
|
||||||
|
assertThat(javaBaseUses, empty());
|
||||||
|
assertThat(javaSqlUses, empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenAddingReadsToAModule_thenModuleCanReadNewModule() {
|
||||||
|
Module updatedModule = module.addReads(javaSqlModule);
|
||||||
|
|
||||||
|
assertTrue(updatedModule.canRead(javaSqlModule));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenExportingPackage_thenPackageIsExported() {
|
||||||
|
Module updatedModule = module.addExports("com.baeldung.java9.modules", javaSqlModule);
|
||||||
|
|
||||||
|
assertTrue(updatedModule.isExported("com.baeldung.java9.modules"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenOpeningAModulePackage_thenPackagedIsOpened() {
|
||||||
|
Module updatedModule = module.addOpens("com.baeldung.java9.modules", javaSqlModule);
|
||||||
|
|
||||||
|
assertTrue(updatedModule.isOpen("com.baeldung.java9.modules", javaSqlModule));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenAddingUsesToModule_thenUsesIsAdded() {
|
||||||
|
Module updatedModule = module.addUses(Driver.class);
|
||||||
|
|
||||||
|
assertTrue(updatedModule.canUse(Driver.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Person {
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Person(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -29,3 +29,4 @@
|
|||||||
- [Java TreeMap vs HashMap](http://www.baeldung.com/java-treemap-vs-hashmap)
|
- [Java TreeMap vs HashMap](http://www.baeldung.com/java-treemap-vs-hashmap)
|
||||||
- [How to TDD a List Implementation in Java](http://www.baeldung.com/java-test-driven-list)
|
- [How to TDD a List Implementation in Java](http://www.baeldung.com/java-test-driven-list)
|
||||||
- [How to Store Duplicate Keys in a Map in Java?](http://www.baeldung.com/java-map-duplicate-keys)
|
- [How to Store Duplicate Keys in a Map in Java?](http://www.baeldung.com/java-map-duplicate-keys)
|
||||||
|
- [Getting the Size of an Iterable in Java](http://www.baeldung.com/java-iterable-size)
|
||||||
|
@ -27,3 +27,4 @@
|
|||||||
- [A Guide to WatchService in Java NIO2](http://www.baeldung.com/java-nio2-watchservice)
|
- [A Guide to WatchService in Java NIO2](http://www.baeldung.com/java-nio2-watchservice)
|
||||||
- [Guide to Java NIO2 Asynchronous Channel APIs](http://www.baeldung.com/java-nio-2-async-channels)
|
- [Guide to Java NIO2 Asynchronous Channel APIs](http://www.baeldung.com/java-nio-2-async-channels)
|
||||||
- [A Guide to NIO2 Asynchronous Socket Channel](http://www.baeldung.com/java-nio2-async-socket-channel)
|
- [A Guide to NIO2 Asynchronous Socket Channel](http://www.baeldung.com/java-nio2-async-socket-channel)
|
||||||
|
- [Download a File From an URL in Java](http://www.baeldung.com/java-download-file)
|
||||||
|
@ -77,6 +77,6 @@ public class FilesManualTest {
|
|||||||
bw.newLine();
|
bw.newLine();
|
||||||
bw.close();
|
bw.close();
|
||||||
|
|
||||||
assertThat(StreamUtils.getStringFromInputStream(new FileInputStream(fileName))).isEqualTo("UK\r\n" + "US\r\n" + "Germany\r\n" + "Spain\n");
|
assertThat(StreamUtils.getStringFromInputStream(new FileInputStream(fileName))).isEqualTo("UK\r\n" + "US\r\n" + "Germany\r\n" + "Spain\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package org.baeldung.java.io;
|
package org.baeldung.java.io;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -105,8 +106,9 @@ public class JavaReadFromFileUnitTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Ignore // TODO
|
||||||
public void whenReadUTFEncodedFile_thenCorrect() throws IOException {
|
public void whenReadUTFEncodedFile_thenCorrect() throws IOException {
|
||||||
final String expected_value = "é<EFBFBD>’空";
|
final String expected_value = "青空";
|
||||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.in"), "UTF-8"));
|
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.in"), "UTF-8"));
|
||||||
final String currentLine = reader.readLine();
|
final String currentLine = reader.readLine();
|
||||||
reader.close();
|
reader.close();
|
||||||
|
@ -141,3 +141,12 @@
|
|||||||
- [Java KeyStore API](http://www.baeldung.com/java-keystore)
|
- [Java KeyStore API](http://www.baeldung.com/java-keystore)
|
||||||
- [Double-Checked Locking with Singleton](http://www.baeldung.com/java-singleton-double-checked-locking)
|
- [Double-Checked Locking with Singleton](http://www.baeldung.com/java-singleton-double-checked-locking)
|
||||||
- [Guide to Java Clock Class](http://www.baeldung.com/java-clock)
|
- [Guide to Java Clock Class](http://www.baeldung.com/java-clock)
|
||||||
|
- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
|
||||||
|
- [Using Java Assertions](http://www.baeldung.com/java-assert)
|
||||||
|
- [Pass-By-Value as a Parameter Passing Mechanism in Java](http://www.baeldung.com/java-pass-by-value-or-pass-by-reference)
|
||||||
|
- [Check If a String Is Numeric in Java](http://www.baeldung.com/java-check-string-number)
|
||||||
|
- [Variable and Method Hiding in Java](http://www.baeldung.com/java-variable-method-hiding)
|
||||||
|
- [Access Modifiers in Java](http://www.baeldung.com/java-access-modifiers)
|
||||||
|
- [NaN in Java](http://www.baeldung.com/java-not-a-number)
|
||||||
|
- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
|
||||||
|
- [Why Use char[] Array Over a String for Storing Passwords in Java?](http://www.baeldung.com/java-storing-passwords)
|
||||||
|
@ -198,6 +198,11 @@
|
|||||||
<artifactId>mail</artifactId>
|
<artifactId>mail</artifactId>
|
||||||
<version>${javax.mail.version}</version>
|
<version>${javax.mail.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.mail</groupId>
|
||||||
|
<artifactId>mail</artifactId>
|
||||||
|
<version>1.5.0-b01</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
49
core-java/src/main/java/com/baeldung/array/JaggedArray.java
Normal file
49
core-java/src/main/java/com/baeldung/array/JaggedArray.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package com.baeldung.array;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class JaggedArray {
|
||||||
|
|
||||||
|
int[][] shortHandFormInitialization() {
|
||||||
|
int[][] jaggedArr = { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } };
|
||||||
|
return jaggedArr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int[][] declarationAndThenInitialization() {
|
||||||
|
int[][] jaggedArr = new int[3][];
|
||||||
|
jaggedArr[0] = new int[] { 1, 2 };
|
||||||
|
jaggedArr[1] = new int[] { 3, 4, 5 };
|
||||||
|
jaggedArr[2] = new int[] { 6, 7, 8, 9 };
|
||||||
|
return jaggedArr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int[][] declarationAndThenInitializationUsingUserInputs() {
|
||||||
|
int[][] jaggedArr = new int[3][];
|
||||||
|
jaggedArr[0] = new int[2];
|
||||||
|
jaggedArr[1] = new int[3];
|
||||||
|
jaggedArr[2] = new int[4];
|
||||||
|
initializeElements(jaggedArr);
|
||||||
|
return jaggedArr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initializeElements(int[][] jaggedArr) {
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
for (int outer = 0; outer < jaggedArr.length; outer++) {
|
||||||
|
for (int inner = 0; inner < jaggedArr[outer].length; inner++) {
|
||||||
|
jaggedArr[outer][inner] = sc.nextInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void printElements(int[][] jaggedArr) {
|
||||||
|
for (int index = 0; index < jaggedArr.length; index++) {
|
||||||
|
System.out.println(Arrays.toString(jaggedArr[index]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] getElementAtGivenIndex(int[][] jaggedArr, int index) {
|
||||||
|
return jaggedArr[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package com.baeldung.keyword;
|
package com.baeldung.keyword;
|
||||||
|
|
||||||
import com.baeldung.keyword.superkeyword.SuperSub;
|
import com.baeldung.keyword.superkeyword.SuperSub;
|
||||||
import com.baeldung.keyword.thiskeyword.KeywordTest;
|
import com.baeldung.keyword.thiskeyword.KeywordUnitTest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Gebruiker on 5/14/2018.
|
* Created by Gebruiker on 5/14/2018.
|
||||||
@ -9,7 +9,7 @@ import com.baeldung.keyword.thiskeyword.KeywordTest;
|
|||||||
public class KeywordDemo {
|
public class KeywordDemo {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
KeywordTest keyword = new KeywordTest();
|
KeywordUnitTest keyword = new KeywordUnitTest();
|
||||||
|
|
||||||
SuperSub child = new SuperSub("message from the child class");
|
SuperSub child = new SuperSub("message from the child class");
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package com.baeldung.keyword.thiskeyword;
|
package com.baeldung.keyword.thiskeyword;
|
||||||
|
|
||||||
public class KeywordTest {
|
public class KeywordUnitTest {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private int age;
|
private int age;
|
||||||
|
|
||||||
public KeywordTest() {
|
public KeywordUnitTest() {
|
||||||
this("John", 27);
|
this("John", 27);
|
||||||
this.printMessage();
|
this.printMessage();
|
||||||
printInstance(this);
|
printInstance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeywordTest(String name, int age) {
|
public KeywordUnitTest(String name, int age) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.age = age;
|
this.age = age;
|
||||||
}
|
}
|
||||||
@ -20,11 +20,11 @@ public class KeywordTest {
|
|||||||
System.out.println("invoked by this");
|
System.out.println("invoked by this");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printInstance(KeywordTest thisKeyword) {
|
public void printInstance(KeywordUnitTest thisKeyword) {
|
||||||
System.out.println(thisKeyword);
|
System.out.println(thisKeyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeywordTest getCurrentInstance() {
|
public KeywordUnitTest getCurrentInstance() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,8 +33,8 @@ public class KeywordTest {
|
|||||||
boolean isInnerClass = true;
|
boolean isInnerClass = true;
|
||||||
|
|
||||||
public ThisInnerClass() {
|
public ThisInnerClass() {
|
||||||
KeywordTest thisKeyword = KeywordTest.this;
|
KeywordUnitTest thisKeyword = KeywordUnitTest.this;
|
||||||
String outerString = KeywordTest.this.name;
|
String outerString = KeywordUnitTest.this.name;
|
||||||
System.out.println(this.isInnerClass);
|
System.out.println(this.isInnerClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,20 @@
|
|||||||
package com.baeldung.linkedlist;
|
package com.baeldung.linkedlist;
|
||||||
|
|
||||||
import com.baeldung.linkedlist.LinkedList.Node;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import com.baeldung.linkedlist.Node;
|
||||||
|
|
||||||
public class MiddleElementLookup {
|
public class MiddleElementLookup {
|
||||||
|
|
||||||
public static String findMiddleElement(Node head) {
|
public static String findMiddleElementLinkedList(LinkedList<String> linkedList) {
|
||||||
|
if (linkedList == null || linkedList.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return linkedList.get((linkedList.size() - 1) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String findMiddleElementFromHead(Node head) {
|
||||||
if (head == null) {
|
if (head == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -26,7 +36,7 @@ public class MiddleElementLookup {
|
|||||||
return current.data();
|
return current.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String findMiddleElement1PassRecursively(Node head) {
|
public static String findMiddleElementFromHead1PassRecursively(Node head) {
|
||||||
if (head == null) {
|
if (head == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -53,7 +63,7 @@ public class MiddleElementLookup {
|
|||||||
middleAux.length--;
|
middleAux.length--;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String findMiddleElement1PassIteratively(Node head) {
|
public static String findMiddleElementFromHead1PassIteratively(Node head) {
|
||||||
if (head == null) {
|
if (head == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
34
core-java/src/main/java/com/baeldung/linkedlist/Node.java
Normal file
34
core-java/src/main/java/com/baeldung/linkedlist/Node.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package com.baeldung.linkedlist;
|
||||||
|
|
||||||
|
public class Node {
|
||||||
|
private Node next;
|
||||||
|
private String data;
|
||||||
|
|
||||||
|
public Node(String data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String data() {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(String data) {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasNext() {
|
||||||
|
return next != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node next() {
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNext(Node next) {
|
||||||
|
this.next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return this.data;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.baeldung.array;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class JaggedArrayUnitTest {
|
||||||
|
|
||||||
|
private JaggedArray obj = new JaggedArray();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenInitializedUsingShortHandForm_thenCorrect() {
|
||||||
|
assertArrayEquals(new int[][] { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } }, obj.shortHandFormInitialization());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenInitializedWithDeclarationAndThenInitalization_thenCorrect() {
|
||||||
|
assertArrayEquals(new int[][] { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } }, obj.declarationAndThenInitialization());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenInitializedWithDeclarationAndThenInitalizationUsingUserInputs_thenCorrect() {
|
||||||
|
InputStream is = new ByteArrayInputStream("1 2 3 4 5 6 7 8 9".getBytes());
|
||||||
|
System.setIn(is);
|
||||||
|
assertArrayEquals(new int[][] { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } }, obj.declarationAndThenInitializationUsingUserInputs());
|
||||||
|
System.setIn(System.in);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenJaggedArrayAndAnIndex_thenReturnArrayAtGivenIndex() {
|
||||||
|
int[][] jaggedArr = { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } };
|
||||||
|
assertArrayEquals(new int[] { 1, 2 }, obj.getElementAtGivenIndex(jaggedArr, 0));
|
||||||
|
assertArrayEquals(new int[] { 3, 4, 5 }, obj.getElementAtGivenIndex(jaggedArr, 1));
|
||||||
|
assertArrayEquals(new int[] { 6, 7, 8, 9 }, obj.getElementAtGivenIndex(jaggedArr, 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenJaggedArray_whenUsingArraysAPI_thenVerifyPrintedElements() {
|
||||||
|
int[][] jaggedArr = { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } };
|
||||||
|
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||||
|
System.setOut(new PrintStream(outContent));
|
||||||
|
obj.printElements(jaggedArr);
|
||||||
|
assertEquals("[1, 2]\n[3, 4, 5]\n[6, 7, 8, 9]\n", outContent.toString());
|
||||||
|
System.setOut(System.out);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -11,7 +11,7 @@ import java.util.Locale;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class DecimalFormatExamplesTest {
|
public class DecimalFormatExamplesUnitTest {
|
||||||
|
|
||||||
double d = 1234567.89;
|
double d = 1234567.89;
|
||||||
|
|
@ -13,7 +13,7 @@ import java.util.TimeZone;
|
|||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class DaylightSavingTimeExamplesTest {
|
public class DaylightSavingTimeExamplesUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenItalianTimeZone_WhenDSTHappens_ThenCorrectlyShiftTimeZone() throws ParseException {
|
public void givenItalianTimeZone_WhenDSTHappens_ThenCorrectlyShiftTimeZone() throws ParseException {
|
@ -11,7 +11,7 @@ import java.util.TimeZone;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class DaylightSavingTimeJavaTimeExamplesTest {
|
public class DaylightSavingTimeJavaTimeExamplesUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenItalianTimeZone_WhenDSTHappens_ThenCorrectlyShiftTimeZone() throws ParseException {
|
public void givenItalianTimeZone_WhenDSTHappens_ThenCorrectlyShiftTimeZone() throws ParseException {
|
@ -3,7 +3,7 @@ package com.baeldung.extension;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ExtensionTest {
|
public class ExtensionUnitTest {
|
||||||
private Extension extension = new Extension();
|
private Extension extension = new Extension();
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -8,7 +8,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class ApplicationTest {
|
public class ApplicationUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void main_NoInputState_TextPrintedToConsole() throws Exception {
|
public void main_NoInputState_TextPrintedToConsole() throws Exception {
|
@ -5,7 +5,7 @@ import org.junit.Assert;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class UserTest {
|
public class UserUnitTest {
|
||||||
|
|
||||||
private User user;
|
private User user;
|
||||||
private User comparisonUser;
|
private User comparisonUser;
|
@ -6,14 +6,14 @@ import junit.framework.Test;
|
|||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
public class AppTest extends TestCase {
|
public class AppUnitTest extends TestCase {
|
||||||
|
|
||||||
public AppTest(String testName) {
|
public AppUnitTest(String testName) {
|
||||||
super( testName );
|
super( testName );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return new TestSuite(AppTest.class);
|
return new TestSuite(AppUnitTest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("static-access")
|
@SuppressWarnings("static-access")
|
@ -6,7 +6,7 @@ import static org.assertj.core.api.Assertions.*;
|
|||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
public class UserTest {
|
public class UserUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() {
|
public void givenUserInstance_whenIntializedWithNew_thenInstanceIsNotNull() {
|
@ -7,7 +7,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.junit.runners.JUnit4;
|
import org.junit.runners.JUnit4;
|
||||||
|
|
||||||
@RunWith(JUnit4.class)
|
@RunWith(JUnit4.class)
|
||||||
public class InnerInterfaceTests {
|
public class InnerInterfaceUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenCustomerListJoined_thenReturnsJoinedNames() {
|
public void whenCustomerListJoined_thenReturnsJoinedNames() {
|
||||||
Customer.List customerList = new CommaSeparatedCustomers();
|
Customer.List customerList = new CommaSeparatedCustomers();
|
@ -7,7 +7,7 @@ import static org.junit.Assert.assertEquals;
|
|||||||
/**
|
/**
|
||||||
* The class presents various ways of finding the name of currently executed method.
|
* The class presents various ways of finding the name of currently executed method.
|
||||||
*/
|
*/
|
||||||
public class CurrentlyExecutedMethodFinderTest {
|
public class CurrentlyExecutedMethodFinderUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenCurrentThread_whenGetStackTrace_thenFindMethod() {
|
public void givenCurrentThread_whenGetStackTrace_thenFindMethod() {
|
@ -23,8 +23,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
import com.baeldung.javanetworking.uriurl.URLDemo;
|
import com.baeldung.javanetworking.uriurl.URLDemo;
|
||||||
|
|
||||||
@FixMethodOrder
|
@FixMethodOrder
|
||||||
public class URIDemoTest {
|
public class URIDemoLiveTest {
|
||||||
private final Logger log = LoggerFactory.getLogger(URIDemoTest.class);
|
private final Logger log = LoggerFactory.getLogger(URIDemoLiveTest.class);
|
||||||
String URISTRING = "https://wordpress.org:443/support/topic/page-jumps-within-wordpress/?replies=3#post-2278484";
|
String URISTRING = "https://wordpress.org:443/support/topic/page-jumps-within-wordpress/?replies=3#post-2278484";
|
||||||
// parsed locator
|
// parsed locator
|
||||||
static String URISCHEME = "https";
|
static String URISCHEME = "https";
|
@ -21,8 +21,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
import com.baeldung.javanetworking.uriurl.URLDemo;
|
import com.baeldung.javanetworking.uriurl.URLDemo;
|
||||||
|
|
||||||
@FixMethodOrder
|
@FixMethodOrder
|
||||||
public class URLDemoTest {
|
public class URLDemoLiveTest {
|
||||||
private final Logger log = LoggerFactory.getLogger(URLDemoTest.class);
|
private final Logger log = LoggerFactory.getLogger(URLDemoLiveTest.class);
|
||||||
static String URLSTRING = "https://wordpress.org:443/support/topic/page-jumps-within-wordpress/?replies=3#post-2278484";
|
static String URLSTRING = "https://wordpress.org:443/support/topic/page-jumps-within-wordpress/?replies=3#post-2278484";
|
||||||
// parsed locator
|
// parsed locator
|
||||||
static String URLPROTOCOL = "https";
|
static String URLPROTOCOL = "https";
|
@ -15,7 +15,7 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
@RunWith(MockitoJUnitRunner.class)
|
||||||
public class BatchProcessingTest {
|
public class BatchProcessingLiveTest {
|
||||||
|
|
||||||
|
|
||||||
@InjectMocks
|
@InjectMocks
|
@ -24,7 +24,7 @@ import com.sun.rowset.JdbcRowSetImpl;
|
|||||||
import com.sun.rowset.JoinRowSetImpl;
|
import com.sun.rowset.JoinRowSetImpl;
|
||||||
import com.sun.rowset.WebRowSetImpl;
|
import com.sun.rowset.WebRowSetImpl;
|
||||||
|
|
||||||
public class JdbcRowSetTest {
|
public class JdbcRowSetLiveTest {
|
||||||
Statement stmt = null;
|
Statement stmt = null;
|
||||||
String username = "sa";
|
String username = "sa";
|
||||||
String password = "";
|
String password = "";
|
@ -5,6 +5,6 @@ import org.junit.runners.Suite;
|
|||||||
|
|
||||||
@RunWith(Suite.class)
|
@RunWith(Suite.class)
|
||||||
@Suite.SuiteClasses({ RegistrationUnitTest.class, SignInUnitTest.class })
|
@Suite.SuiteClasses({ RegistrationUnitTest.class, SignInUnitTest.class })
|
||||||
public class SuiteTest {
|
public class SuiteUnitTest {
|
||||||
|
|
||||||
}
|
}
|
@ -33,7 +33,7 @@ import java.util.Date;
|
|||||||
/**
|
/**
|
||||||
* Created by adi on 4/14/18.
|
* Created by adi on 4/14/18.
|
||||||
*/
|
*/
|
||||||
public class JavaKeyStoreTest {
|
public class JavaKeyStoreUnitTest {
|
||||||
|
|
||||||
private JavaKeyStore keyStore;
|
private JavaKeyStore keyStore;
|
||||||
|
|
@ -2,51 +2,46 @@ package com.baeldung.linkedlist;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class MiddleElementLookupUnitTest {
|
public class MiddleElementLookupUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenFindingMiddle_thenMiddleFound() {
|
public void whenFindingMiddleLinkedList_thenMiddleFound() {
|
||||||
String middle = MiddleElementLookup.findMiddleElement(createList(5).head());
|
assertEquals("3", MiddleElementLookup.findMiddleElementLinkedList(createLinkedList(5)));
|
||||||
assertEquals("3", middle);
|
assertEquals("2", MiddleElementLookup.findMiddleElementLinkedList(createLinkedList(4)));
|
||||||
|
|
||||||
middle = MiddleElementLookup.findMiddleElement(createList(4).head());
|
|
||||||
assertEquals("2", middle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenFindingMiddle1PassRecursively_thenMiddleFound() {
|
public void whenFindingMiddleFromHead_thenMiddleFound() {
|
||||||
String middle = MiddleElementLookup.findMiddleElement1PassRecursively(createList(5).head());
|
assertEquals("3", MiddleElementLookup.findMiddleElementFromHead(createNodesList(5)));
|
||||||
assertEquals("3", middle);
|
assertEquals("2", MiddleElementLookup.findMiddleElementFromHead(createNodesList(4)));
|
||||||
|
|
||||||
middle = MiddleElementLookup.findMiddleElement1PassRecursively(createList(4).head());
|
|
||||||
assertEquals("2", middle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenFindingMiddle1PassIteratively_thenMiddleFound() {
|
public void whenFindingMiddleFromHead1PassRecursively_thenMiddleFound() {
|
||||||
String middle = MiddleElementLookup.findMiddleElement1PassIteratively(createList(5).head());
|
assertEquals("3", MiddleElementLookup.findMiddleElementFromHead1PassRecursively(createNodesList(5)));
|
||||||
assertEquals("3", middle);
|
assertEquals("2", MiddleElementLookup.findMiddleElementFromHead1PassRecursively(createNodesList(4)));
|
||||||
|
}
|
||||||
|
|
||||||
middle = MiddleElementLookup.findMiddleElement1PassIteratively(createList(4).head());
|
@Test
|
||||||
assertEquals("2", middle);
|
public void whenFindingMiddleFromHead1PassIteratively_thenMiddleFound() {
|
||||||
|
assertEquals("3", MiddleElementLookup.findMiddleElementFromHead1PassIteratively(createNodesList(5)));
|
||||||
|
assertEquals("2", MiddleElementLookup.findMiddleElementFromHead1PassIteratively(createNodesList(4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenListEmptyOrNull_thenMiddleNull() {
|
public void whenListEmptyOrNull_thenMiddleNull() {
|
||||||
String middle = MiddleElementLookup.findMiddleElement(null);
|
assertEquals(null, MiddleElementLookup.findMiddleElementLinkedList(null));
|
||||||
assertEquals(null, middle);
|
assertEquals(null, MiddleElementLookup.findMiddleElementFromHead(null));
|
||||||
|
assertEquals(null, MiddleElementLookup.findMiddleElementFromHead1PassIteratively(null));
|
||||||
middle = MiddleElementLookup.findMiddleElement1PassIteratively(null);
|
assertEquals(null, MiddleElementLookup.findMiddleElementFromHead1PassRecursively(null));
|
||||||
assertEquals(null, middle);
|
|
||||||
|
|
||||||
middle = MiddleElementLookup.findMiddleElement1PassRecursively(null);
|
|
||||||
assertEquals(null, middle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LinkedList createList(int n) {
|
private static LinkedList<String> createLinkedList(int n) {
|
||||||
LinkedList list = new LinkedList();
|
LinkedList<String> list = new LinkedList<>();
|
||||||
|
|
||||||
for (int i = 1; i <= n; i++) {
|
for (int i = 1; i <= n; i++) {
|
||||||
list.add(String.valueOf(i));
|
list.add(String.valueOf(i));
|
||||||
@ -55,4 +50,17 @@ public class MiddleElementLookupUnitTest {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Node createNodesList(int n) {
|
||||||
|
Node head = new Node("1");
|
||||||
|
Node current = head;
|
||||||
|
|
||||||
|
for (int i = 2; i <= n; i++) {
|
||||||
|
Node newNode = new Node(String.valueOf(i));
|
||||||
|
current.setNext(newNode);
|
||||||
|
current = newNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
public class BigDecimalImplTest {
|
public class BigDecimalImplUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBigDecimalNumbers_whenAddedTogether_thenGetExpectedResult() {
|
public void givenBigDecimalNumbers_whenAddedTogether_thenGetExpectedResult() {
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
|
|
||||||
public class BigIntegerImplTest {
|
public class BigIntegerImplUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBigIntegerNumbers_whenAddedTogether_thenGetExpectedResult() {
|
public void givenBigIntegerNumbers_whenAddedTogether_thenGetExpectedResult() {
|
@ -5,7 +5,7 @@ import java.math.BigDecimal;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class FloatingPointArithmeticTest {
|
public class FloatingPointArithmeticUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenDecimalNumbers_whenAddedTogether_thenGetExpectedResult() {
|
public void givenDecimalNumbers_whenAddedTogether_thenGetExpectedResult() {
|
@ -8,7 +8,7 @@ import org.junit.Test;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
|
||||||
public class RoundTest {
|
public class RoundUnitTest {
|
||||||
private double value = 2.03456d;
|
private double value = 2.03456d;
|
||||||
private int places = 2;
|
private int places = 2;
|
||||||
private double delta = 0.0d;
|
private double delta = 0.0d;
|
@ -2,7 +2,7 @@ package com.baeldung.noclassdeffounderror;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class NoClassDefFoundErrorTest {
|
public class NoClassDefFoundErrorUnitTest {
|
||||||
|
|
||||||
@Test(expected = NoClassDefFoundError.class)
|
@Test(expected = NoClassDefFoundError.class)
|
||||||
public void givenInitErrorInClass_whenloadClass_thenNoClassDefFoundError() {
|
public void givenInitErrorInClass_whenloadClass_thenNoClassDefFoundError() {
|
@ -3,7 +3,7 @@ package com.baeldung.recursion;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class RecursionExampleTest {
|
public class RecursionExampleUnitTest {
|
||||||
|
|
||||||
RecursionExample recursion = new RecursionExample();
|
RecursionExample recursion = new RecursionExample();
|
||||||
|
|
@ -7,7 +7,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class BaeldungReflectionUtilsTest {
|
public class BaeldungReflectionUtilsUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenCustomer_whenAFieldIsNull_thenFieldNameInResult() throws Exception {
|
public void givenCustomer_whenAFieldIsNull_thenFieldNameInResult() throws Exception {
|
@ -10,7 +10,7 @@ import static org.hamcrest.CoreMatchers.equalTo;
|
|||||||
import static org.hamcrest.CoreMatchers.not;
|
import static org.hamcrest.CoreMatchers.not;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
public class EscapingCharsTest {
|
public class EscapingCharsUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void givenRegexWithDot_whenMatchingStr_thenMatches() {
|
public void givenRegexWithDot_whenMatchingStr_thenMatches() {
|
||||||
String strInput = "foof";
|
String strInput = "foof";
|
@ -4,7 +4,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
public class SneakyRunnableTest {
|
public class SneakyRunnableUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCallSneakyRunnableMethod_thenThrowException() {
|
public void whenCallSneakyRunnableMethod_thenThrowException() {
|
@ -4,7 +4,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
public class SneakyThrowsTest {
|
public class SneakyThrowsUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCallSneakyMethod_thenThrowSneakyException() {
|
public void whenCallSneakyMethod_thenThrowSneakyException() {
|
@ -3,7 +3,7 @@ package com.baeldung.string;
|
|||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class PalindromeTest {
|
public class PalindromeUnitTest {
|
||||||
|
|
||||||
private String[] words = {
|
private String[] words = {
|
||||||
"Anna",
|
"Anna",
|
@ -7,7 +7,7 @@ import java.util.Objects;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
public class StringComparisonTest {
|
public class StringComparisonUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenUsingComparisonOperator_ThenComparingStrings(){
|
public void whenUsingComparisonOperator_ThenComparingStrings(){
|
@ -12,7 +12,7 @@ import java.util.regex.PatternSyntaxException;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class StringTest {
|
public class StringUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenCallCodePointAt_thenDecimalUnicodeReturned() {
|
public void whenCallCodePointAt_thenDecimalUnicodeReturned() {
|
@ -8,7 +8,7 @@ import static org.junit.Assert.assertFalse;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class StringFormatterExampleTests {
|
public class StringFormatterExampleUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenString_whenFormatSpecifierForCalendar_thenGotExpected() {
|
public void givenString_whenFormatSpecifierForCalendar_thenGotExpected() {
|
@ -3,7 +3,7 @@ package com.baeldung.system;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class DateTimeServiceTest {
|
public class DateTimeServiceUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenClass_whenCalledMethods_thenNotNullInResult() {
|
public void givenClass_whenCalledMethods_thenNotNullInResult() {
|
@ -3,7 +3,7 @@ package com.baeldung.system;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class EnvironmentVariablesTest {
|
public class EnvironmentVariablesUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenEnvVars_whenReadPath_thenGetValueinResult() {
|
public void givenEnvVars_whenReadPath_thenGetValueinResult() {
|
@ -3,7 +3,7 @@ package com.baeldung.system;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class SystemArrayCopyTest {
|
public class SystemArrayCopyUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTwoArraysAB_whenUseArrayCopy_thenArrayCopiedFromAToBInResult() {
|
public void givenTwoArraysAB_whenUseArrayCopy_thenArrayCopiedFromAToBInResult() {
|
@ -3,7 +3,7 @@ package com.baeldung.system;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class SystemNanoTest {
|
public class SystemNanoUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenSystem_whenCalledNanoTime_thenGivesTimeinResult() {
|
public void givenSystem_whenCalledNanoTime_thenGivesTimeinResult() {
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class SystemPropertiesTest {
|
public class SystemPropertiesUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenSystem_whenCalledGetProperty_thenReturnPropertyinResult() {
|
public void givenSystem_whenCalledGetProperty_thenReturnPropertyinResult() {
|
@ -5,7 +5,7 @@ import org.junit.Ignore;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
public class WhenDetectingOSTest {
|
public class WhenDetectingOSUnitTest {
|
||||||
|
|
||||||
private DetectOS os = new DetectOS();
|
private DetectOS os = new DetectOS();
|
||||||
|
|
@ -5,7 +5,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ThreadLocalRandomTest {
|
public class ThreadLocalRandomIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenUsingThreadLocalRandom_whenGeneratingRandomIntBounded_thenCorrect() {
|
public void givenUsingThreadLocalRandom_whenGeneratingRandomIntBounded_thenCorrect() {
|
@ -7,7 +7,7 @@ import java.util.Properties;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class PropertiesLoaderTest {
|
public class PropertiesLoaderUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void loadProperties_whenPropertyReaded_thenSuccess() throws IOException {
|
public void loadProperties_whenPropertyReaded_thenSuccess() throws IOException {
|
@ -5,7 +5,7 @@ import org.junit.Test;
|
|||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
|
||||||
public class FormatterTest {
|
public class FormatterUnitTest {
|
||||||
|
|
||||||
private final static String FORMAT = "%s %s %s";
|
private final static String FORMAT = "%s %s %s";
|
||||||
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class RawTypesTest {
|
public class RawTypesUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void shouldCreateListUsingRawTypes() {
|
public void shouldCreateListUsingRawTypes() {
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
@ -27,3 +27,6 @@
|
|||||||
- [Guide to Kotlin @JvmField](http://www.baeldung.com/kotlin-jvm-field-annotation)
|
- [Guide to Kotlin @JvmField](http://www.baeldung.com/kotlin-jvm-field-annotation)
|
||||||
- [Filtering Kotlin Collections](http://www.baeldung.com/kotlin-filter-collection)
|
- [Filtering Kotlin Collections](http://www.baeldung.com/kotlin-filter-collection)
|
||||||
- [Writing to a File in Kotlin](http://www.baeldung.com/kotlin-write-file)
|
- [Writing to a File in Kotlin](http://www.baeldung.com/kotlin-write-file)
|
||||||
|
- [Lambda Expressions in Kotlin](http://www.baeldung.com/kotlin-lambda-expressions)
|
||||||
|
- [Writing Specifications with Kotlin and Spek](http://www.baeldung.com/kotlin-spek)
|
||||||
|
- [Processing JSON with Kotlin and Klaxson](http://www.baeldung.com/kotlin-json-klaxson)
|
||||||
|
48
core-kotlin/src/main/kotlin/com/baeldung/enums/CardType.kt
Normal file
48
core-kotlin/src/main/kotlin/com/baeldung/enums/CardType.kt
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package com.baeldung.enums
|
||||||
|
|
||||||
|
enum class CardType(val color: String) : ICardLimit {
|
||||||
|
SILVER("gray") {
|
||||||
|
override fun getCreditLimit(): Int {
|
||||||
|
return 100000
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun calculateCashbackPercent(): Float {
|
||||||
|
return 0.25f
|
||||||
|
}
|
||||||
|
},
|
||||||
|
GOLD("yellow") {
|
||||||
|
override fun getCreditLimit(): Int {
|
||||||
|
return 200000
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun calculateCashbackPercent(): Float {
|
||||||
|
return 0.5f
|
||||||
|
}
|
||||||
|
},
|
||||||
|
PLATINUM("black") {
|
||||||
|
override fun getCreditLimit(): Int {
|
||||||
|
return 300000
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun calculateCashbackPercent(): Float {
|
||||||
|
return 0.75f
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun getCardTypeByColor(color: String): CardType? {
|
||||||
|
for (cardType in CardType.values()) {
|
||||||
|
if (cardType.color.equals(color)) {
|
||||||
|
return cardType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCardTypeByName(name: String): CardType {
|
||||||
|
return CardType.valueOf(name.toUpperCase())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract fun calculateCashbackPercent(): Float
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package com.baeldung.enums
|
||||||
|
|
||||||
|
interface ICardLimit {
|
||||||
|
fun getCreditLimit(): Int
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package com.baeldung.enums
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions
|
||||||
|
import org.junit.jupiter.api.Assertions.assertEquals
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
|
||||||
|
internal class CardTypeUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenSilverCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() {
|
||||||
|
assertEquals(0.25f, CardType.SILVER.calculateCashbackPercent())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenGoldCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() {
|
||||||
|
assertEquals(0.5f, CardType.GOLD.calculateCashbackPercent())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenPlatinumCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() {
|
||||||
|
assertEquals(0.75f, CardType.PLATINUM.calculateCashbackPercent())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenSilverCardType_whenGetCreditLimit_thenReturnCreditLimit() {
|
||||||
|
assertEquals(100000, CardType.SILVER.getCreditLimit())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenGoldCardType_whenGetCreditLimit_thenReturnCreditLimit() {
|
||||||
|
assertEquals(200000, CardType.GOLD.getCreditLimit())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenPlatinumCardType_whenGetCreditLimit_thenReturnCreditLimit() {
|
||||||
|
assertEquals(300000, CardType.PLATINUM.getCreditLimit())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenSilverCardType_whenCheckColor_thenReturnColor() {
|
||||||
|
assertEquals("gray", CardType.SILVER.color)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenGoldCardType_whenCheckColor_thenReturnColor() {
|
||||||
|
assertEquals("yellow", CardType.GOLD.color)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun givenPlatinumCardType_whenCheckColor_thenReturnColor() {
|
||||||
|
assertEquals("black", CardType.PLATINUM.color)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun whenGetCardTypeByColor_thenSilverCardType() {
|
||||||
|
Assertions.assertEquals(CardType.SILVER, CardType.getCardTypeByColor("gray"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun whenGetCardTypeByColor_thenGoldCardType() {
|
||||||
|
Assertions.assertEquals(CardType.GOLD, CardType.getCardTypeByColor("yellow"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun whenGetCardTypeByColor_thenPlatinumCardType() {
|
||||||
|
Assertions.assertEquals(CardType.PLATINUM, CardType.getCardTypeByColor("black"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun whenGetCardTypeByName_thenSilverCardType() {
|
||||||
|
Assertions.assertEquals(CardType.SILVER, CardType.getCardTypeByName("silver"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun whenGetCardTypeByName_thenGoldCardType() {
|
||||||
|
Assertions.assertEquals(CardType.GOLD, CardType.getCardTypeByName("gold"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun whenGetCardTypeByName_thenPlatinumCardType() {
|
||||||
|
Assertions.assertEquals(CardType.PLATINUM, CardType.getCardTypeByName("platinum"))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Binary file not shown.
@ -14,18 +14,17 @@ public class UnitTestNamingConventionRule extends AbstractJavaRule {
|
|||||||
"ManualTest",
|
"ManualTest",
|
||||||
"JdbcTest",
|
"JdbcTest",
|
||||||
"LiveTest",
|
"LiveTest",
|
||||||
"UnitTest");
|
"UnitTest",
|
||||||
|
"jmhTest");
|
||||||
|
|
||||||
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
||||||
String className = node.getImage();
|
String className = node.getImage();
|
||||||
Objects.requireNonNull(className);
|
Objects.requireNonNull(className);
|
||||||
|
|
||||||
if (className.endsWith("Test") || className.endsWith("Tests")) {
|
if (className.endsWith("Tests")
|
||||||
if (allowedEndings.stream()
|
|| (className.endsWith("Test") && allowedEndings.stream().noneMatch(className::endsWith))) {
|
||||||
.noneMatch(className::endsWith)) {
|
|
||||||
addViolation(data, node);
|
addViolation(data, node);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -1 +1,3 @@
|
|||||||
### Relevant articles
|
### Relevant articles:
|
||||||
|
|
||||||
|
- [Introduction to Dagger 2](http://www.baeldung.com/dagger-2)
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-spring</artifactId>
|
<artifactId>parent-spring-4</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-spring</relativePath>
|
<relativePath>../parent-spring-4</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -54,7 +54,6 @@
|
|||||||
<http-component-version>4.4.6</http-component-version>
|
<http-component-version>4.4.6</http-component-version>
|
||||||
<drools-version>7.4.1.Final</drools-version>
|
<drools-version>7.4.1.Final</drools-version>
|
||||||
<apache-poi-version>3.13</apache-poi-version>
|
<apache-poi-version>3.13</apache-poi-version>
|
||||||
<spring.version>4.3.6.RELEASE</spring.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -10,7 +10,7 @@ import com.baeldung.drools.model.Result;
|
|||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
public class BackwardChainingTest {
|
public class BackwardChainingIntegrationTest {
|
||||||
private Result result;
|
private Result result;
|
||||||
private KieSession ksession;
|
private KieSession ksession;
|
||||||
|
|
@ -3,7 +3,6 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>ejb-client</artifactId>
|
<artifactId>ejb-client</artifactId>
|
||||||
<name>EJB3 Client Maven</name>
|
|
||||||
<description>EJB3 Client Maven</description>
|
<description>EJB3 Client Maven</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
<name>ethereumj</name>
|
<name>ethereumj</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-boot-5</artifactId>
|
<artifactId>parent-boot-1</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-5</relativePath>
|
<relativePath>../parent-boot-1</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
<name>flips</name>
|
<name>flips</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-boot-5</artifactId>
|
<artifactId>parent-boot-1</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-5</relativePath>
|
<relativePath>../parent-boot-1</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -23,7 +23,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|||||||
}, webEnvironment = SpringBootTest.WebEnvironment.MOCK)
|
}, webEnvironment = SpringBootTest.WebEnvironment.MOCK)
|
||||||
@AutoConfigureMockMvc
|
@AutoConfigureMockMvc
|
||||||
@ActiveProfiles("dev")
|
@ActiveProfiles("dev")
|
||||||
public class FlipControllerTest {
|
public class FlipControllerIntegrationTest {
|
||||||
|
|
||||||
@Autowired private MockMvc mvc;
|
@Autowired private MockMvc mvc;
|
||||||
|
|
@ -8,10 +8,10 @@
|
|||||||
<description>Flyway Callbacks Demo</description>
|
<description>Flyway Callbacks Demo</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-boot-5</artifactId>
|
<artifactId>parent-boot-1</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-5</relativePath>
|
<relativePath>../parent-boot-1</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
<artifactId>grpc-demo</artifactId>
|
<artifactId>grpc-demo</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>grpc-demo</name>
|
|
||||||
<url>http://maven.apache.org</url>
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
|
@ -11,7 +11,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.equalTo;
|
import static org.hamcrest.CoreMatchers.equalTo;
|
||||||
|
|
||||||
public class GuavaMiscUtilsTest {
|
public class GuavaMiscUtilsUnitTest {
|
||||||
@Test
|
@Test
|
||||||
public void whenHashingData_shouldReturnCorrectHashCode() throws Exception {
|
public void whenHashingData_shouldReturnCorrectHashCode() throws Exception {
|
||||||
int receivedData = 123;
|
int receivedData = 123;
|
@ -12,7 +12,7 @@ import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInA
|
|||||||
import static org.hamcrest.core.AnyOf.anyOf;
|
import static org.hamcrest.core.AnyOf.anyOf;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class GuavaMiscUtilsTest {
|
public class GuavaMiscUtilsUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenGettingLazyStackTrace_ListShouldBeReturned() throws Exception {
|
public void whenGettingLazyStackTrace_ListShouldBeReturned() throws Exception {
|
@ -13,7 +13,7 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class ZipCollectionTest {
|
public class ZipCollectionUnitTest {
|
||||||
|
|
||||||
private List<String> names;
|
private List<String> names;
|
||||||
private List<Integer> ages;
|
private List<Integer> ages;
|
@ -9,7 +9,7 @@ import java.util.stream.IntStream;
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
public class BloomFilterTest {
|
public class BloomFilterUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenBloomFilter_whenAddNStringsToIt_thenShouldNotReturnAnyFalsePositive() {
|
public void givenBloomFilter_whenAddNStringsToIt_thenShouldNotReturnAnyFalsePositive() {
|
@ -7,7 +7,7 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import com.google.common.io.CountingOutputStream;
|
import com.google.common.io.CountingOutputStream;
|
||||||
|
|
||||||
public class GuavaCountingOutputStreamTest {
|
public class GuavaCountingOutputStreamUnitTest {
|
||||||
public static final int MAX = 5;
|
public static final int MAX = 5;
|
||||||
|
|
||||||
@Test(expected = RuntimeException.class)
|
@Test(expected = RuntimeException.class)
|
@ -27,28 +27,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
@ -45,28 +45,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>parent-spring</artifactId>
|
<artifactId>parent-spring-4</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-spring</relativePath>
|
<relativePath>../parent-spring-4</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-core</artifactId>
|
<artifactId>spring-core</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${spring.version}</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<artifactId>commons-logging</artifactId>
|
<artifactId>commons-logging</artifactId>
|
||||||
@ -48,43 +48,43 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-context</artifactId>
|
<artifactId>spring-context</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-jdbc</artifactId>
|
<artifactId>spring-jdbc</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-beans</artifactId>
|
<artifactId>spring-beans</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-aop</artifactId>
|
<artifactId>spring-aop</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-tx</artifactId>
|
<artifactId>spring-tx</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-expression</artifactId>
|
<artifactId>spring-expression</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-web</artifactId>
|
<artifactId>spring-web</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-webmvc</artifactId>
|
<artifactId>spring-webmvc</artifactId>
|
||||||
<version>${org.springframework.version}</version>
|
<version>${spring.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- AOP -->
|
<!-- AOP -->
|
||||||
@ -190,8 +190,7 @@
|
|||||||
<java-version>1.8</java-version>
|
<java-version>1.8</java-version>
|
||||||
|
|
||||||
<!-- Spring -->
|
<!-- Spring -->
|
||||||
<org.springframework.version>4.3.4.RELEASE</org.springframework.version>
|
<org.springframework.security.version>4.2.6.RELEASE</org.springframework.security.version>
|
||||||
<org.springframework.security.version>4.2.0.RELEASE</org.springframework.security.version>
|
|
||||||
|
|
||||||
<org.aspectj-version>1.8.9</org.aspectj-version>
|
<org.aspectj-version>1.8.9</org.aspectj-version>
|
||||||
<javax.servlet.jsp-api.version>2.3.2-b02</javax.servlet.jsp-api.version>
|
<javax.servlet.jsp-api.version>2.3.2-b02</javax.servlet.jsp-api.version>
|
||||||
|
@ -10,3 +10,5 @@
|
|||||||
- [JPA Attribute Converters](http://www.baeldung.com/jpa-attribute-converters)
|
- [JPA Attribute Converters](http://www.baeldung.com/jpa-attribute-converters)
|
||||||
- [Mapping LOB Data in Hibernate](http://www.baeldung.com/hibernate-lob)
|
- [Mapping LOB Data in Hibernate](http://www.baeldung.com/hibernate-lob)
|
||||||
- [@Immutable in Hibernate](http://www.baeldung.com/hibernate-immutable)
|
- [@Immutable in Hibernate](http://www.baeldung.com/hibernate-immutable)
|
||||||
|
- [Pessimistic Locking in JPA](http://www.baeldung.com/jpa-pessimistic-locking)
|
||||||
|
|
||||||
|
@ -6,10 +6,10 @@
|
|||||||
<name>hystrix</name>
|
<name>hystrix</name>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-boot-5</artifactId>
|
<artifactId>parent-boot-1</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-5</relativePath>
|
<relativePath>../parent-boot-1</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -4,7 +4,7 @@ import org.javalite.activejdbc.Base;
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class ProductTest {
|
public class ProductUnitTest {
|
||||||
|
|
||||||
//@Test
|
//@Test
|
||||||
public void givenSavedProduct_WhenFindFirst_ThenSavedProductIsReturned() {
|
public void givenSavedProduct_WhenFindFirst_ThenSavedProductIsReturned() {
|
4
java-spi/README.md
Normal file
4
java-spi/README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
|
||||||
|
- [Java Service Provider Interface](http://www.baeldung.com/java-spi)
|
5
java-vavr-stream/README.md
Normal file
5
java-vavr-stream/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
|
||||||
|
- [Java Streams vs Vavr Streams](http://www.baeldung.com/vavr-java-streams)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user