Milestone
This commit is contained in:
parent
1d6505a2ca
commit
12b7224510
3
.idea/compiler.xml
generated
3
.idea/compiler.xml
generated
@ -2,6 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<annotationProcessing>
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="true" />
|
||||||
<profile name="Maven default annotation processors profile" enabled="true">
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
@ -9,6 +10,6 @@
|
|||||||
<module name="app" />
|
<module name="app" />
|
||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel target="1.6" />
|
<bytecodeTargetLevel target="19" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
1
.idea/gradle.xml
generated
1
.idea/gradle.xml
generated
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@ -9,7 +9,7 @@
|
|||||||
</option>
|
</option>
|
||||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" project-jdk-name="corretto-19" project-jdk-type="JavaSDK" />
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="corretto-19" project-jdk-type="JavaSDK" />
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
<option name="id" value="jpab" />
|
<option name="id" value="jpab" />
|
||||||
</component>
|
</component>
|
||||||
|
@ -9,6 +9,15 @@
|
|||||||
- Entonces, el contenido del bote se multiplica por dos y se divide entre todos los jugadores.
|
- Entonces, el contenido del bote se multiplica por dos y se divide entre todos los jugadores.
|
||||||
- Pasadas N rondas, el jugador se queda con lo que ganó + monedas iniciales.
|
- Pasadas N rondas, el jugador se queda con lo que ganó + monedas iniciales.
|
||||||
|
|
||||||
|
- Tipos de jugadores:
|
||||||
|
- Pícaro: no colabora nunca.
|
||||||
|
- Santo: colabora siempre.
|
||||||
|
- Justiciero: colabora si y solo si todos los jugadores han colaborado en el turno anterior.
|
||||||
|
|
||||||
|
Comprobar distribución de ganancia según variación en tipo de jugadores; Pícaro, santo o justiciero.
|
||||||
|
|
||||||
|
10 jugadores, 100 turnos, 100 monedas iniciales.
|
||||||
|
|
||||||
|
|
||||||
Comprobar cómo de dispuesta está la gente a contribuir a un bien, que será compartido por todos por igual,
|
Comprobar cómo de dispuesta está la gente a contribuir a un bien, que será compartido por todos por igual,
|
||||||
hayan contribuido o no.
|
hayan contribuido o no.
|
@ -3,14 +3,14 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
|
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
|
||||||
<title>Test results - Class dev.freireservices.social_altruism.chat.ChatQuickStartTest</title>
|
<title>Test results - Class dev.freireservices.social_altruism.chat.PotQuickStartTest</title>
|
||||||
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
|
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
|
||||||
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
|
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
|
||||||
<script src="../js/report.js" type="text/javascript"></script>
|
<script src="../js/report.js" type="text/javascript"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<h1>Class dev.freireservices.social_altruism.chat.ChatQuickStartTest</h1>
|
<h1>Class dev.freireservices.social_altruism.chat.PotQuickStartTest</h1>
|
||||||
<div class="breadcrumbs">
|
<div class="breadcrumbs">
|
||||||
<a href="../index.html">all</a> >
|
<a href="../index.html">all</a> >
|
||||||
<a href="../packages/dev.freireservices.social_altruism.chat.html">dev.freireservices.social_altruism.chat</a> > ChatQuickStartTest</div>
|
<a href="../packages/dev.freireservices.social_altruism.chat.html">dev.freireservices.social_altruism.chat</a> > ChatQuickStartTest</div>
|
||||||
@ -76,11 +76,11 @@
|
|||||||
<a name="testGreeterActorSendingOfGreeting"></a>
|
<a name="testGreeterActorSendingOfGreeting"></a>
|
||||||
<h3 class="failures">testGreeterActorSendingOfGreeting</h3>
|
<h3 class="failures">testGreeterActorSendingOfGreeting</h3>
|
||||||
<span class="code">
|
<span class="code">
|
||||||
<pre>java.lang.AssertionError: Timeout (10 seconds) during expectMessageClass waiting for class dev.freireservices.social_altruism.chat.ChatPotProtocol$PotReturned
|
<pre>java.lang.AssertionError: Timeout (10 seconds) during expectMessageClass waiting for class dev.freireservices.social_altruism.chat.potroom.PotRoom$PotReturned
|
||||||
at akka.actor.testkit.typed.internal.TestProbeImpl.assertFail(TestProbeImpl.scala:399)
|
at akka.actor.testkit.typed.internal.TestProbeImpl.assertFail(TestProbeImpl.scala:399)
|
||||||
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass_internal(TestProbeImpl.scala:239)
|
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass_internal(TestProbeImpl.scala:239)
|
||||||
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass(TestProbeImpl.scala:227)
|
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass(TestProbeImpl.scala:227)
|
||||||
at dev.freireservices.social_altruism.chat.ChatQuickStartTest.testGreeterActorSendingOfGreeting(ChatQuickStartTest.java:35)
|
at dev.freireservices.social_altruism.chat.PotQuickStartTest.testGreeterActorSendingOfGreeting(ChatQuickStartTest.java:35)
|
||||||
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
||||||
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
||||||
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
|
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
|
||||||
|
@ -71,8 +71,8 @@
|
|||||||
<h2>Failed tests</h2>
|
<h2>Failed tests</h2>
|
||||||
<ul class="linkList">
|
<ul class="linkList">
|
||||||
<li>
|
<li>
|
||||||
<a href="classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html">ChatQuickStartTest</a>.
|
<a href="classes/dev.freireservices.social_altruism.chat.PotQuickStartTest.html">ChatQuickStartTest</a>.
|
||||||
<a href="classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html#testGreeterActorSendingOfGreeting">testGreeterActorSendingOfGreeting</a>
|
<a href="classes/dev.freireservices.social_altruism.chat.PotQuickStartTest.html#testGreeterActorSendingOfGreeting">testGreeterActorSendingOfGreeting</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -119,7 +119,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="failures">
|
<td class="failures">
|
||||||
<a href="classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html">dev.freireservices.social_altruism.chat.ChatQuickStartTest</a>
|
<a href="classes/dev.freireservices.social_altruism.chat.PotQuickStartTest.html">dev.freireservices.social_altruism.chat.PotQuickStartTest</a>
|
||||||
</td>
|
</td>
|
||||||
<td>1</td>
|
<td>1</td>
|
||||||
<td>1</td>
|
<td>1</td>
|
||||||
|
@ -70,8 +70,8 @@
|
|||||||
<h2>Failed tests</h2>
|
<h2>Failed tests</h2>
|
||||||
<ul class="linkList">
|
<ul class="linkList">
|
||||||
<li>
|
<li>
|
||||||
<a href="../classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html">ChatQuickStartTest</a>.
|
<a href="../classes/dev.freireservices.social_altruism.chat.PotQuickStartTest.html">ChatQuickStartTest</a>.
|
||||||
<a href="../classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html#testGreeterActorSendingOfGreeting">testGreeterActorSendingOfGreeting</a>
|
<a href="../classes/dev.freireservices.social_altruism.chat.PotQuickStartTest.html#testGreeterActorSendingOfGreeting">testGreeterActorSendingOfGreeting</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@ -90,7 +90,7 @@
|
|||||||
</thread>
|
</thread>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="failures">
|
<td class="failures">
|
||||||
<a href="../classes/dev.freireservices.social_altruism.chat.ChatQuickStartTest.html">ChatQuickStartTest</a>
|
<a href="../classes/dev.freireservices.social_altruism.chat.PotQuickStartTest.html">ChatQuickStartTest</a>
|
||||||
</td>
|
</td>
|
||||||
<td>1</td>
|
<td>1</td>
|
||||||
<td>1</td>
|
<td>1</td>
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<testsuite name="dev.freireservices.social_altruism.chat.ChatQuickStartTest" tests="1" skipped="0" failures="1" errors="0" timestamp="2023-12-23T10:22:36" hostname="MacBook-Pro.local" time="10.961">
|
<testsuite name="dev.freireservices.social_altruism.chat.PotQuickStartTest" tests="1" skipped="0" failures="1" errors="0" timestamp="2023-12-23T10:22:36" hostname="MacBook-Pro.local" time="10.961">
|
||||||
<properties/>
|
<properties/>
|
||||||
<testcase name="testGreeterActorSendingOfGreeting" classname="dev.freireservices.social_altruism.chat.ChatQuickStartTest" time="10.961">
|
<testcase name="testGreeterActorSendingOfGreeting" classname="dev.freireservices.social_altruism.chat.PotQuickStartTest" time="10.961">
|
||||||
<failure message="java.lang.AssertionError: Timeout (10 seconds) during expectMessageClass waiting for class dev.freireservices.social_altruism.chat.ChatPotProtocol$PotReturned" type="java.lang.AssertionError">java.lang.AssertionError: Timeout (10 seconds) during expectMessageClass waiting for class dev.freireservices.social_altruism.chat.ChatPotProtocol$PotReturned
|
<failure message="java.lang.AssertionError: Timeout (10 seconds) during expectMessageClass waiting for class dev.freireservices.social_altruism.chat.potroom.PotRoom$PotReturned" type="java.lang.AssertionError">java.lang.AssertionError:
|
||||||
|
Timeout (10 seconds) during expectMessageClass waiting for class
|
||||||
|
dev.freireservices.social_altruism.chat.potroom.PotRoom$PotReturned
|
||||||
at akka.actor.testkit.typed.internal.TestProbeImpl.assertFail(TestProbeImpl.scala:399)
|
at akka.actor.testkit.typed.internal.TestProbeImpl.assertFail(TestProbeImpl.scala:399)
|
||||||
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass_internal(TestProbeImpl.scala:239)
|
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass_internal(TestProbeImpl.scala:239)
|
||||||
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass(TestProbeImpl.scala:227)
|
at akka.actor.testkit.typed.internal.TestProbeImpl.expectMessageClass(TestProbeImpl.scala:227)
|
||||||
at dev.freireservices.social_altruism.chat.ChatQuickStartTest.testGreeterActorSendingOfGreeting(ChatQuickStartTest.java:35)
|
at
|
||||||
|
dev.freireservices.social_altruism.chat.PotQuickStartTest.testGreeterActorSendingOfGreeting(ChatQuickStartTest.java:35)
|
||||||
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
||||||
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
||||||
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
|
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
|
||||||
@ -25,25 +28,31 @@
|
|||||||
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
|
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
|
||||||
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
|
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
|
||||||
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
|
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
|
||||||
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
|
at
|
||||||
|
org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:108)
|
||||||
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:57)
|
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:57)
|
||||||
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:39)
|
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:39)
|
||||||
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
|
at
|
||||||
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
|
org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
|
||||||
|
at
|
||||||
|
org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
|
||||||
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
|
||||||
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
|
||||||
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
|
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
|
||||||
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
|
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
|
||||||
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
|
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
|
||||||
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
|
at
|
||||||
|
org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
|
||||||
at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
|
at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
|
||||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
|
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
|
||||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
|
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
|
||||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
|
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
|
||||||
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
|
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
|
||||||
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
|
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
|
||||||
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
|
at
|
||||||
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
|
org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
|
||||||
|
at
|
||||||
|
org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
|
||||||
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
|
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
|
||||||
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
|
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
|
||||||
</failure>
|
</failure>
|
||||||
|
11
pom.xml
11
pom.xml
@ -66,6 +66,15 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.30</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -87,7 +96,7 @@
|
|||||||
<arguments>
|
<arguments>
|
||||||
<argument>-classpath</argument>
|
<argument>-classpath</argument>
|
||||||
<classpath />
|
<classpath />
|
||||||
<argument>dev.freireservices.social_altruism.chat.ChatQuickStart</argument>
|
<argument>dev.freireservices.social_altruism.chat.PotQuickStart</argument>
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -1,184 +0,0 @@
|
|||||||
package dev.freireservices.social_altruism.chat;
|
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.*;
|
|
||||||
import static java.util.Collections.emptyList;
|
|
||||||
|
|
||||||
import akka.actor.typed.ActorRef;
|
|
||||||
import akka.actor.typed.Behavior;
|
|
||||||
import akka.actor.typed.javadsl.ActorContext;
|
|
||||||
import akka.actor.typed.javadsl.Behaviors;
|
|
||||||
import dev.freireservices.social_altruism.chat.commands.Commands;
|
|
||||||
import dev.freireservices.social_altruism.chat.events.Events;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ChatPotProtocol {
|
|
||||||
private final ActorContext<Commands.RoomCommand> context;
|
|
||||||
|
|
||||||
private final List<ActorRef<SessionCommand>> sessions;
|
|
||||||
|
|
||||||
public double getCurrentPot() {
|
|
||||||
return currentPot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetPot() {
|
|
||||||
this.currentPot = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addToPot(double pot) {
|
|
||||||
this.currentPot += pot;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double currentPot = 0.0;
|
|
||||||
|
|
||||||
public int getCurrentTurn() {
|
|
||||||
return currentTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int incrementCurrentTurnAndGet() {
|
|
||||||
this.currentTurn++;
|
|
||||||
return this.currentTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int currentTurn = 0;
|
|
||||||
private int totalTurns = 0;
|
|
||||||
|
|
||||||
public int getParticipantsInTurn() {
|
|
||||||
return participantsInTurn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementParticipantsInTurn() {
|
|
||||||
this.participantsInTurn++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void resetParticipantsInTurn() {
|
|
||||||
this.participantsInTurn = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNumberOfParticipants() {
|
|
||||||
return numberOfParticipants;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int participantsInTurn = 0;
|
|
||||||
private final int numberOfParticipants;
|
|
||||||
|
|
||||||
private ChatPotProtocol(
|
|
||||||
ActorContext<Commands.RoomCommand> context,
|
|
||||||
List<ActorRef<SessionCommand>> sessions,
|
|
||||||
int numberOfParticipants,
|
|
||||||
int turns) {
|
|
||||||
this.context = context;
|
|
||||||
this.sessions = sessions;
|
|
||||||
this.numberOfParticipants = numberOfParticipants;
|
|
||||||
this.totalTurns = turns;
|
|
||||||
}
|
|
||||||
|
|
||||||
// #chatroom-behavior
|
|
||||||
// #chatroom-protocol
|
|
||||||
|
|
||||||
private Behavior<Commands.RoomCommand> onGetPotSession(Commands.EnterPot enterPot) {
|
|
||||||
|
|
||||||
// Add check session started
|
|
||||||
if (sessions.stream()
|
|
||||||
.anyMatch(
|
|
||||||
s ->
|
|
||||||
s.path()
|
|
||||||
.name()
|
|
||||||
.equals(URLEncoder.encode(enterPot.replyTo().path().name(), UTF_8)))) {
|
|
||||||
|
|
||||||
enterPot.replyTo().tell(new Events.SessionDenied("Can only enter a pot once"));
|
|
||||||
}
|
|
||||||
|
|
||||||
context.getLog().info("Participant joined {} pot", enterPot.replyTo().path().name());
|
|
||||||
|
|
||||||
ActorRef<Events.SessionEvent> client = enterPot.replyTo();
|
|
||||||
|
|
||||||
ActorRef<SessionCommand> session =
|
|
||||||
context.spawn(
|
|
||||||
Session.create(client), URLEncoder.encode(enterPot.replyTo().path().name(), UTF_8));
|
|
||||||
|
|
||||||
// narrow to only expose PostMessage
|
|
||||||
client.tell(new Events.SessionGranted(session.narrow()));
|
|
||||||
|
|
||||||
sessions.add(session);
|
|
||||||
|
|
||||||
if (numberOfParticipants == sessions.size()) {
|
|
||||||
context.getLog().info("All participants joined; pot is ready to start.");
|
|
||||||
return createPotBehaviour();
|
|
||||||
} else {
|
|
||||||
// Waiting for more participants
|
|
||||||
context.getLog().info("Waiting for more participants.");
|
|
||||||
return Behaviors.same();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Behavior<Commands.RoomCommand> onPlayTurn(Commands.PlayTurn playTurn) {
|
|
||||||
|
|
||||||
context
|
|
||||||
.getLog()
|
|
||||||
.info(
|
|
||||||
"Participant {} joined for turn {} with {}",
|
|
||||||
playTurn.replyTo().path().name(),
|
|
||||||
currentTurn,
|
|
||||||
playTurn.pot());
|
|
||||||
|
|
||||||
// Add to current pot
|
|
||||||
addToPot(playTurn.pot());
|
|
||||||
incrementParticipantsInTurn();
|
|
||||||
|
|
||||||
if (getParticipantsInTurn() == numberOfParticipants) {
|
|
||||||
|
|
||||||
double amountToShare = (getCurrentPot() * 2) / numberOfParticipants;
|
|
||||||
sessions.forEach(s -> s.tell(new SharePotWithParticipants(amountToShare)));
|
|
||||||
|
|
||||||
resetPot();
|
|
||||||
resetParticipantsInTurn();
|
|
||||||
|
|
||||||
context.getLog().info("Turn {} complete", getCurrentTurn());
|
|
||||||
|
|
||||||
if (incrementCurrentTurnAndGet() == totalTurns) {
|
|
||||||
context.getLog().info("All turns completed");
|
|
||||||
return Behaviors.stopped();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Behaviors.same();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Behavior<Commands.RoomCommand> createPotBehaviour() {
|
|
||||||
return Behaviors.receive(Commands.RoomCommand.class)
|
|
||||||
.onMessage(Commands.EnterPot.class, this::onGetPotSession)
|
|
||||||
.onMessage(Commands.PlayTurn.class, this::onPlayTurn)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Behavior<Commands.RoomCommand> create(int numberOfParticipants, int turns) {
|
|
||||||
return Behaviors.setup(
|
|
||||||
ctx ->
|
|
||||||
new ChatPotProtocol(ctx, new ArrayList<>(), numberOfParticipants, turns)
|
|
||||||
.createPotBehaviour());
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SessionCommand {}
|
|
||||||
|
|
||||||
public record ParticipateInTurn(String message) implements SessionCommand {}
|
|
||||||
|
|
||||||
public record SharePotWithParticipants(double returnedAmount) implements SessionCommand {}
|
|
||||||
|
|
||||||
static class Session {
|
|
||||||
static Behavior<ChatPotProtocol.SessionCommand> create(ActorRef<Events.SessionEvent> client) {
|
|
||||||
return Behaviors.receive(ChatPotProtocol.SessionCommand.class)
|
|
||||||
.onMessage(
|
|
||||||
SharePotWithParticipants.class,
|
|
||||||
pot -> onSharePotWithParticipants(client, pot.returnedAmount))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Behavior<SessionCommand> onSharePotWithParticipants(
|
|
||||||
ActorRef<Events.SessionEvent> participant, double returnedAmount) {
|
|
||||||
participant.tell(new Events.PotReturned(participant, returnedAmount));
|
|
||||||
return Behaviors.same();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
package dev.freireservices.social_altruism.chat;
|
|
||||||
|
|
||||||
import akka.actor.typed.ActorRef;
|
|
||||||
import akka.actor.typed.ActorSystem;
|
|
||||||
import akka.actor.typed.Behavior;
|
|
||||||
import akka.actor.typed.Terminated;
|
|
||||||
import akka.actor.typed.javadsl.Behaviors;
|
|
||||||
import dev.freireservices.social_altruism.chat.commands.Commands;
|
|
||||||
import dev.freireservices.social_altruism.chat.events.Events;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
public class ChatQuickStart {
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
// #actor-system
|
|
||||||
ActorSystem.create(Main.create(), "PotRoom");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Main {
|
|
||||||
|
|
||||||
static List<ActorRef<Events.SessionEvent>> sessions = new ArrayList<>();
|
|
||||||
|
|
||||||
static final int numberOfParticipants = 2;
|
|
||||||
static final int numberOfTurns = 100;
|
|
||||||
|
|
||||||
public static Behavior<Void> create() {
|
|
||||||
return Behaviors.setup(
|
|
||||||
context -> {
|
|
||||||
ActorRef<Commands.RoomCommand> chatRoom =
|
|
||||||
context.spawn(
|
|
||||||
ChatPotProtocol.create(numberOfParticipants, numberOfTurns), "potRoom");
|
|
||||||
|
|
||||||
// Agregamos jugadores
|
|
||||||
sessions.addAll(
|
|
||||||
IntStream.range(0, numberOfParticipants)
|
|
||||||
.mapToObj(
|
|
||||||
i ->
|
|
||||||
context.spawn(
|
|
||||||
Participante.create(getRandomNumberBetween(0, 100)),
|
|
||||||
"participante-" + i))
|
|
||||||
.toList());
|
|
||||||
|
|
||||||
// Entrar en pot
|
|
||||||
for (ActorRef<Events.SessionEvent> session : sessions) {
|
|
||||||
chatRoom.tell(new Commands.EnterPot(session));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < numberOfTurns; i++) {
|
|
||||||
// Participar en cada turno cantidad diferente
|
|
||||||
for (ActorRef<Events.SessionEvent> session : sessions) {
|
|
||||||
|
|
||||||
// Pícaro
|
|
||||||
if (session.path().name().contains("participante-0")) {
|
|
||||||
chatRoom.tell(new Commands.PlayTurn(session, 0));
|
|
||||||
} else {
|
|
||||||
chatRoom.tell(new Commands.PlayTurn(session, getRandomNumberBetween(0, 10)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Behaviors.receive(Void.class)
|
|
||||||
.onSignal(Terminated.class, sig -> Behaviors.stopped())
|
|
||||||
.build();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// #actor-system
|
|
||||||
|
|
||||||
public static int getRandomNumberBetween(int min, int max) {
|
|
||||||
SecureRandom secureRandom = new SecureRandom();
|
|
||||||
return secureRandom.nextInt(max - min) + min;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,85 +0,0 @@
|
|||||||
package dev.freireservices.social_altruism.chat;
|
|
||||||
|
|
||||||
import akka.actor.typed.Behavior;
|
|
||||||
import akka.actor.typed.javadsl.ActorContext;
|
|
||||||
import akka.actor.typed.javadsl.Behaviors;
|
|
||||||
import dev.freireservices.social_altruism.chat.events.Events;
|
|
||||||
|
|
||||||
public class Participante {
|
|
||||||
|
|
||||||
public static Behavior<Events.SessionEvent> create(int monedasInit) {
|
|
||||||
return Behaviors.setup(ctx -> new Participante(ctx, monedasInit).behavior());
|
|
||||||
}
|
|
||||||
|
|
||||||
private final ActorContext<Events.SessionEvent> context;
|
|
||||||
|
|
||||||
public double getMonedas() {
|
|
||||||
return monedas;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMonedas(double monedas) {
|
|
||||||
this.monedas = monedas;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void decrementMonedas(double monedas) {
|
|
||||||
this.monedas -= monedas;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void incrementMonedas(double monedas) {
|
|
||||||
this.monedas += monedas;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double monedas;
|
|
||||||
|
|
||||||
public double getMonedasInit() {
|
|
||||||
return monedasInit;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final double monedasInit;
|
|
||||||
|
|
||||||
private Participante(ActorContext<Events.SessionEvent> context, double monedas) {
|
|
||||||
this.context = context;
|
|
||||||
this.monedas = monedas;
|
|
||||||
this.monedasInit = monedas;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Behavior<Events.SessionEvent> behavior() {
|
|
||||||
return Behaviors.receive(Events.SessionEvent.class)
|
|
||||||
.onMessage(Events.SessionDenied.class, this::onSessionDenied)
|
|
||||||
.onMessage(Events.SessionGranted.class, this::onSessionGranted)
|
|
||||||
.onMessage(Events.PotReturned.class, this::onPotReturned)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Behavior<Events.SessionEvent> onSessionDenied(Events.SessionDenied message) {
|
|
||||||
context.getLog().info("cannot start chat room session: {}", message.reason());
|
|
||||||
return Behaviors.stopped();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Behavior<Events.SessionEvent> onSessionGranted(Events.SessionGranted message) {
|
|
||||||
return Behaviors.same();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Behavior<Events.SessionEvent> onPotReturned(Events.PotReturned potReturned) {
|
|
||||||
context.getLog().info("Pot returned: {}", potReturned.returnedAmount());
|
|
||||||
incrementMonedas(potReturned.returnedAmount());
|
|
||||||
context
|
|
||||||
.getLog()
|
|
||||||
.info(
|
|
||||||
"Player {} has now {} coins; started with {} for a total profit of: {} %",
|
|
||||||
potReturned.participant().path().name(),
|
|
||||||
getMonedas(),
|
|
||||||
getMonedasInit(),
|
|
||||||
calculateProfit());
|
|
||||||
|
|
||||||
//Calcular contribución total.
|
|
||||||
//Si detecta baja contribución aplicar penalización
|
|
||||||
|
|
||||||
|
|
||||||
return Behaviors.same();
|
|
||||||
}
|
|
||||||
|
|
||||||
private double calculateProfit() {
|
|
||||||
return Math.round((getMonedas() * 100) / getMonedasInit() -100);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,83 @@
|
|||||||
|
package dev.freireservices.social_altruism.chat;
|
||||||
|
|
||||||
|
import static dev.freireservices.social_altruism.chat.participant.ParticipantType.*;
|
||||||
|
|
||||||
|
import akka.actor.typed.ActorRef;
|
||||||
|
import akka.actor.typed.ActorSystem;
|
||||||
|
import akka.actor.typed.Behavior;
|
||||||
|
import akka.actor.typed.Terminated;
|
||||||
|
import akka.actor.typed.javadsl.Behaviors;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol;
|
||||||
|
import dev.freireservices.social_altruism.chat.events.ParticipantProtocol;
|
||||||
|
import dev.freireservices.social_altruism.chat.participant.Participant;
|
||||||
|
import dev.freireservices.social_altruism.chat.potroom.PotRoom;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PotQuickStart {
|
||||||
|
|
||||||
|
public static final int MONEDAS_INIT = 100;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// #actor-system
|
||||||
|
ActorSystem.create(Main.create(), "PotRoom");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Main {
|
||||||
|
|
||||||
|
static List<ActorRef<ParticipantProtocol.ParticipantMessage>> sessions = new ArrayList<>();
|
||||||
|
|
||||||
|
static final int numberOfParticipants = 3;
|
||||||
|
static final int numberOfTurns = 100;
|
||||||
|
|
||||||
|
public static Behavior<Void> create() {
|
||||||
|
return Behaviors.setup(
|
||||||
|
context -> {
|
||||||
|
ActorRef<PotRoomProtocol.PotRoomMessage> chatRoom =
|
||||||
|
context.spawn(
|
||||||
|
PotRoom.create(numberOfParticipants, numberOfTurns), "potRoom");
|
||||||
|
|
||||||
|
// Agregamos jugadores
|
||||||
|
final var picaroZero = Participant.create(MONEDAS_INIT, PICARO);
|
||||||
|
final var santoZero = Participant.create(MONEDAS_INIT, SANTO);
|
||||||
|
final var justiZero = Participant.create(MONEDAS_INIT, JUSTICIERO);
|
||||||
|
|
||||||
|
sessions.add(context.spawn(picaroZero, "participante-picaro-0"));
|
||||||
|
sessions.add(context.spawn(santoZero, "participante-santo-0"));
|
||||||
|
sessions.add(context.spawn(justiZero, "participante-justiciero-0"));
|
||||||
|
|
||||||
|
// Entrar en pot
|
||||||
|
for (ActorRef<ParticipantProtocol.ParticipantMessage> session : sessions) {
|
||||||
|
chatRoom.tell(new PotRoomProtocol.EnterPot(session));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* for (int i = 0; i < numberOfTurns; i++) {
|
||||||
|
// Participar en cada turno cantidad diferente
|
||||||
|
for (ActorRef<ParticipantProtocol.ParticipantMessage> session : sessions) {
|
||||||
|
|
||||||
|
// Pícaro
|
||||||
|
if (session.path().name().contains("participante-0")) {
|
||||||
|
chatRoom.tell(new PotRoomProtocol.PlayTurn(session, 0));
|
||||||
|
// Justiciero
|
||||||
|
} else if (session.path().name().contains("participante-1")) {
|
||||||
|
|
||||||
|
// ActorRef<Commands.RoomCommand> chatRoom, double pot,
|
||||||
|
// ActorRef<Events.SessionEvent> replyTo)
|
||||||
|
|
||||||
|
chatRoom.tell(new PotRoomProtocol.PlayTurn(session, 1));
|
||||||
|
// Santo
|
||||||
|
} else if (session.path().name().contains("participante-2")) {
|
||||||
|
chatRoom.tell(new PotRoomProtocol.PlayTurn(session, 2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return Behaviors.receive(Void.class)
|
||||||
|
.onSignal(Terminated.class, sig -> Behaviors.stopped())
|
||||||
|
.build();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// #actor-system
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
package dev.freireservices.social_altruism.chat;
|
|
||||||
|
|
||||||
public enum TipoDeParticipante {
|
|
||||||
SANTO,
|
|
||||||
JUSTICIERO,
|
|
||||||
PICARO,
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
package dev.freireservices.social_altruism.chat.commands;
|
|
||||||
|
|
||||||
import akka.actor.typed.ActorRef;
|
|
||||||
import dev.freireservices.social_altruism.chat.events.Events;
|
|
||||||
|
|
||||||
public class Commands {
|
|
||||||
public interface RoomCommand {}
|
|
||||||
|
|
||||||
public record EnterPot(ActorRef<Events.SessionEvent> replyTo) implements RoomCommand {}
|
|
||||||
|
|
||||||
public record PlayTurn(ActorRef<Events.SessionEvent> replyTo, double pot) implements RoomCommand {}
|
|
||||||
|
|
||||||
// #chatroom-protocol
|
|
||||||
// #chatroom-behavior
|
|
||||||
}
|
|
@ -0,0 +1,32 @@
|
|||||||
|
package dev.freireservices.social_altruism.chat.commands;
|
||||||
|
|
||||||
|
import akka.actor.typed.ActorRef;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static dev.freireservices.social_altruism.chat.events.ParticipantProtocol.*;
|
||||||
|
|
||||||
|
public class PotRoomProtocol {
|
||||||
|
public interface PotRoomMessage {}
|
||||||
|
|
||||||
|
public record EnterPot(ActorRef<ParticipantMessage> replyTo)
|
||||||
|
implements PotRoomMessage {}
|
||||||
|
|
||||||
|
public record StartSession(
|
||||||
|
ActorRef<ParticipantMessage> replyTo,
|
||||||
|
List<ActorRef<PotRoomMessage>> sessions)
|
||||||
|
implements PotRoomMessage {}
|
||||||
|
|
||||||
|
public record ParticipateInTurn(String message) implements PotRoomMessage {}
|
||||||
|
|
||||||
|
public record ShareReturnPotWithParticipants(double returnedAmount) implements PotRoomMessage {}
|
||||||
|
|
||||||
|
public record PlayTurn(
|
||||||
|
//ActorRef<PotRoomMessage> chatRoom,
|
||||||
|
ActorRef<ParticipantMessage> replyTo,
|
||||||
|
double pot)
|
||||||
|
implements PotRoomMessage {}
|
||||||
|
|
||||||
|
// #chatroom-protocol
|
||||||
|
// #chatroom-behavior
|
||||||
|
}
|
@ -1,16 +0,0 @@
|
|||||||
package dev.freireservices.social_altruism.chat.events;
|
|
||||||
|
|
||||||
import akka.actor.typed.ActorRef;
|
|
||||||
import dev.freireservices.social_altruism.chat.ChatPotProtocol;
|
|
||||||
|
|
||||||
public class Events {
|
|
||||||
public interface SessionEvent {}
|
|
||||||
|
|
||||||
public record SessionGranted(ActorRef<ChatPotProtocol.ParticipateInTurn> handle) implements SessionEvent {}
|
|
||||||
|
|
||||||
public record SessionDenied(String reason) implements SessionEvent {}
|
|
||||||
|
|
||||||
public record PotReturned(ActorRef participant, double returnedAmount) implements SessionEvent {}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,29 @@
|
|||||||
|
package dev.freireservices.social_altruism.chat.events;
|
||||||
|
|
||||||
|
import akka.actor.typed.ActorRef;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol.PotRoomMessage;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ParticipantProtocol {
|
||||||
|
public interface ParticipantMessage {}
|
||||||
|
|
||||||
|
public record SessionGranted(
|
||||||
|
ActorRef<PotRoomMessage> chatRoom,
|
||||||
|
ActorRef<PotRoomProtocol.ParticipateInTurn> handle)
|
||||||
|
implements ParticipantMessage {}
|
||||||
|
|
||||||
|
public record SessionStarted(
|
||||||
|
ActorRef<PotRoomMessage> replyTo,
|
||||||
|
List<ActorRef<ParticipantMessage>> participants)
|
||||||
|
implements ParticipantMessage {}
|
||||||
|
|
||||||
|
public record SessionDenied(String reason) implements ParticipantMessage {}
|
||||||
|
|
||||||
|
public record PotReturned(
|
||||||
|
ActorRef<PotRoomMessage> handle,
|
||||||
|
ActorRef<ParticipantMessage> participant,
|
||||||
|
double returnedAmount)
|
||||||
|
implements ParticipantMessage {}
|
||||||
|
}
|
@ -0,0 +1,171 @@
|
|||||||
|
package dev.freireservices.social_altruism.chat.participant;
|
||||||
|
|
||||||
|
import static dev.freireservices.social_altruism.chat.participant.ParticipantType.*;
|
||||||
|
import static dev.freireservices.social_altruism.chat.participant.ParticipantType.JUSTICIERO;
|
||||||
|
|
||||||
|
import akka.actor.typed.ActorRef;
|
||||||
|
import akka.actor.typed.Behavior;
|
||||||
|
import akka.actor.typed.javadsl.ActorContext;
|
||||||
|
import akka.actor.typed.javadsl.Behaviors;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol.ParticipateInTurn;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol.PotRoomMessage;
|
||||||
|
import dev.freireservices.social_altruism.chat.events.ParticipantProtocol;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class Participant {
|
||||||
|
|
||||||
|
private final ActorContext<ParticipantProtocol.ParticipantMessage> context;
|
||||||
|
private ActorRef<PotRoomMessage> chatRoom;
|
||||||
|
|
||||||
|
private boolean collaborateSwitch;
|
||||||
|
private int currentTurn;
|
||||||
|
private double coins;
|
||||||
|
private final double initialCoins;
|
||||||
|
private int participantNumber;
|
||||||
|
private int totalTurns;
|
||||||
|
private final ParticipantType participantType;
|
||||||
|
|
||||||
|
private Participant(
|
||||||
|
ActorContext<ParticipantProtocol.ParticipantMessage> context,
|
||||||
|
double coins,
|
||||||
|
ParticipantType participantType) {
|
||||||
|
this.context = context;
|
||||||
|
this.coins = coins;
|
||||||
|
this.initialCoins = coins;
|
||||||
|
this.participantType = participantType;
|
||||||
|
this.collaborateSwitch = participantType == JUSTICIERO || participantType == SANTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Behavior<ParticipantProtocol.ParticipantMessage> create(
|
||||||
|
int initialCoins, ParticipantType participantType) {
|
||||||
|
return Behaviors.setup(ctx -> new Participant(ctx, initialCoins, participantType).behavior());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decrementCoins(double coins) {
|
||||||
|
this.coins -= coins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementCoins(double coins) {
|
||||||
|
this.coins += coins;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Behavior<ParticipantProtocol.ParticipantMessage> behavior() {
|
||||||
|
return Behaviors.receive(ParticipantProtocol.ParticipantMessage.class)
|
||||||
|
.onMessage(ParticipantProtocol.SessionStarted.class, this::onSessionStarted)
|
||||||
|
.onMessage(ParticipantProtocol.SessionDenied.class, this::onSessionDenied)
|
||||||
|
.onMessage(ParticipantProtocol.SessionGranted.class, this::onSessionGranted)
|
||||||
|
.onMessage(ParticipantProtocol.PotReturned.class, this::onPotReturned)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Behavior<ParticipantProtocol.ParticipantMessage> onSessionDenied(
|
||||||
|
ParticipantProtocol.SessionDenied message) {
|
||||||
|
context.getLog().info("cannot start chat room session: {}", message.reason());
|
||||||
|
return Behaviors.stopped();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Behavior<ParticipantProtocol.ParticipantMessage> onSessionGranted(
|
||||||
|
ParticipantProtocol.SessionGranted message) {
|
||||||
|
setChatRoom(message.chatRoom());
|
||||||
|
return Behaviors.same();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Behavior<ParticipantProtocol.ParticipantMessage> onSessionStarted(
|
||||||
|
ParticipantProtocol.SessionStarted startSession) {
|
||||||
|
resetCurrentTurn();
|
||||||
|
setParticipantNumber(startSession.participants().size());
|
||||||
|
playTurn(startSession.replyTo());
|
||||||
|
|
||||||
|
context.getLog().info("Session started with {} participants", startSession.participants());
|
||||||
|
return Behaviors.same();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void playTurn(ActorRef<PotRoomMessage> replyTo) {
|
||||||
|
if (getCoins() > 0 && getCurrentTurn() < getTotalTurns()) {
|
||||||
|
replyTo.tell(new PotRoomProtocol.PlayTurn(context.getSelf(), getCurrentTurnParticipation()));
|
||||||
|
incrementCurrentTurn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getCurrentTurnParticipation() {
|
||||||
|
var currentTurnCoins = getRandomNumberBetween(0, Math.floor(getCoins()));
|
||||||
|
decrementCoins(currentTurnCoins);
|
||||||
|
return currentTurnCoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getRandomNumberBetween(double min, double max) {
|
||||||
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
return secureRandom.nextDouble(max - min) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Behavior<ParticipantProtocol.ParticipantMessage> onPotReturned(
|
||||||
|
ParticipantProtocol.PotReturned potReturned) {
|
||||||
|
context.getLog().info("Pot returned: {}", potReturned.returnedAmount());
|
||||||
|
incrementCoins(potReturned.returnedAmount());
|
||||||
|
|
||||||
|
context
|
||||||
|
.getLog()
|
||||||
|
.info(
|
||||||
|
"Player {} has now {} coins; started with {} for a total profit of: {} %",
|
||||||
|
potReturned.participant().path().name(),
|
||||||
|
getCoins(),
|
||||||
|
getInitialCoins(),
|
||||||
|
calculateProfit());
|
||||||
|
|
||||||
|
// Still game?
|
||||||
|
if (getCoins() > 0) {
|
||||||
|
playTurn(potReturned.handle());
|
||||||
|
} else {
|
||||||
|
context
|
||||||
|
.getLog()
|
||||||
|
.info(
|
||||||
|
"Player {} has now {} coins; started with {} for a total profit of: {} %",
|
||||||
|
potReturned.participant().path().name(),
|
||||||
|
getCoins(),
|
||||||
|
getInitialCoins(),
|
||||||
|
calculateProfit());
|
||||||
|
|
||||||
|
return Behaviors.stopped();
|
||||||
|
}
|
||||||
|
adjustBehaviour(potReturned);
|
||||||
|
return Behaviors.same();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void adjustBehaviour(ParticipantProtocol.PotReturned potReturned) {
|
||||||
|
|
||||||
|
switch (participantType) {
|
||||||
|
case SANTO:
|
||||||
|
setCollaborateSwitch(true);
|
||||||
|
break;
|
||||||
|
case PICARO:
|
||||||
|
setCollaborateSwitch(false);
|
||||||
|
break;
|
||||||
|
case JUSTICIERO:
|
||||||
|
// Tweak minimum amount to collaborate
|
||||||
|
setCollaborateSwitch(potReturned.returnedAmount() > getParticipantNumber());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void participant() {
|
||||||
|
ActorRef<ParticipateInTurn> handle;
|
||||||
|
// return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetCurrentTurn() {
|
||||||
|
setCurrentTurn(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementCurrentTurn() {
|
||||||
|
setCurrentTurn(this.currentTurn++);
|
||||||
|
}
|
||||||
|
|
||||||
|
private double calculateProfit() {
|
||||||
|
return Math.round((getCoins() * 100) / getInitialCoins() - 100);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package dev.freireservices.social_altruism.chat.participant;
|
||||||
|
|
||||||
|
public enum ParticipantType {
|
||||||
|
SANTO,
|
||||||
|
JUSTICIERO,
|
||||||
|
PICARO,
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,184 @@
|
|||||||
|
package dev.freireservices.social_altruism.chat.potroom;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.*;
|
||||||
|
|
||||||
|
import akka.actor.typed.ActorRef;
|
||||||
|
import akka.actor.typed.Behavior;
|
||||||
|
import akka.actor.typed.javadsl.ActorContext;
|
||||||
|
import akka.actor.typed.javadsl.Behaviors;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol.PotRoomMessage;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol.ShareReturnPotWithParticipants;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol.StartSession;
|
||||||
|
import dev.freireservices.social_altruism.chat.events.ParticipantProtocol;
|
||||||
|
import dev.freireservices.social_altruism.chat.events.ParticipantProtocol.ParticipantMessage;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class PotRoom {
|
||||||
|
private final ActorContext<PotRoomMessage> context;
|
||||||
|
private final List<ActorRef<PotRoomMessage>> participants;
|
||||||
|
|
||||||
|
private double currentPot = 0.0;
|
||||||
|
private int currentTurn = 0;
|
||||||
|
private int totalTurns = 0;
|
||||||
|
private int participantsInTurn = 0;
|
||||||
|
private final int numberOfParticipants;
|
||||||
|
|
||||||
|
private PotRoom(
|
||||||
|
ActorContext<PotRoomMessage> context,
|
||||||
|
List<ActorRef<PotRoomMessage>> participants,
|
||||||
|
int numberOfParticipants,
|
||||||
|
int turns) {
|
||||||
|
this.context = context;
|
||||||
|
this.participants = participants;
|
||||||
|
this.numberOfParticipants = numberOfParticipants;
|
||||||
|
this.totalTurns = turns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetPot() {
|
||||||
|
this.currentPot = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addToPot(double pot) {
|
||||||
|
this.currentPot += pot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementParticipantsInTurn() {
|
||||||
|
this.participantsInTurn++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetParticipantsInTurn() {
|
||||||
|
this.participantsInTurn = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int incrementCurrentTurnAndGet() {
|
||||||
|
this.currentTurn++;
|
||||||
|
return this.currentTurn;
|
||||||
|
}
|
||||||
|
|
||||||
|
// #chatroom-behavior
|
||||||
|
// #chatroom-protocol
|
||||||
|
|
||||||
|
private Behavior<PotRoomMessage> onGetPotSession(
|
||||||
|
ActorRef<PotRoomMessage> chatRoom, PotRoomProtocol.EnterPot enterPot) {
|
||||||
|
|
||||||
|
validate(enterPot);
|
||||||
|
|
||||||
|
context.getLog().info("Participant joined {} pot", enterPot.replyTo().path().name());
|
||||||
|
|
||||||
|
ActorRef<ParticipantMessage> client = enterPot.replyTo();
|
||||||
|
|
||||||
|
ActorRef<PotRoomMessage> session =
|
||||||
|
context.spawn(
|
||||||
|
Session.create(chatRoom, client),
|
||||||
|
URLEncoder.encode(enterPot.replyTo().path().name(), UTF_8));
|
||||||
|
|
||||||
|
client.tell(new ParticipantProtocol.SessionGranted(chatRoom,session.narrow()));
|
||||||
|
|
||||||
|
participants.add(session);
|
||||||
|
|
||||||
|
if (getNumberOfParticipants() == participants.size()) {
|
||||||
|
context.getLog().info("All participants joined; pot is ready to start.");
|
||||||
|
|
||||||
|
// Communicate session start and share pot info with all participants
|
||||||
|
chatRoom.tell(new StartSession(enterPot.replyTo(), participants));
|
||||||
|
|
||||||
|
return createPotBehaviour(chatRoom);
|
||||||
|
} else {
|
||||||
|
// Waiting for more participants
|
||||||
|
context.getLog().info("Waiting for more participants.");
|
||||||
|
return Behaviors.same();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validate(PotRoomProtocol.EnterPot enterPot) {
|
||||||
|
// Add check session started
|
||||||
|
if (participants.stream()
|
||||||
|
.anyMatch(
|
||||||
|
s ->
|
||||||
|
s.path()
|
||||||
|
.name()
|
||||||
|
.equals(URLEncoder.encode(enterPot.replyTo().path().name(), UTF_8)))) {
|
||||||
|
|
||||||
|
enterPot.replyTo().tell(new ParticipantProtocol.SessionDenied("Can only enter a pot once"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Behavior<PotRoomMessage> onPlayTurn(PotRoomProtocol.PlayTurn playTurn) {
|
||||||
|
context
|
||||||
|
.getLog()
|
||||||
|
.info(
|
||||||
|
"Participant joined for turn {} with {}",
|
||||||
|
//playTurn.replyTo().path().name(),
|
||||||
|
currentTurn,
|
||||||
|
playTurn.pot());
|
||||||
|
|
||||||
|
// Add to current pot
|
||||||
|
addToPot(playTurn.pot());
|
||||||
|
incrementParticipantsInTurn();
|
||||||
|
|
||||||
|
if (getParticipantsInTurn() == numberOfParticipants) {
|
||||||
|
|
||||||
|
double amountToShare = (getCurrentPot() * 2) / numberOfParticipants;
|
||||||
|
participants.forEach(s -> s.tell(new ShareReturnPotWithParticipants(amountToShare)));
|
||||||
|
|
||||||
|
resetPot();
|
||||||
|
resetParticipantsInTurn();
|
||||||
|
|
||||||
|
context.getLog().info("Turn {} complete", getCurrentTurn());
|
||||||
|
|
||||||
|
if (incrementCurrentTurnAndGet() == totalTurns) {
|
||||||
|
context.getLog().info("All turns completed");
|
||||||
|
return Behaviors.stopped();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Behaviors.same();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Behavior<PotRoomMessage> createPotBehaviour(ActorRef<PotRoomMessage> chatRoom) {
|
||||||
|
return Behaviors.receive(PotRoomMessage.class)
|
||||||
|
.onMessage(PotRoomProtocol.EnterPot.class, x -> onGetPotSession(chatRoom, x))
|
||||||
|
.onMessage(PotRoomProtocol.PlayTurn.class, this::onPlayTurn)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Behavior<PotRoomMessage> create(int numberOfParticipants, int turns) {
|
||||||
|
return Behaviors.setup(
|
||||||
|
ctx ->
|
||||||
|
new PotRoom(ctx, new ArrayList<>(), numberOfParticipants, turns)
|
||||||
|
.createPotBehaviour(ctx.getSelf()));
|
||||||
|
}
|
||||||
|
|
||||||
|
static class Session {
|
||||||
|
static Behavior<PotRoomMessage> create(
|
||||||
|
ActorRef<PotRoomMessage> chatRoom, ActorRef<ParticipantMessage> client) {
|
||||||
|
return Behaviors.receive(PotRoomMessage.class)
|
||||||
|
.onMessage(
|
||||||
|
ShareReturnPotWithParticipants.class,
|
||||||
|
sharePot -> onSharePotWithParticipants(chatRoom, client, sharePot.returnedAmount()))
|
||||||
|
.onMessage(
|
||||||
|
StartSession.class,
|
||||||
|
(startSession) -> onSessionStarted(startSession.replyTo(), startSession.sessions()))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Behavior<PotRoomMessage> onSessionStarted(
|
||||||
|
ActorRef<ParticipantMessage> replyTo, List<ActorRef<PotRoomMessage>> participants) {
|
||||||
|
participants.forEach(s -> s.tell(new StartSession(replyTo, participants)));
|
||||||
|
return Behaviors.same();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Behavior<PotRoomMessage> onSharePotWithParticipants(
|
||||||
|
ActorRef<PotRoomMessage> chatRoom,
|
||||||
|
ActorRef<ParticipantMessage> participant,
|
||||||
|
double returnedAmount) {
|
||||||
|
participant.tell(new ParticipantProtocol.PotReturned(chatRoom, participant, returnedAmount));
|
||||||
|
return Behaviors.same();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,80 +0,0 @@
|
|||||||
package dev.freireservices.social_altruism.chat;
|
|
||||||
|
|
||||||
import akka.actor.testkit.typed.javadsl.ActorTestKit;
|
|
||||||
import akka.actor.testkit.typed.javadsl.TestProbe;
|
|
||||||
import akka.actor.typed.ActorRef;
|
|
||||||
import dev.freireservices.social_altruism.chat.commands.Commands;
|
|
||||||
import dev.freireservices.social_altruism.chat.events.Events;
|
|
||||||
import java.time.Duration;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
// #definition
|
|
||||||
public class ChatQuickStartTest {
|
|
||||||
|
|
||||||
// #definition
|
|
||||||
|
|
||||||
// #test
|
|
||||||
@Test
|
|
||||||
// FIXME - Improve or delete..
|
|
||||||
public void testCooperationCaseOne() {
|
|
||||||
|
|
||||||
final ActorTestKit testKit = ActorTestKit.create();
|
|
||||||
|
|
||||||
TestProbe<Events.SessionEvent> testProbe = testKit.createTestProbe();
|
|
||||||
|
|
||||||
ActorRef<Commands.RoomCommand> chatRoomTest =
|
|
||||||
testKit.spawn(ChatPotProtocol.create(2, 1), "chatRoom");
|
|
||||||
|
|
||||||
ActorRef<Events.SessionEvent> participanteUno =
|
|
||||||
testKit.spawn(Participante.create(100), "participanteUno");
|
|
||||||
|
|
||||||
ActorRef<Events.SessionEvent> participanteDos =
|
|
||||||
testKit.spawn(Participante.create(10), "participanteDos");
|
|
||||||
|
|
||||||
ActorRef<Events.SessionEvent> participanteTres =
|
|
||||||
testKit.spawn(Participante.create(100), "participanteTres");
|
|
||||||
|
|
||||||
ActorRef<Events.SessionEvent> participanteCuatro =
|
|
||||||
testKit.spawn(Participante.create(10), "participanteCuatro");
|
|
||||||
|
|
||||||
// Enter POT
|
|
||||||
|
|
||||||
chatRoomTest.tell(new Commands.EnterPot(participanteUno));
|
|
||||||
chatRoomTest.tell(new Commands.EnterPot(participanteDos));
|
|
||||||
|
|
||||||
chatRoomTest.tell(new Commands.EnterPot(participanteTres));
|
|
||||||
chatRoomTest.tell(new Commands.EnterPot(participanteCuatro));
|
|
||||||
|
|
||||||
// Turnos
|
|
||||||
chatRoomTest.tell(new Commands.PlayTurn(participanteUno, 1));
|
|
||||||
chatRoomTest.tell(new Commands.PlayTurn(participanteDos, 2));
|
|
||||||
chatRoomTest.tell(new Commands.PlayTurn(participanteTres, 3));
|
|
||||||
chatRoomTest.tell(new Commands.PlayTurn(participanteCuatro, 4));
|
|
||||||
|
|
||||||
// #assert
|
|
||||||
// #assert
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testActorGetsUserDenied() {
|
|
||||||
final ActorTestKit testKit = ActorTestKit.create();
|
|
||||||
TestProbe<Events.SessionEvent> testProbe = testKit.createTestProbe();
|
|
||||||
|
|
||||||
ActorRef<Commands.RoomCommand> chatRoomTest =
|
|
||||||
testKit.spawn(ChatPotProtocol.create(2, 1), "chatRoom");
|
|
||||||
|
|
||||||
chatRoomTest.tell(new Commands.EnterPot(testProbe.ref()));
|
|
||||||
|
|
||||||
testProbe.expectMessageClass(Events.SessionGranted.class, Duration.ofSeconds(10));
|
|
||||||
|
|
||||||
chatRoomTest.tell(new Commands.EnterPot(testProbe.ref()));
|
|
||||||
|
|
||||||
Events.SessionDenied sessionDenied =
|
|
||||||
new Events.SessionDenied("Can only enter a pot once");
|
|
||||||
|
|
||||||
testProbe.expectMessage(Duration.ofSeconds(10), sessionDenied);
|
|
||||||
|
|
||||||
// #assert
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,73 @@
|
|||||||
|
package dev.freireservices.social_altruism.chat;
|
||||||
|
|
||||||
|
import static dev.freireservices.social_altruism.chat.participant.ParticipantType.*;
|
||||||
|
|
||||||
|
import akka.actor.testkit.typed.javadsl.ActorTestKit;
|
||||||
|
import akka.actor.testkit.typed.javadsl.TestProbe;
|
||||||
|
import akka.actor.typed.ActorRef;
|
||||||
|
import dev.freireservices.social_altruism.chat.commands.PotRoomProtocol;
|
||||||
|
import dev.freireservices.social_altruism.chat.events.ParticipantProtocol;
|
||||||
|
import dev.freireservices.social_altruism.chat.participant.Participant;
|
||||||
|
import dev.freireservices.social_altruism.chat.potroom.PotRoom;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.List;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
// #definition
|
||||||
|
public class PotQuickStartTest {
|
||||||
|
|
||||||
|
// #definition
|
||||||
|
|
||||||
|
// #test
|
||||||
|
@Test
|
||||||
|
// FIXME - Improve or delete..
|
||||||
|
public void testCooperationCaseOne() {
|
||||||
|
|
||||||
|
final ActorTestKit testKit = ActorTestKit.create();
|
||||||
|
|
||||||
|
ActorRef<PotRoomProtocol.PotRoomMessage> chatRoomTest =
|
||||||
|
testKit.spawn(PotRoom.create(3, 1), "potRoom");
|
||||||
|
|
||||||
|
ActorRef<ParticipantProtocol.ParticipantMessage> p1 = testKit.spawn(Participant.create(100, PICARO), "PICARO-1");
|
||||||
|
|
||||||
|
ActorRef<ParticipantProtocol.ParticipantMessage> p2 = testKit.spawn(Participant.create(100, JUSTICIERO), "JUSTICIERO-1");
|
||||||
|
|
||||||
|
ActorRef<ParticipantProtocol.ParticipantMessage> p3 = testKit.spawn(Participant.create(10, SANTO), "SANTO-1");
|
||||||
|
|
||||||
|
final List<ActorRef<ParticipantProtocol.ParticipantMessage>> sessions = List.of(p1, p2, p3);
|
||||||
|
|
||||||
|
// Enter POT
|
||||||
|
chatRoomTest.tell(new PotRoomProtocol.EnterPot(p1));
|
||||||
|
chatRoomTest.tell(new PotRoomProtocol.EnterPot(p2));
|
||||||
|
chatRoomTest.tell(new PotRoomProtocol.EnterPot(p3));
|
||||||
|
|
||||||
|
// Turnos
|
||||||
|
chatRoomTest.tell(new PotRoomProtocol.PlayTurn(p1,0));
|
||||||
|
chatRoomTest.tell(new PotRoomProtocol.PlayTurn(p2,1));
|
||||||
|
chatRoomTest.tell(new PotRoomProtocol.PlayTurn(p3, 3));
|
||||||
|
|
||||||
|
// #assert
|
||||||
|
// #assert
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testActorGetsUserDenied() {
|
||||||
|
final ActorTestKit testKit = ActorTestKit.create();
|
||||||
|
TestProbe<ParticipantProtocol.ParticipantMessage> testProbe = testKit.createTestProbe("TestProbe");
|
||||||
|
|
||||||
|
ActorRef<PotRoomProtocol.PotRoomMessage> chatRoomTest =
|
||||||
|
testKit.spawn(PotRoom.create(2, 1), "chatRoom");
|
||||||
|
|
||||||
|
chatRoomTest.tell(new PotRoomProtocol.EnterPot(testProbe.ref()));
|
||||||
|
|
||||||
|
testProbe.expectMessageClass(ParticipantProtocol.SessionGranted.class, Duration.ofSeconds(10));
|
||||||
|
|
||||||
|
chatRoomTest.tell(new PotRoomProtocol.EnterPot(testProbe.ref()));
|
||||||
|
|
||||||
|
testProbe.expectMessage(
|
||||||
|
Duration.ofSeconds(10), new ParticipantProtocol.SessionDenied("Can only enter a pot once"));
|
||||||
|
|
||||||
|
// #assert
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
artifactId=app
|
artifactId=SocialAltruism
|
||||||
groupId=hello-akka-java
|
groupId=hello-akka-java
|
||||||
version=1.0
|
version=1.0
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$PotReturned.class
|
dev/freireservices/social_altruism/chat/commands/PotRoomProtocol$PotRoomMessage.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$Session.class
|
dev/freireservices/social_altruism/chat/events/ParticipantProtocol$ParticipantMessage.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$EnterPot.class
|
dev/freireservices/social_altruism/chat/participant/ParticipantType.class
|
||||||
dev/freireservices/social_altruism/chat/ChatQuickStart.class
|
dev/freireservices/social_altruism/chat/commands/PotRoomProtocol$ParticipateInTurn.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$SessionGranted.class
|
dev/freireservices/social_altruism/chat/events/ParticipantProtocol$SessionStarted.class
|
||||||
dev/freireservices/social_altruism/chat/ChatQuickStart$Main.class
|
dev/freireservices/social_altruism/chat/events/ParticipantProtocol.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$SharePotWithParticipants.class
|
dev/freireservices/social_altruism/chat/PotQuickStart.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$MessagePosted.class
|
dev/freireservices/social_altruism/chat/commands/PotRoomProtocol.class
|
||||||
dev/freireservices/social_altruism/chat/Participante.class
|
dev/freireservices/social_altruism/chat/commands/PotRoomProtocol$EnterPot.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$SessionEvent.class
|
dev/freireservices/social_altruism/chat/PotQuickStart$Main.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$SessionCommand.class
|
dev/freireservices/social_altruism/chat/potroom/PotRoom.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$ParticipateInTurn.class
|
dev/freireservices/social_altruism/chat/events/ParticipantProtocol$SessionGranted.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol.class
|
dev/freireservices/social_altruism/chat/events/ParticipantProtocol$SessionDenied.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$UpdatePlayerAfterTurn.class
|
dev/freireservices/social_altruism/chat/commands/PotRoomProtocol$SharePotWithParticipants.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$RoomCommand.class
|
dev/freireservices/social_altruism/chat/participant/Participant.class
|
||||||
dev/freireservices/social_altruism/chat/ChatPotProtocol$SessionDenied.class
|
dev/freireservices/social_altruism/chat/commands/PotRoomProtocol$PlayTurn.class
|
||||||
|
dev/freireservices/social_altruism/chat/potroom/PotRoom$Session.class
|
||||||
|
dev/freireservices/social_altruism/chat/commands/PotRoomProtocol$StartSession.class
|
||||||
|
dev/freireservices/social_altruism/chat/events/ParticipantProtocol$PotReturned.class
|
||||||
|
dev/freireservices/social_altruism/chat/participant/Participant$1.class
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
/Users/rdev/Source/social_altruism_akka/src/main/java/dev/freireservices/social_altruism/chat/ChatQuickStart.java
|
/Users/rdev/Source/social_altruism_akka/src/main/java/dev/freireservices/social_altruism/chat/potroom/PotRoom.java
|
||||||
/Users/rdev/Source/social_altruism_akka/src/main/java/dev/freireservices/social_altruism/chat/ChatPotProtocol.java
|
/Users/rdev/Source/social_altruism_akka/src/main/java/dev/freireservices/social_altruism/chat/commands/PotRoomProtocol.java
|
||||||
/Users/rdev/Source/social_altruism_akka/src/main/java/dev/freireservices/social_altruism/chat/Participante.java
|
/Users/rdev/Source/social_altruism_akka/src/main/java/dev/freireservices/social_altruism/chat/events/ParticipantProtocol.java
|
||||||
|
/Users/rdev/Source/social_altruism_akka/src/main/java/dev/freireservices/social_altruism/chat/participant/Participant.java
|
||||||
|
/Users/rdev/Source/social_altruism_akka/src/main/java/dev/freireservices/social_altruism/chat/PotQuickStart.java
|
||||||
|
/Users/rdev/Source/social_altruism_akka/src/main/java/dev/freireservices/social_altruism/chat/participant/ParticipantType.java
|
||||||
|
@ -1 +1 @@
|
|||||||
dev/freireservices/social_altruism/chat/ChatQuickStartTest.class
|
dev/freireservices/social_altruism/chat/PotQuickStartTest.class
|
||||||
|
@ -1 +1 @@
|
|||||||
/Users/rdev/Source/social_altruism_akka/src/test/java/dev/freireservices/social_altruism/chat/ChatQuickStartTest.java
|
/Users/rdev/Source/social_altruism_akka/src/test/java/dev/freireservices/social_altruism/chat/PotQuickStartTest.java
|
||||||
|
@ -1,67 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="dev.freireservices.social_altruism.chat.ChatQuickStartTest" time="0.387" tests="1" errors="0" skipped="0" failures="0">
|
|
||||||
<properties>
|
|
||||||
<property name="java.specification.version" value="21"/>
|
|
||||||
<property name="sun.jnu.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.class.path" value="/Users/rdev/Source/social_altruism_akka/target/test-classes:/Users/rdev/Source/social_altruism_akka/target/classes:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor-typed_2.13/2.9.0/akka-actor-typed_2.13-2.9.0.jar:/Users/rdev/.m2/repository/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor_2.13/2.9.0/akka-actor_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/config/1.4.3/config-1.4.3.jar:/Users/rdev/.m2/repository/org/scala-lang/modules/scala-java8-compat_2.13/1.0.2/scala-java8-compat_2.13-1.0.2.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-slf4j_2.13/2.9.0/akka-slf4j_2.13-2.9.0.jar:/Users/rdev/.m2/repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:/Users/rdev/.m2/repository/ch/qos/logback/logback-classic/1.2.11/logback-classic-1.2.11.jar:/Users/rdev/.m2/repository/ch/qos/logback/logback-core/1.2.11/logback-core-1.2.11.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor-testkit-typed_2.13/2.9.0/akka-actor-testkit-typed_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-testkit_2.13/2.9.0/akka-testkit_2.13-2.9.0.jar:/Users/rdev/.m2/repository/junit/junit/4.13.2/junit-4.13.2.jar:/Users/rdev/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
|
|
||||||
<property name="java.vm.vendor" value="Amazon.com Inc."/>
|
|
||||||
<property name="sun.arch.data.model" value="64"/>
|
|
||||||
<property name="java.vendor.url" value="https://aws.amazon.com/corretto/"/>
|
|
||||||
<property name="os.name" value="Mac OS X"/>
|
|
||||||
<property name="java.vm.specification.version" value="21"/>
|
|
||||||
<property name="sun.java.launcher" value="SUN_STANDARD"/>
|
|
||||||
<property name="user.country" value="CH"/>
|
|
||||||
<property name="sun.boot.library.path" value="/Users/rdev/.sdkman/candidates/java/21-amzn/lib"/>
|
|
||||||
<property name="sun.java.command" value="/Users/rdev/Source/social_altruism_akka/target/surefire/surefirebooter-20231219123316996_3.jar /Users/rdev/Source/social_altruism_akka/target/surefire 2023-12-19T12-33-16_961-jvmRun1 surefire-20231219123316996_1tmp surefire_0-20231219123316996_2tmp"/>
|
|
||||||
<property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
|
|
||||||
<property name="jdk.debug" value="release"/>
|
|
||||||
<property name="surefire.test.class.path" value="/Users/rdev/Source/social_altruism_akka/target/test-classes:/Users/rdev/Source/social_altruism_akka/target/classes:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor-typed_2.13/2.9.0/akka-actor-typed_2.13-2.9.0.jar:/Users/rdev/.m2/repository/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor_2.13/2.9.0/akka-actor_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/config/1.4.3/config-1.4.3.jar:/Users/rdev/.m2/repository/org/scala-lang/modules/scala-java8-compat_2.13/1.0.2/scala-java8-compat_2.13-1.0.2.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-slf4j_2.13/2.9.0/akka-slf4j_2.13-2.9.0.jar:/Users/rdev/.m2/repository/org/slf4j/slf4j-api/1.7.36/slf4j-api-1.7.36.jar:/Users/rdev/.m2/repository/ch/qos/logback/logback-classic/1.2.11/logback-classic-1.2.11.jar:/Users/rdev/.m2/repository/ch/qos/logback/logback-core/1.2.11/logback-core-1.2.11.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor-testkit-typed_2.13/2.9.0/akka-actor-testkit-typed_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-testkit_2.13/2.9.0/akka-testkit_2.13-2.9.0.jar:/Users/rdev/.m2/repository/junit/junit/4.13.2/junit-4.13.2.jar:/Users/rdev/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:"/>
|
|
||||||
<property name="sun.cpu.endian" value="little"/>
|
|
||||||
<property name="user.home" value="/Users/rdev"/>
|
|
||||||
<property name="user.language" value="es"/>
|
|
||||||
<property name="java.specification.vendor" value="Oracle Corporation"/>
|
|
||||||
<property name="java.version.date" value="2023-10-17"/>
|
|
||||||
<property name="java.home" value="/Users/rdev/.sdkman/candidates/java/21-amzn"/>
|
|
||||||
<property name="file.separator" value="/"/>
|
|
||||||
<property name="basedir" value="/Users/rdev/Source/social_altruism_akka"/>
|
|
||||||
<property name="java.vm.compressedOopsMode" value="Zero based"/>
|
|
||||||
<property name="line.separator" value=" "/>
|
|
||||||
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
|
|
||||||
<property name="java.specification.name" value="Java Platform API Specification"/>
|
|
||||||
<property name="apple.awt.application.name" value="ForkedBooter"/>
|
|
||||||
<property name="surefire.real.class.path" value="/Users/rdev/Source/social_altruism_akka/target/surefire/surefirebooter-20231219123316996_3.jar"/>
|
|
||||||
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
|
|
||||||
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
|
|
||||||
<property name="java.runtime.version" value="21.0.1+12-LTS"/>
|
|
||||||
<property name="user.name" value="rdev"/>
|
|
||||||
<property name="stdout.encoding" value="UTF-8"/>
|
|
||||||
<property name="path.separator" value=":"/>
|
|
||||||
<property name="os.version" value="14.2"/>
|
|
||||||
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
|
|
||||||
<property name="file.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
|
|
||||||
<property name="java.vendor.version" value="Corretto-21.0.1.12.1"/>
|
|
||||||
<property name="localRepository" value="/Users/rdev/.m2/repository"/>
|
|
||||||
<property name="java.vendor.url.bug" value="https://github.com/corretto/corretto-21/issues/"/>
|
|
||||||
<property name="java.io.tmpdir" value="/var/folders/31/f1vtm4ks0_j2myb365hc02m40000gn/T/"/>
|
|
||||||
<property name="idea.version" value="2023.3.1"/>
|
|
||||||
<property name="java.version" value="21.0.1"/>
|
|
||||||
<property name="user.dir" value="/Users/rdev/Source/social_altruism_akka"/>
|
|
||||||
<property name="os.arch" value="aarch64"/>
|
|
||||||
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
|
|
||||||
<property name="native.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.library.path" value="/Users/rdev/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/>
|
|
||||||
<property name="java.vm.info" value="mixed mode, sharing"/>
|
|
||||||
<property name="stderr.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.vendor" value="Amazon.com Inc."/>
|
|
||||||
<property name="java.vm.version" value="21.0.1+12-LTS"/>
|
|
||||||
<property name="sun.io.unicode.encoding" value="UnicodeBig"/>
|
|
||||||
<property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
|
|
||||||
<property name="java.class.version" value="65.0"/>
|
|
||||||
</properties>
|
|
||||||
<testcase name="testGreeterActorSendingOfGreeting" classname="dev.freireservices.social_altruism.chat.ChatQuickStartTest" time="0.012">
|
|
||||||
<system-out><![CDATA[[2023-12-19 12:33:17,437] [INFO] [akka.event.slf4j.Slf4jLogger] [AkkaQuickstartTest-akka.actor.default-dispatcher-3] [] - Slf4jLogger started
|
|
||||||
[2023-12-19 12:33:17,477] [INFO] [dev.freireservices.social_altruism.Greeter] [AkkaQuickstartTest-akka.actor.default-dispatcher-3] [akka://AkkaQuickstartTest/user/greeter] - Hello Charles!
|
|
||||||
]]></system-out>
|
|
||||||
</testcase>
|
|
||||||
</testsuite>
|
|
@ -1,106 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report-3.0.xsd" version="3.0" name="dev.freireservices.social_altruism.chat.ChatQuickStartTest" time="1.155" tests="2" errors="0" skipped="0" failures="0">
|
|
||||||
<properties>
|
|
||||||
<property name="java.specification.version" value="19"/>
|
|
||||||
<property name="sun.jnu.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.class.path" value="/Users/rdev/Source/social_altruism_akka/target/test-classes:/Users/rdev/Source/social_altruism_akka/target/classes:/Users/rdev/.m2/repository/ch/qos/logback/logback-classic/1.4.14/logback-classic-1.4.14.jar:/Users/rdev/.m2/repository/ch/qos/logback/logback-core/1.4.14/logback-core-1.4.14.jar:/Users/rdev/.m2/repository/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor-typed_2.13/2.9.0/akka-actor-typed_2.13-2.9.0.jar:/Users/rdev/.m2/repository/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor_2.13/2.9.0/akka-actor_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/config/1.4.3/config-1.4.3.jar:/Users/rdev/.m2/repository/org/scala-lang/modules/scala-java8-compat_2.13/1.0.2/scala-java8-compat_2.13-1.0.2.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-slf4j_2.13/2.9.0/akka-slf4j_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor-testkit-typed_2.13/2.9.0/akka-actor-testkit-typed_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-testkit_2.13/2.9.0/akka-testkit_2.13-2.9.0.jar:/Users/rdev/.m2/repository/junit/junit/4.13.2/junit-4.13.2.jar:/Users/rdev/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/Users/rdev/.m2/repository/org/awaitility/awaitility/4.2.0/awaitility-4.2.0.jar:/Users/rdev/.m2/repository/org/awaitility/awaitility-proxy/3.1.6/awaitility-proxy-3.1.6.jar:/Users/rdev/.m2/repository/net/bytebuddy/byte-buddy/1.7.0/byte-buddy-1.7.0.jar:/Users/rdev/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:"/>
|
|
||||||
<property name="java.vm.vendor" value="Amazon.com Inc."/>
|
|
||||||
<property name="sun.arch.data.model" value="64"/>
|
|
||||||
<property name="java.vendor.url" value="https://aws.amazon.com/corretto/"/>
|
|
||||||
<property name="os.name" value="Mac OS X"/>
|
|
||||||
<property name="java.vm.specification.version" value="19"/>
|
|
||||||
<property name="sun.java.launcher" value="SUN_STANDARD"/>
|
|
||||||
<property name="user.country" value="CH"/>
|
|
||||||
<property name="sun.boot.library.path" value="/Users/rdev/.sdkman/candidates/java/19.0.1-amzn/lib"/>
|
|
||||||
<property name="sun.java.command" value="/Users/rdev/Source/social_altruism_akka/target/surefire/surefirebooter-20231223121640936_3.jar /Users/rdev/Source/social_altruism_akka/target/surefire 2023-12-23T12-16-40_715-jvmRun1 surefire-20231223121640936_1tmp surefire_0-20231223121640936_2tmp"/>
|
|
||||||
<property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
|
|
||||||
<property name="jdk.debug" value="release"/>
|
|
||||||
<property name="surefire.test.class.path" value="/Users/rdev/Source/social_altruism_akka/target/test-classes:/Users/rdev/Source/social_altruism_akka/target/classes:/Users/rdev/.m2/repository/ch/qos/logback/logback-classic/1.4.14/logback-classic-1.4.14.jar:/Users/rdev/.m2/repository/ch/qos/logback/logback-core/1.4.14/logback-core-1.4.14.jar:/Users/rdev/.m2/repository/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor-typed_2.13/2.9.0/akka-actor-typed_2.13-2.9.0.jar:/Users/rdev/.m2/repository/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor_2.13/2.9.0/akka-actor_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/config/1.4.3/config-1.4.3.jar:/Users/rdev/.m2/repository/org/scala-lang/modules/scala-java8-compat_2.13/1.0.2/scala-java8-compat_2.13-1.0.2.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-slf4j_2.13/2.9.0/akka-slf4j_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-actor-testkit-typed_2.13/2.9.0/akka-actor-testkit-typed_2.13-2.9.0.jar:/Users/rdev/.m2/repository/com/typesafe/akka/akka-testkit_2.13/2.9.0/akka-testkit_2.13-2.9.0.jar:/Users/rdev/.m2/repository/junit/junit/4.13.2/junit-4.13.2.jar:/Users/rdev/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/Users/rdev/.m2/repository/org/awaitility/awaitility/4.2.0/awaitility-4.2.0.jar:/Users/rdev/.m2/repository/org/awaitility/awaitility-proxy/3.1.6/awaitility-proxy-3.1.6.jar:/Users/rdev/.m2/repository/net/bytebuddy/byte-buddy/1.7.0/byte-buddy-1.7.0.jar:/Users/rdev/.m2/repository/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar:"/>
|
|
||||||
<property name="sun.cpu.endian" value="little"/>
|
|
||||||
<property name="user.home" value="/Users/rdev"/>
|
|
||||||
<property name="user.language" value="es"/>
|
|
||||||
<property name="java.specification.vendor" value="Oracle Corporation"/>
|
|
||||||
<property name="java.version.date" value="2022-10-18"/>
|
|
||||||
<property name="java.home" value="/Users/rdev/.sdkman/candidates/java/19.0.1-amzn"/>
|
|
||||||
<property name="file.separator" value="/"/>
|
|
||||||
<property name="basedir" value="/Users/rdev/Source/social_altruism_akka"/>
|
|
||||||
<property name="java.vm.compressedOopsMode" value="Zero based"/>
|
|
||||||
<property name="line.separator" value=" "/>
|
|
||||||
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
|
|
||||||
<property name="java.specification.name" value="Java Platform API Specification"/>
|
|
||||||
<property name="apple.awt.application.name" value="ForkedBooter"/>
|
|
||||||
<property name="surefire.real.class.path" value="/Users/rdev/Source/social_altruism_akka/target/surefire/surefirebooter-20231223121640936_3.jar"/>
|
|
||||||
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
|
|
||||||
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
|
|
||||||
<property name="java.runtime.version" value="19.0.1+10-FR"/>
|
|
||||||
<property name="user.name" value="rdev"/>
|
|
||||||
<property name="stdout.encoding" value="UTF-8"/>
|
|
||||||
<property name="path.separator" value=":"/>
|
|
||||||
<property name="os.version" value="14.2"/>
|
|
||||||
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
|
|
||||||
<property name="file.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
|
|
||||||
<property name="java.vendor.version" value="Corretto-19.0.1.10.1"/>
|
|
||||||
<property name="localRepository" value="/Users/rdev/.m2/repository"/>
|
|
||||||
<property name="java.vendor.url.bug" value="https://github.com/corretto/corretto-19/issues/"/>
|
|
||||||
<property name="java.io.tmpdir" value="/var/folders/31/f1vtm4ks0_j2myb365hc02m40000gn/T/"/>
|
|
||||||
<property name="idea.version" value="2023.3.1"/>
|
|
||||||
<property name="java.version" value="19.0.1"/>
|
|
||||||
<property name="user.dir" value="/Users/rdev/Source/social_altruism_akka"/>
|
|
||||||
<property name="os.arch" value="x86_64"/>
|
|
||||||
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
|
|
||||||
<property name="native.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.library.path" value="/Users/rdev/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/>
|
|
||||||
<property name="java.vm.info" value="mixed mode, sharing"/>
|
|
||||||
<property name="stderr.encoding" value="UTF-8"/>
|
|
||||||
<property name="java.vendor" value="Amazon.com Inc."/>
|
|
||||||
<property name="java.vm.version" value="19.0.1+10-FR"/>
|
|
||||||
<property name="sun.io.unicode.encoding" value="UnicodeBig"/>
|
|
||||||
<property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
|
|
||||||
<property name="java.class.version" value="63.0"/>
|
|
||||||
</properties>
|
|
||||||
<testcase name="testActorGetsUserDenied" classname="dev.freireservices.social_altruism.chat.ChatQuickStartTest" time="1.02">
|
|
||||||
<system-out><![CDATA[[2023-12-23 12:16:42,141] [INFO] [akka.event.slf4j.Slf4jLogger] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [] - Slf4jLogger started
|
|
||||||
[2023-12-23 12:16:42,291] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-5] [akka://ChatQuickStartTest/user/chatRoom] - Participant joined testProbe-1 turn pot: 10.0
|
|
||||||
[2023-12-23 12:16:42,293] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-5] [akka://ChatQuickStartTest/user/chatRoom] - Waiting for more participants.
|
|
||||||
[2023-12-23 12:16:42,293] [INFO] [dev.freireservices.social_altruism.chat.ChatPotProtocol] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [akka://ChatQuickStartTest/user/chatRoom] - Participant joined testProbe-1 turn pot: 10.0
|
|
||||||
[2023-12-23 12:16:42,303] [ERROR] [akka.actor.SupervisorStrategy] [ChatQuickStartTest-akka.actor.default-dispatcher-5] [akka://ChatQuickStartTest/user] - actor name [testProbe-1] is not unique!
|
|
||||||
akka.actor.InvalidActorNameException: actor name [testProbe-1] is not unique!
|
|
||||||
at akka.actor.dungeon.ChildrenContainer$NormalChildrenContainer.reserve(ChildrenContainer.scala:134)
|
|
||||||
at akka.actor.dungeon.Children.reserveChild(Children.scala:147)
|
|
||||||
at akka.actor.dungeon.Children.reserveChild$(Children.scala:145)
|
|
||||||
at akka.actor.ActorCell.reserveChild(ActorCell.scala:410)
|
|
||||||
at akka.actor.dungeon.Children.makeChild(Children.scala:300)
|
|
||||||
at akka.actor.dungeon.Children.actorOf(Children.scala:49)
|
|
||||||
at akka.actor.dungeon.Children.actorOf$(Children.scala:48)
|
|
||||||
at akka.actor.ActorCell.actorOf(ActorCell.scala:410)
|
|
||||||
at akka.actor.typed.internal.adapter.ActorRefFactoryAdapter$.spawn(ActorRefFactoryAdapter.scala:55)
|
|
||||||
at akka.actor.typed.internal.adapter.ActorContextAdapter.spawn(ActorContextAdapter.scala:73)
|
|
||||||
at akka.actor.typed.internal.ActorContextImpl.spawn(ActorContextImpl.scala:202)
|
|
||||||
at akka.actor.typed.internal.ActorContextImpl.spawn$(ActorContextImpl.scala:201)
|
|
||||||
at akka.actor.typed.internal.adapter.ActorContextAdapter.spawn(ActorContextAdapter.scala:38)
|
|
||||||
at dev.freireservices.social_altruism.chat.ChatPotProtocol.onGetPotSession(ChatPotProtocol.java:72)
|
|
||||||
at dev.freireservices.social_altruism.chat.ChatPotProtocol.lambda$createPot$e7bfbadc$1(ChatPotProtocol.java:113)
|
|
||||||
at akka.actor.typed.javadsl.BuiltBehavior.receive(BehaviorBuilder.scala:197)
|
|
||||||
at akka.actor.typed.javadsl.BuiltBehavior.receive(BehaviorBuilder.scala:186)
|
|
||||||
at akka.actor.typed.Behavior$.interpret(Behavior.scala:282)
|
|
||||||
at akka.actor.typed.Behavior$.interpretMessage(Behavior.scala:238)
|
|
||||||
at akka.actor.typed.internal.adapter.ActorAdapter.handleMessage(ActorAdapter.scala:133)
|
|
||||||
at akka.actor.typed.internal.adapter.ActorAdapter.aroundReceive(ActorAdapter.scala:109)
|
|
||||||
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:579)
|
|
||||||
at akka.actor.ActorCell.invoke(ActorCell.scala:547)
|
|
||||||
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:270)
|
|
||||||
at akka.dispatch.Mailbox.run(Mailbox.scala:231)
|
|
||||||
at akka.dispatch.Mailbox.exec(Mailbox.scala:243)
|
|
||||||
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
|
|
||||||
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1311)
|
|
||||||
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1840)
|
|
||||||
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1806)
|
|
||||||
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)
|
|
||||||
]]></system-out>
|
|
||||||
</testcase>
|
|
||||||
<testcase name="testCooperationCaseOne" classname="dev.freireservices.social_altruism.chat.ChatQuickStartTest" time="0.059">
|
|
||||||
<system-out><![CDATA[[2023-12-23 12:16:42,373] [INFO] [akka.event.slf4j.Slf4jLogger] [ChatQuickStartTest-akka.actor.default-dispatcher-3] [] - Slf4jLogger started
|
|
||||||
]]></system-out>
|
|
||||||
</testcase>
|
|
||||||
</testsuite>
|
|
@ -1,4 +0,0 @@
|
|||||||
-------------------------------------------------------------------------------
|
|
||||||
Test set: dev.freireservices.social_altruism.chat.ChatQuickStartTest
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.387 s -- in dev.freireservices.social_altruism.chat.ChatQuickStartTest
|
|
@ -1,4 +0,0 @@
|
|||||||
-------------------------------------------------------------------------------
|
|
||||||
Test set: dev.freireservices.social_altruism.chat.ChatQuickStartTest
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.155 s -- in dev.freireservices.social_altruism.chat.ChatQuickStartTest
|
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user