Merge branch 'master' of https://github.com/eugenp/tutorials into BAEL_3301_testing_@ConfigurationProperties
This commit is contained in:
-20
@@ -1,20 +0,0 @@
|
||||
package com.baeldung.array;
|
||||
|
||||
public class Find2ndLargestInArray {
|
||||
|
||||
public static int find2ndLargestElement(int[] array) {
|
||||
int maxElement = array[0];
|
||||
int secondLargestElement = -1;
|
||||
|
||||
for (int index = 0; index < array.length; index++) {
|
||||
if (maxElement <= array[index]) {
|
||||
secondLargestElement = maxElement;
|
||||
maxElement = array[index];
|
||||
} else if (secondLargestElement < array[index]) {
|
||||
secondLargestElement = array[index];
|
||||
}
|
||||
}
|
||||
return secondLargestElement;
|
||||
}
|
||||
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package com.baeldung.array;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FindElementInArray {
|
||||
|
||||
public static boolean findGivenElementInArrayWithoutUsingStream(int[] array, int element) {
|
||||
boolean actualResult = false;
|
||||
|
||||
for (int index = 0; index < array.length; index++) {
|
||||
if (element == array[index]) {
|
||||
actualResult = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return actualResult;
|
||||
}
|
||||
|
||||
public static boolean findGivenElementInArrayUsingStream(int[] array, int element) {
|
||||
return Arrays.stream(array).filter(x -> element == x).findFirst().isPresent();
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.baeldung.array;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class Find2ndLargestInArrayUnitTest {
|
||||
@Test
|
||||
public void givenAnIntArray_thenFind2ndLargestElement() {
|
||||
int[] array = { 1, 3, 24, 16, 87, 20 };
|
||||
int expected2ndLargest = 24;
|
||||
|
||||
int actualSecondLargestElement = Find2ndLargestInArray.find2ndLargestElement(array);
|
||||
|
||||
Assert.assertEquals(expected2ndLargest, actualSecondLargestElement);
|
||||
}
|
||||
}
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
package com.baeldung.array;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FindElementInArrayUnitTest {
|
||||
@Test
|
||||
public void givenAnIntArray_whenNotUsingStream_thenFindAnElement() {
|
||||
int[] array = { 1, 3, 4, 8, 19, 20 };
|
||||
int element = 19;
|
||||
boolean expectedResult = true;
|
||||
boolean actualResult = FindElementInArray.findGivenElementInArrayWithoutUsingStream(array, element);
|
||||
Assert.assertEquals(expectedResult, actualResult);
|
||||
|
||||
element = 78;
|
||||
expectedResult = false;
|
||||
actualResult = FindElementInArray.findGivenElementInArrayWithoutUsingStream(array, element);
|
||||
Assert.assertEquals(expectedResult, actualResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenAnIntArray_whenUsingStream_thenFindAnElement() {
|
||||
int[] array = { 15, 16, 12, 18 };
|
||||
int element = 16;
|
||||
boolean expectedResult = true;
|
||||
boolean actualResult = FindElementInArray.findGivenElementInArrayUsingStream(array, element);
|
||||
Assert.assertEquals(expectedResult, actualResult);
|
||||
|
||||
element = 20;
|
||||
expectedResult = false;
|
||||
actualResult = FindElementInArray.findGivenElementInArrayUsingStream(array, element);
|
||||
Assert.assertEquals(expectedResult, actualResult);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
## Spring Data Couchbase Tutorial Project
|
||||
|
||||
### Relevant Articles:
|
||||
- [Intro to Spring Data Couchbase](http://www.baeldung.com/spring-data-couchbase)
|
||||
- [Entity Validation, Optimistic Locking, and Query Consistency in Spring Data Couchbase](http://www.baeldung.com/entity-validation-locking-and-query-consistency-in-spring-data-couchbase)
|
||||
- [Multiple Buckets and Spatial View Queries in Spring Data Couchbase](http://www.baeldung.com/spring-data-couchbase-buckets-and-spatial-view-queries)
|
||||
- [Intro to Spring Data Couchbase](https://www.baeldung.com/spring-data-couchbase)
|
||||
- [Entity Validation, Optimistic Locking, and Query Consistency in Spring Data Couchbase](https://www.baeldung.com/entity-validation-locking-and-query-consistency-in-spring-data-couchbase)
|
||||
- [Multiple Buckets and Spatial View Queries in Spring Data Couchbase](https://www.baeldung.com/spring-data-couchbase-buckets-and-spatial-view-queries)
|
||||
|
||||
### Overview
|
||||
This Maven project contains the Java code for Spring Data Couchbase
|
||||
@@ -25,14 +25,14 @@ mvn clean install
|
||||
|
||||
### Package Organization
|
||||
Java classes for the first two tutorials listed above are in src/main/java in the package hierarchy
|
||||
org.baeldung.spring.data.couchbase
|
||||
com.baeldung.spring.data.couchbase
|
||||
|
||||
Java classes for the multiple-bucket tutorials are in src/main/java in the package hierarchy
|
||||
org.baeldung.spring.data.couchbase2b
|
||||
com.baeldung.spring.data.couchbase2b
|
||||
|
||||
### Running the tests
|
||||
The test classes for the single-bucket tutorials are in src/test/java in the package
|
||||
org.baeldung.spring.data.couchbase.service:
|
||||
com.baeldung.spring.data.couchbase.service:
|
||||
- PersonServiceTest (abstract)
|
||||
- PersonRepositoryTest (concrete)
|
||||
- PersonTemplateServiceTest (concrete)
|
||||
@@ -41,7 +41,7 @@ org.baeldung.spring.data.couchbase.service:
|
||||
- StudentTemplateServiceTest (concrete)
|
||||
|
||||
The concrete test classes for the multiple-bucket tutorial are in src/test/java in the package
|
||||
org.baeldung.spring.data.couchbase2b.service:
|
||||
com.baeldung.spring.data.couchbase2b.service:
|
||||
- CampusRepositoryServiceImplTest
|
||||
- PersonRepositoryServiceImplTest
|
||||
- StudentRepositoryServiceImplTest
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>spring-data-couchbase-2</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<name>spring-data-couchbase-2</name>
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.baeldung.spring.data.couchbase.model;
|
||||
package com.baeldung.spring.data.couchbase.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.baeldung.spring.data.couchbase.model;
|
||||
package com.baeldung.spring.data.couchbase.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.baeldung.spring.data.couchbase.model;
|
||||
package com.baeldung.spring.data.couchbase.model;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Past;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase.repos;
|
||||
package com.baeldung.spring.data.couchbase.repos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Student;
|
||||
import com.baeldung.spring.data.couchbase.model.Student;
|
||||
|
||||
public interface CustomStudentRepository {
|
||||
List<Student> findByFirstNameStartsWith(String s);
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase.repos;
|
||||
package com.baeldung.spring.data.couchbase.repos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Student;
|
||||
import com.baeldung.spring.data.couchbase.model.Student;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase.repos;
|
||||
package com.baeldung.spring.data.couchbase.repos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Person;
|
||||
import com.baeldung.spring.data.couchbase.model.Person;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface PersonRepository extends CrudRepository<Person, String> {
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase.repos;
|
||||
package com.baeldung.spring.data.couchbase.repos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Student;
|
||||
import com.baeldung.spring.data.couchbase.model.Student;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface StudentRepository extends CrudRepository<Student, String>, CustomStudentRepository {
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package org.baeldung.spring.data.couchbase.service;
|
||||
package com.baeldung.spring.data.couchbase.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Person;
|
||||
import org.baeldung.spring.data.couchbase.repos.PersonRepository;
|
||||
import com.baeldung.spring.data.couchbase.model.Person;
|
||||
import com.baeldung.spring.data.couchbase.repos.PersonRepository;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase.service;
|
||||
package com.baeldung.spring.data.couchbase.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Person;
|
||||
import com.baeldung.spring.data.couchbase.model.Person;
|
||||
|
||||
public interface PersonService {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase.service;
|
||||
package com.baeldung.spring.data.couchbase.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Person;
|
||||
import com.baeldung.spring.data.couchbase.model.Person;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package org.baeldung.spring.data.couchbase.service;
|
||||
package com.baeldung.spring.data.couchbase.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Student;
|
||||
import org.baeldung.spring.data.couchbase.repos.StudentRepository;
|
||||
import com.baeldung.spring.data.couchbase.model.Student;
|
||||
import com.baeldung.spring.data.couchbase.repos.StudentRepository;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase.service;
|
||||
package com.baeldung.spring.data.couchbase.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Student;
|
||||
import com.baeldung.spring.data.couchbase.model.Student;
|
||||
|
||||
public interface StudentService {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase.service;
|
||||
package com.baeldung.spring.data.couchbase.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Student;
|
||||
import com.baeldung.spring.data.couchbase.model.Student;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase2b.repos;
|
||||
package com.baeldung.spring.data.couchbase2b.repos;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Campus;
|
||||
import com.baeldung.spring.data.couchbase.model.Campus;
|
||||
import org.springframework.data.couchbase.core.query.Dimensional;
|
||||
import org.springframework.data.couchbase.core.query.View;
|
||||
import org.springframework.data.geo.Distance;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase2b.repos;
|
||||
package com.baeldung.spring.data.couchbase2b.repos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Person;
|
||||
import com.baeldung.spring.data.couchbase.model.Person;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface PersonRepository extends CrudRepository<Person, String> {
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase2b.repos;
|
||||
package com.baeldung.spring.data.couchbase2b.repos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Student;
|
||||
import com.baeldung.spring.data.couchbase.model.Student;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface StudentRepository extends CrudRepository<Student, String> {
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase2b.service;
|
||||
package com.baeldung.spring.data.couchbase2b.service;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Campus;
|
||||
import com.baeldung.spring.data.couchbase.model.Campus;
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Point;
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package org.baeldung.spring.data.couchbase2b.service;
|
||||
package com.baeldung.spring.data.couchbase2b.service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Campus;
|
||||
import org.baeldung.spring.data.couchbase2b.repos.CampusRepository;
|
||||
import com.baeldung.spring.data.couchbase2b.repos.CampusRepository;
|
||||
import com.baeldung.spring.data.couchbase.model.Campus;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.geo.Distance;
|
||||
import org.springframework.data.geo.Point;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase2b.service;
|
||||
package com.baeldung.spring.data.couchbase2b.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Person;
|
||||
import com.baeldung.spring.data.couchbase.model.Person;
|
||||
|
||||
public interface PersonService {
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package org.baeldung.spring.data.couchbase2b.service;
|
||||
package com.baeldung.spring.data.couchbase2b.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Person;
|
||||
import org.baeldung.spring.data.couchbase2b.repos.PersonRepository;
|
||||
import com.baeldung.spring.data.couchbase2b.repos.PersonRepository;
|
||||
import com.baeldung.spring.data.couchbase.model.Person;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package org.baeldung.spring.data.couchbase2b.service;
|
||||
package com.baeldung.spring.data.couchbase2b.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Student;
|
||||
import com.baeldung.spring.data.couchbase.model.Student;
|
||||
|
||||
public interface StudentService {
|
||||
|
||||
+3
-3
@@ -1,11 +1,11 @@
|
||||
package org.baeldung.spring.data.couchbase2b.service;
|
||||
package com.baeldung.spring.data.couchbase2b.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.spring.data.couchbase.model.Student;
|
||||
import org.baeldung.spring.data.couchbase2b.repos.StudentRepository;
|
||||
import com.baeldung.spring.data.couchbase2b.repos.StudentRepository;
|
||||
import com.baeldung.spring.data.couchbase.model.Student;
|
||||
import org.joda.time.DateTime;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
package org.baeldung;
|
||||
package com.baeldung;
|
||||
|
||||
import org.baeldung.spring.data.couchbase2b.MultiBucketCouchbaseConfig;
|
||||
import org.baeldung.spring.data.couchbase2b.MultiBucketIntegrationTestConfig;
|
||||
import com.baeldung.spring.data.couchbase2b.MultiBucketCouchbaseConfig;
|
||||
import com.baeldung.spring.data.couchbase2b.MultiBucketIntegrationTestConfig;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -25,7 +25,7 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution
|
||||
* {@code
|
||||
* function (doc) {
|
||||
* if (doc.location &&
|
||||
* doc._class == "org.baeldung.spring.data.couchbase.model.Campus") {
|
||||
* doc._class == "com.baeldung.spring.data.couchbase.model.Campus") {
|
||||
* emit([doc.location.x, doc.location.y], null);
|
||||
* }
|
||||
* }}
|
||||
@@ -34,7 +34,7 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution
|
||||
* 2.4.1- view 'all' with function:
|
||||
* {@code
|
||||
* function (doc, meta) {
|
||||
* if(doc._class == "org.baeldung.spring.data.couchbase.model.Campus") {
|
||||
* if(doc._class == "com.baeldung.spring.data.couchbase.model.Campus") {
|
||||
* emit(meta.id, null);
|
||||
* }
|
||||
* }}
|
||||
@@ -42,7 +42,7 @@ import org.springframework.test.context.support.DependencyInjectionTestExecution
|
||||
* 2.4.2- view 'byName' with function:
|
||||
* {@code
|
||||
* function (doc, meta) {
|
||||
* if(doc._class == "org.baeldung.spring.data.couchbase.model.Campus" &&
|
||||
* if(doc._class == "com.baeldung.spring.data.couchbase.model.Campus" &&
|
||||
* doc.name) {
|
||||
* emit(doc.name, null);
|
||||
* }
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package org.baeldung.spring.data.couchbase;
|
||||
package com.baeldung.spring.data.couchbase;
|
||||
|
||||
import org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user