Merge remote-tracking branch 'refs/remotes/eugenp/master'
This commit is contained in:
@@ -1,11 +0,0 @@
|
|||||||
package com.baeldung.examples.guice.marker;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Baeldung
|
|
||||||
*/
|
|
||||||
public interface Communicator {
|
|
||||||
|
|
||||||
public boolean sendMessage(String message);
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung.examples.guice</groupId>
|
<groupId>com.baeldung.examples.guice</groupId>
|
||||||
<artifactId>guice-intro</artifactId>
|
<artifactId>guice</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -30,5 +30,5 @@
|
|||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<guice.version>4.1.0</guice.version>
|
<guice.version>4.1.0</guice.version>
|
||||||
</properties>
|
</properties>
|
||||||
<name>guice-intro</name>
|
<name>guice</name>
|
||||||
</project>
|
</project>
|
||||||
+1
-5
@@ -10,7 +10,7 @@ import java.util.Scanner;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public class RunGuice {
|
public class RunGuice {
|
||||||
|
|
||||||
@@ -18,14 +18,10 @@ public class RunGuice {
|
|||||||
Injector injector = Guice.createInjector(new BasicModule(), new AOPModule());
|
Injector injector = Guice.createInjector(new BasicModule(), new AOPModule());
|
||||||
Communication comms = injector.getInstance(Communication.class);
|
Communication comms = injector.getInstance(Communication.class);
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
System.out.println("Enter your message to be sent; press Q to quit and P to print the message log");
|
|
||||||
while (true) {
|
while (true) {
|
||||||
String input = scanner.nextLine();
|
String input = scanner.nextLine();
|
||||||
if (input.equalsIgnoreCase("q")) {
|
if (input.equalsIgnoreCase("q")) {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
|
||||||
if (input.equalsIgnoreCase("p")) {
|
|
||||||
comms.print();
|
|
||||||
} else {
|
} else {
|
||||||
comms.sendMessage(input);
|
comms.sendMessage(input);
|
||||||
}
|
}
|
||||||
+4
-21
@@ -10,7 +10,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public class Communication {
|
public class Communication {
|
||||||
|
|
||||||
@@ -19,37 +19,20 @@ public class Communication {
|
|||||||
@Inject
|
@Inject
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
private Queue<String> messageLog;
|
|
||||||
|
|
||||||
@Named("CommsUUID")
|
|
||||||
private String commsID;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private DefaultCommunicator communicator;
|
private DefaultCommunicator communicator;
|
||||||
|
|
||||||
public Communication(Boolean keepRecords) {
|
public Communication(Boolean keepRecords) {
|
||||||
if (keepRecords) {
|
if (keepRecords) {
|
||||||
messageLog = new LinkedList();
|
System.out.println("keeping records");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sendMessage(String message) {
|
public boolean sendMessage(String message) {
|
||||||
if (!message.isEmpty() && messageLog != null) {
|
|
||||||
messageLog.add(message);
|
|
||||||
}
|
|
||||||
return communicator.sendMessage(message);
|
return communicator.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print() {
|
|
||||||
if (messageLog != null) {
|
|
||||||
for (String message : messageLog) {
|
|
||||||
logger.info(message);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.info("Message logging wasn't enabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DefaultCommunicator getCommunicator() {
|
public DefaultCommunicator getCommunicator() {
|
||||||
return this.communicator;
|
return this.communicator;
|
||||||
}
|
}
|
||||||
+4
-1
@@ -5,7 +5,10 @@ import com.baeldung.examples.guice.marker.Communicator;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.name.Named;
|
import com.google.inject.name.Named;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author baeldung
|
||||||
|
*/
|
||||||
public class DefaultCommunicator implements Communicator {
|
public class DefaultCommunicator implements Communicator {
|
||||||
|
|
||||||
private CommunicationMode defaultCommsMode;
|
private CommunicationMode defaultCommsMode;
|
||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package com.baeldung.examples.guice;
|
package com.baeldung.examples.guice;
|
||||||
|
|
||||||
import com.baeldung.examples.guice.aop.MessageSentLoggable;
|
import com.baeldung.examples.guice.aop.MessageSentLoggable;
|
||||||
@@ -5,7 +6,7 @@ import com.baeldung.examples.guice.constant.CommunicationModel;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baekdung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public class EmailCommunicationMode implements CommunicationMode {
|
public class EmailCommunicationMode implements CommunicationMode {
|
||||||
|
|
||||||
+1
-1
@@ -8,7 +8,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public class IMCommunicationMode implements CommunicationMode {
|
public class IMCommunicationMode implements CommunicationMode {
|
||||||
|
|
||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package com.baeldung.examples.guice;
|
package com.baeldung.examples.guice;
|
||||||
|
|
||||||
import com.baeldung.examples.guice.aop.MessageSentLoggable;
|
import com.baeldung.examples.guice.aop.MessageSentLoggable;
|
||||||
@@ -7,7 +8,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public class SMSCommunicationMode implements CommunicationMode {
|
public class SMSCommunicationMode implements CommunicationMode {
|
||||||
|
|
||||||
+3
-1
@@ -1,12 +1,14 @@
|
|||||||
|
|
||||||
package com.baeldung.examples.guice.aop;
|
package com.baeldung.examples.guice.aop;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.aopalliance.intercept.MethodInterceptor;
|
import org.aopalliance.intercept.MethodInterceptor;
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public class MessageLogger implements MethodInterceptor {
|
public class MessageLogger implements MethodInterceptor {
|
||||||
|
|
||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package com.baeldung.examples.guice.aop;
|
package com.baeldung.examples.guice.aop;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
@@ -7,7 +8,7 @@ import java.lang.annotation.Target;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package com.baeldung.examples.guice.binding;
|
package com.baeldung.examples.guice.binding;
|
||||||
|
|
||||||
import com.baeldung.examples.guice.aop.MessageLogger;
|
import com.baeldung.examples.guice.aop.MessageLogger;
|
||||||
@@ -7,7 +8,7 @@ import com.google.inject.matcher.Matchers;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public class AOPModule extends AbstractModule {
|
public class AOPModule extends AbstractModule {
|
||||||
|
|
||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package com.baeldung.examples.guice.binding;
|
package com.baeldung.examples.guice.binding;
|
||||||
|
|
||||||
import com.baeldung.examples.guice.Communication;
|
import com.baeldung.examples.guice.Communication;
|
||||||
@@ -13,7 +14,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public class BasicModule extends AbstractModule {
|
public class BasicModule extends AbstractModule {
|
||||||
|
|
||||||
+2
-1
@@ -1,8 +1,9 @@
|
|||||||
|
|
||||||
package com.baeldung.examples.guice.constant;
|
package com.baeldung.examples.guice.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public enum CommunicationModel {
|
public enum CommunicationModel {
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.baeldung.examples.guice.marker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Tayo
|
||||||
|
*/
|
||||||
|
public interface Communicator {
|
||||||
|
|
||||||
|
}
|
||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package com.baeldung.examples.guice.modules;
|
package com.baeldung.examples.guice.modules;
|
||||||
|
|
||||||
import com.baeldung.examples.guice.Communication;
|
import com.baeldung.examples.guice.Communication;
|
||||||
@@ -13,7 +14,7 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Baeldung
|
* @author baeldung
|
||||||
*/
|
*/
|
||||||
public class BasicModule extends AbstractModule {
|
public class BasicModule extends AbstractModule {
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own.
|
||||||
|
|
||||||
|
The code examples related to different libraries should go in a new package.
|
||||||
|
|
||||||
|
Remember, for advanced libraries like JUnit, Jackson, etc. we already have separate modules. Please make sure to have a look at the existing modules in such cases.
|
||||||
+65
-54
@@ -1,60 +1,71 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
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">
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<parent>
|
||||||
<parent>
|
<artifactId>parent-modules</artifactId>
|
||||||
<artifactId>parent-modules</artifactId>
|
<groupId>com.baeldung</groupId>
|
||||||
<groupId>com.baeldung</groupId>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
</parent>
|
||||||
</parent>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>libraries</artifactId>
|
<artifactId>libraries</artifactId>
|
||||||
<name>libraries</name>
|
<name>libraries</name>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
|
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cglib</groupId>
|
<groupId>cglib</groupId>
|
||||||
<artifactId>cglib</artifactId>
|
<artifactId>cglib</artifactId>
|
||||||
<version>${cglib.version}</version>
|
<version>${cglib.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>${commons-lang.version}</version>
|
<version>${commons-lang.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>${junit.version}</version>
|
<version>${junit.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.jasypt</groupId>
|
<groupId>org.jasypt</groupId>
|
||||||
<artifactId>jasypt</artifactId>
|
<artifactId>jasypt</artifactId>
|
||||||
<version>${jasypt.version}</version>
|
<version>${jasypt.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.javatuples</groupId>
|
||||||
|
<artifactId>javatuples</artifactId>
|
||||||
|
<version>${javatuples.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<version>${assertj.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
</dependencies>
|
<properties>
|
||||||
|
<cglib.version>3.2.4</cglib.version>
|
||||||
<properties>
|
<commons-lang.version>3.5</commons-lang.version>
|
||||||
<cglib.version>3.2.4</cglib.version>
|
<junit.version>4.12</junit.version>
|
||||||
<commons-lang.version>3.5</commons-lang.version>
|
<jasypt.version>1.9.2</jasypt.version>
|
||||||
<junit.version>4.12</junit.version>
|
<javatuples.version>1.2</javatuples.version>
|
||||||
<jasypt.version>1.9.2</jasypt.version>
|
<assertj.version>3.6.2</assertj.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package com.baeldung.javatuples;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.javatuples.KeyValue;
|
||||||
|
import org.javatuples.LabelValue;
|
||||||
|
import org.javatuples.Pair;
|
||||||
|
import org.javatuples.Quartet;
|
||||||
|
import org.javatuples.Triplet;
|
||||||
|
import org.javatuples.Unit;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class JavaTuplesTest {
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Test
|
||||||
|
public void whenCreatingTuples_thenCreateTuples() {
|
||||||
|
Pair<String, Integer> pair = new Pair<String, Integer>("This is a pair", 55);
|
||||||
|
Triplet<String, Integer, Double> triplet = Triplet.with("hello", 23, 33.2);
|
||||||
|
|
||||||
|
List<String> collectionOfNames = Arrays.asList("john", "doe", "anne", "alex");
|
||||||
|
Quartet<String, String, String, String> quartet = Quartet.fromCollection(collectionOfNames);
|
||||||
|
|
||||||
|
Pair<String, String> pairFromList = Pair.fromIterable(collectionOfNames, 2);
|
||||||
|
|
||||||
|
String[] names = new String[] { "john", "doe", "anne" };
|
||||||
|
Triplet<String, String, String> triplet2 = Triplet.fromArray(names);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetValuexFromTuples_thenRetriveValueWithType() {
|
||||||
|
Quartet<String, Double, Integer, String> quartet = Quartet.with("john", 72.5, 32, "1051 SW");
|
||||||
|
|
||||||
|
String name = quartet.getValue0();
|
||||||
|
Integer age = quartet.getValue2();
|
||||||
|
assertThat(name).isEqualTo("john");
|
||||||
|
assertThat(age).isEqualTo(32);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetKeyValue_thenGetKeyValue() {
|
||||||
|
KeyValue<Integer, String> keyValue = KeyValue.with(5, "F");
|
||||||
|
Integer key = keyValue.getKey();
|
||||||
|
String value = keyValue.getValue();
|
||||||
|
|
||||||
|
assertThat(key).isEqualTo(5);
|
||||||
|
assertThat(value).isEqualTo("F");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetLabelValue_thenGetLabelValue() {
|
||||||
|
LabelValue<Integer, String> labelValue = LabelValue.with(5, "F");
|
||||||
|
Integer key = labelValue.getLabel();
|
||||||
|
String value = labelValue.getValue();
|
||||||
|
|
||||||
|
assertThat(key).isEqualTo(5);
|
||||||
|
assertThat(value).isEqualTo("F");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenGetValueFromTuples_thenRetriveValueWithoutType() {
|
||||||
|
Quartet<String, Double, Integer, String> quartet = Quartet.with("john", 72.5, 32, "1051 SW");
|
||||||
|
|
||||||
|
String name = (String) quartet.getValue(0);
|
||||||
|
Integer age = (Integer) quartet.getValue(2);
|
||||||
|
assertThat(name).isEqualTo("john");
|
||||||
|
assertThat(age).isEqualTo(32);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSetValueInTuple_thenGetANewTuple() {
|
||||||
|
Pair<String, Integer> john = Pair.with("john", 32);
|
||||||
|
Pair<String, Integer> alex = john.setAt0("alex");
|
||||||
|
assertThat(john.toString()).isNotEqualTo(alex.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenAddNewElement_thenCreateNewTuple() {
|
||||||
|
Pair<String, Integer> pair1 = Pair.with("john", 32);
|
||||||
|
Triplet<String, Integer, String> triplet1 = pair1.add("1051 SW");
|
||||||
|
assertThat(triplet1.contains("john"));
|
||||||
|
assertThat(triplet1.contains(32));
|
||||||
|
assertThat(triplet1.contains("1051 SW"));
|
||||||
|
|
||||||
|
Pair<String, Integer> pair2 = Pair.with("alex", 45);
|
||||||
|
Quartet<String, Integer, String, Integer> quartet2 = pair1.add(pair2);
|
||||||
|
assertThat(quartet2.containsAll(pair1));
|
||||||
|
assertThat(quartet2.containsAll(pair2));
|
||||||
|
|
||||||
|
Quartet<String, Integer, String, Integer> quartet1 = pair1.add("alex", 45);
|
||||||
|
assertThat(quartet1.containsAll("alex", "john", 32, 45));
|
||||||
|
|
||||||
|
Triplet<String, String, Integer> triplet2 = pair1.addAt1("1051 SW");
|
||||||
|
assertThat(triplet2.indexOf("john")).isEqualTo(0);
|
||||||
|
assertThat(triplet2.indexOf("1051 SW")).isEqualTo(1);
|
||||||
|
assertThat(triplet2.indexOf(32)).isEqualTo(2);
|
||||||
|
|
||||||
|
Unit<Integer> unit = pair1.removeFrom0();
|
||||||
|
assertThat(unit.contains(32));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenCallingToList_thenReturnList() {
|
||||||
|
Quartet<String, Double, Integer, String> quartet = Quartet.with("john", 72.5, 32, "1051 SW");
|
||||||
|
List<Object> list = quartet.toList();
|
||||||
|
assertThat(list.size()).isEqualTo(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenCallingToArray_thenReturnArray() {
|
||||||
|
Quartet<String, Double, Integer, String> quartet = Quartet.with("john", 72.5, 32, "1051 SW");
|
||||||
|
Object[] array = quartet.toArray();
|
||||||
|
assertThat(array.length).isEqualTo(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
<module>guava</module>
|
<module>guava</module>
|
||||||
<module>guava18</module>
|
<module>guava18</module>
|
||||||
<module>guava19</module>
|
<module>guava19</module>
|
||||||
<module>guice-intro</module>
|
<module>guice</module>
|
||||||
<module>disruptor</module>
|
<module>disruptor</module>
|
||||||
|
|
||||||
<module>handling-spring-static-resources</module>
|
<module>handling-spring-static-resources</module>
|
||||||
|
|||||||
Reference in New Issue
Block a user