@@ -85,7 +85,3 @@ transaction.log
|
||||
*-shell.log
|
||||
|
||||
apache-cxf/cxf-aegis/baeldung.xml
|
||||
apache-fop/src/test/resources/input.xml
|
||||
apache-fop/src/test/resources/output_herold.pdf
|
||||
apache-fop/src/test/resources/output_html2fo.pdf
|
||||
apache-fop/src/test/resources/output_jtidy.pdf
|
||||
+7
-10
@@ -2,19 +2,16 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.6.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>aws-app-sync</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>aws-app-sync</name>
|
||||
|
||||
<description>Spring Boot using AWS App Sync</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest
|
||||
@Disabled
|
||||
class AwsAppSyncApplicationTests {
|
||||
class AwsAppSyncApplicationUnitTest {
|
||||
|
||||
@Test
|
||||
void givenGraphQuery_whenListEvents_thenReturnAllEvents() {
|
||||
@@ -1,44 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.groovy</groupId>
|
||||
<artifactId>determine-datatype</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmaven</groupId>
|
||||
<artifactId>groovy-maven-plugin</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<version>2.0.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.junit/junit5-engine -->
|
||||
<dependency>
|
||||
<groupId>org.junit</groupId>
|
||||
<artifactId>junit5-engine</artifactId>
|
||||
<version>${junit5.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<junit5.version>5.0.0-ALPHA</junit5.version>
|
||||
</properties>
|
||||
</project>
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package com.baeldung.groovy.determine.datatype
|
||||
|
||||
class Person {
|
||||
|
||||
private int ageAsInt
|
||||
private Double ageAsDouble
|
||||
private String ageAsString
|
||||
|
||||
Person() {}
|
||||
Person(int ageAsInt) { this.ageAsInt = ageAsInt}
|
||||
Person(Double ageAsDouble) { this.ageAsDouble = ageAsDouble}
|
||||
Person(String ageAsString) { this.ageAsString = ageAsString}
|
||||
}
|
||||
class Student extends Person {}
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
package com.baeldung.groovy.determine.datatype;
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test;
|
||||
|
||||
public class PersonTest {
|
||||
|
||||
@Test
|
||||
public void givenWhenParameterTypeIsInteger_thenReturnTrue() {
|
||||
Person personObj = new Person(10)
|
||||
Assert.assertTrue(personObj.ageAsInt instanceof Integer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWhenParameterTypeIsDouble_thenReturnTrue() {
|
||||
Person personObj = new Person(10.0)
|
||||
Assert.assertTrue((personObj.ageAsDouble).getClass() == Double)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWhenParameterTypeIsString_thenReturnTrue() {
|
||||
Person personObj = new Person("10 years")
|
||||
Assert.assertTrue(personObj.ageAsString.class == String)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenClassName_WhenParameterIsInteger_thenReturnTrue() {
|
||||
Assert.assertTrue(Person.class.getDeclaredField('ageAsInt').type == int.class)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWhenObjectIsInstanceOfType_thenReturnTrue() {
|
||||
Person personObj = new Person()
|
||||
Assert.assertTrue(personObj instanceof Person)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenWhenInstanceIsOfSubtype_thenReturnTrue() {
|
||||
Student studentObj = new Student()
|
||||
Assert.assertTrue(studentObj in Person)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenGroovyList_WhenFindClassName_thenReturnTrue() {
|
||||
def ageList = ['ageAsString','ageAsDouble', 10]
|
||||
Assert.assertTrue(ageList.class == ArrayList)
|
||||
Assert.assertTrue(ageList.getClass() == ArrayList)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenGrooyMap_WhenFindClassName_thenReturnTrue() {
|
||||
def ageMap = [ageAsString: '10 years', ageAsDouble: 10.0]
|
||||
Assert.assertFalse(ageMap.class == LinkedHashMap)
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.macaddress;
|
||||
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class GetAllMacAddressesDemo {
|
||||
|
||||
public static void main(String[] args) throws SocketException {
|
||||
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
while (networkInterfaces.hasMoreElements()) {
|
||||
NetworkInterface ni = networkInterfaces.nextElement();
|
||||
byte[] hardwareAddress = ni.getHardwareAddress();
|
||||
if (hardwareAddress != null) {
|
||||
String[] hexadecimalFormat = new String[hardwareAddress.length];
|
||||
for (int i = 0; i < hardwareAddress.length; i++) {
|
||||
hexadecimalFormat[i] = String.format("%02X", hardwareAddress[i]);
|
||||
}
|
||||
System.out.println(String.join("-", hexadecimalFormat));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.macaddress;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class MacAddressUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenNetworkInterface_whenUsingLocalHost_thenGetMacAddress() throws UnknownHostException, SocketException {
|
||||
InetAddress localHost = InetAddress.getLocalHost();
|
||||
NetworkInterface ni = NetworkInterface.getByInetAddress(localHost);
|
||||
byte[] macAddress = ni.getHardwareAddress();
|
||||
assertEquals(6, macAddress.length);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-jdk8</artifactId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>${org.mapstruct.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -71,12 +71,12 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<org.mapstruct.version>1.3.0.Final</org.mapstruct.version>
|
||||
<org.mapstruct.version>1.4.0.Beta1</org.mapstruct.version>
|
||||
<springframework.version>4.3.4.RELEASE</springframework.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<org.projectlombok.version>1.18.4</org.projectlombok.version>
|
||||
<assertj.version>3.11.1</assertj.version>
|
||||
<assertj.version>3.16.1</assertj.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.dto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CompanyDTO {
|
||||
|
||||
private List<EmployeeDTO> employees;
|
||||
|
||||
public List<EmployeeDTO> getEmployees() {
|
||||
return employees;
|
||||
}
|
||||
|
||||
public void setEmployees(List<EmployeeDTO> employees) {
|
||||
this.employees = employees;
|
||||
}
|
||||
|
||||
public void addEmployee(EmployeeDTO employeeDTO) {
|
||||
if (employees == null) {
|
||||
employees = new ArrayList<>();
|
||||
}
|
||||
|
||||
employees.add(employeeDTO);
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.dto;
|
||||
|
||||
public class EmployeeDTO {
|
||||
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.dto;
|
||||
|
||||
public class EmployeeFullNameDTO {
|
||||
|
||||
private String fullName;
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.CompanyDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Company;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper(uses = EmployeeMapper.class)
|
||||
public interface CompanyMapper {
|
||||
|
||||
CompanyDTO map(Company company);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.CompanyDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Company;
|
||||
import org.mapstruct.CollectionMappingStrategy;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
@Mapper(collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED)
|
||||
public interface CompanyMapperAdderPreferred {
|
||||
|
||||
CompanyDTO map(Company company);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeFullNameDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface EmployeeFullNameMapper {
|
||||
|
||||
List<EmployeeFullNameDTO> map(List<Employee> employees);
|
||||
|
||||
default EmployeeFullNameDTO map(Employee employee) {
|
||||
EmployeeFullNameDTO employeeInfoDTO = new EmployeeFullNameDTO();
|
||||
employeeInfoDTO.setFullName(employee.getFirstName() + " " + employee.getLastName());
|
||||
|
||||
return employeeInfoDTO;
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||
import org.mapstruct.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface EmployeeMapper {
|
||||
|
||||
List<EmployeeDTO> map(List<Employee> employees);
|
||||
|
||||
Set<EmployeeDTO> map(Set<Employee> employees);
|
||||
|
||||
Map<String, EmployeeDTO> map(Map<String, Employee> idEmployeeMap);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Company {
|
||||
|
||||
private List<Employee> employees;
|
||||
|
||||
public List<Employee> getEmployees() {
|
||||
return employees;
|
||||
}
|
||||
|
||||
public void setEmployees(List<Employee> employees) {
|
||||
this.employees = employees;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.model;
|
||||
|
||||
public class Employee {
|
||||
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
||||
public Employee(String firstName, String lastName) {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.CompanyDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Company;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CompanyMapperAdderPreferredUnitTest {
|
||||
|
||||
private CompanyMapperAdderPreferred companyMapper = Mappers.getMapper(CompanyMapperAdderPreferred.class);
|
||||
|
||||
@Test
|
||||
void whenMappingToCompanyDTO_thenExpectCorrectMappingResult() {
|
||||
Employee employee = new Employee("John", "Doe");
|
||||
Company company = new Company();
|
||||
company.setEmployees(Collections.singletonList(employee));
|
||||
|
||||
CompanyDTO result = companyMapper.map(company);
|
||||
|
||||
List<EmployeeDTO> employees = result.getEmployees();
|
||||
assertThat(employees).hasSize(1);
|
||||
assertThat(employees.get(0).getFirstName()).isEqualTo("John");
|
||||
assertThat(employees.get(0).getLastName()).isEqualTo("Doe");
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.CompanyDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Company;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class CompanyMapperUnitTest {
|
||||
|
||||
private CompanyMapper companyMapper = Mappers.getMapper(CompanyMapper.class);
|
||||
|
||||
@Test
|
||||
void whenMappingToCompanyDTO_thenExpectCorrectMappingResult() {
|
||||
Employee employee = new Employee("John", "Doe");
|
||||
Company company = new Company();
|
||||
company.setEmployees(Collections.singletonList(employee));
|
||||
|
||||
CompanyDTO result = companyMapper.map(company);
|
||||
|
||||
List<EmployeeDTO> employees = result.getEmployees();
|
||||
assertThat(employees).hasSize(1);
|
||||
assertThat(employees.get(0).getFirstName()).isEqualTo("John");
|
||||
assertThat(employees.get(0).getLastName()).isEqualTo("Doe");
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeFullNameDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class EmployeeFullNameMapperUnitTest {
|
||||
|
||||
private EmployeeFullNameMapper employeeMapper = Mappers.getMapper(EmployeeFullNameMapper.class);
|
||||
|
||||
@Test
|
||||
void whenMappingToEmployeeFullNameDTOList_thenExpectCorrectMappingResult() {
|
||||
Employee employee = new Employee("John", "Doe");
|
||||
|
||||
List<EmployeeFullNameDTO> result = employeeMapper.map(Collections.singletonList(employee));
|
||||
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(0).getFullName()).isEqualTo("John Doe");
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.baeldung.mapstruct.mappingCollections.mapper;
|
||||
|
||||
import com.baeldung.mapstruct.mappingCollections.dto.EmployeeDTO;
|
||||
import com.baeldung.mapstruct.mappingCollections.model.Employee;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class EmployeeMapperUnitTest {
|
||||
|
||||
private EmployeeMapper employeeMapper = Mappers.getMapper(EmployeeMapper.class);
|
||||
|
||||
@Test
|
||||
void whenMappingToEmployeeDTOList_thenExpectCorrectMappingResult() {
|
||||
Employee employee = new Employee("John", "Doe");
|
||||
|
||||
List<EmployeeDTO> result = employeeMapper.map(Collections.singletonList(employee));
|
||||
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get(0).getFirstName()).isEqualTo("John");
|
||||
assertThat(result.get(0).getLastName()).isEqualTo("Doe");
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenMappingToEmployeeDTOSet_thenExpectCorrectMappingResult() {
|
||||
Employee employee = new Employee("John", "Doe");
|
||||
|
||||
Set<EmployeeDTO> result = employeeMapper.map(Collections.singleton(employee));
|
||||
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.iterator().next().getFirstName()).isEqualTo("John");
|
||||
assertThat(result.iterator().next().getLastName()).isEqualTo("Doe");
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenMappingToEmployeeDTOMap_thenExpectCorrectMappingResult() {
|
||||
Employee employee = new Employee("John", "Doe");
|
||||
|
||||
Map<String, EmployeeDTO> result = employeeMapper.map(Collections.singletonMap("1", employee));
|
||||
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.get("1").getFirstName()).isEqualTo("John");
|
||||
assertThat(result.get("1").getLastName()).isEqualTo("Doe");
|
||||
}
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package com.baeldung.observer
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
interface IObservable {
|
||||
val observers: ArrayList<IObserver>
|
||||
fun add(observer: IObserver) {
|
||||
observers.add(observer)
|
||||
}
|
||||
|
||||
fun remove(observer: IObserver) {
|
||||
observers.remove(observer)
|
||||
}
|
||||
|
||||
fun sendUpdateEvent() {
|
||||
observers.forEach { it.update() }
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.baeldung.observer
|
||||
|
||||
interface IObserver {
|
||||
fun update()
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package com.baeldung.observer.delegates
|
||||
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class BaeldungNewsletter {
|
||||
val newestArticleObservers = mutableListOf<(String) -> Unit>()
|
||||
var newestArticleUrl: String by Delegates.observable("") { _, _, newValue ->
|
||||
newestArticleObservers.forEach { it(newValue) }
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
package com.baeldung.observer.delegates
|
||||
|
||||
fun main() {
|
||||
val newsletter = BaeldungNewsletter()
|
||||
newsletter.newestArticleObservers.add { newestArticleUrl ->
|
||||
println("New Baeldung article: ${newestArticleUrl}")
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package com.baeldung.observer.standard
|
||||
|
||||
import com.baeldung.observer.IObservable
|
||||
import com.baeldung.observer.IObserver
|
||||
import java.util.ArrayList
|
||||
|
||||
class BaeldungNewsletter : IObservable {
|
||||
override val observers: ArrayList<IObserver> = ArrayList()
|
||||
var newestArticleUrl = ""
|
||||
set(value) {
|
||||
field = value
|
||||
sendUpdateEvent()
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package com.baeldung.observer.standard
|
||||
|
||||
import com.baeldung.observer.IObserver
|
||||
|
||||
class BaeldungReader(private var newsletter: BaeldungNewsletter) : IObserver {
|
||||
override fun update() {
|
||||
println("New Baeldung article: ${newsletter.newestArticleUrl}")
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,11 @@
|
||||
<description>Sample R2DBC Project</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.6.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import reactor.core.publisher.Flux;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class R2dbcExampleApplicationTests {
|
||||
public class R2dbcExampleApplicationIntegrationTest {
|
||||
|
||||
|
||||
@Autowired
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user