-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Marcus Fihlon <[email protected]>
- Loading branch information
Showing
4 changed files
with
346 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/test/java/swiss/fihlon/apus/plugin/event/sessionize/SessionizePluginTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Apus - A social wall for conferences with additional features. | ||
* Copyright (C) Marcus Fihlon and the individual contributors to Apus. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package swiss.fihlon.apus.plugin.event.sessionize; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import swiss.fihlon.apus.configuration.Configuration; | ||
import swiss.fihlon.apus.event.Language; | ||
import swiss.fihlon.apus.event.Room; | ||
import swiss.fihlon.apus.event.Session; | ||
import swiss.fihlon.apus.event.SessionImportException; | ||
import swiss.fihlon.apus.event.Speaker; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
class SessionizePluginTest { | ||
|
||
@Test | ||
void isEnabled() { | ||
final var configuration = mock(Configuration.class); | ||
final var sessionizeConfig = new SessionizeConfig("1", ""); | ||
when(configuration.getSessionize()).thenReturn(sessionizeConfig); | ||
|
||
final var sessionizePlugin = new SessionizePlugin(configuration); | ||
assertTrue(sessionizePlugin.isEnabled()); | ||
} | ||
|
||
@Test | ||
void isDisabled() { | ||
final var configuration = mock(Configuration.class); | ||
final var sessionizeConfig = new SessionizeConfig("0", ""); | ||
when(configuration.getSessionize()).thenReturn(sessionizeConfig); | ||
|
||
final var sessionizePlugin = new SessionizePlugin(configuration); | ||
assertFalse(sessionizePlugin.isEnabled()); | ||
} | ||
|
||
@Test | ||
void getSessions() { | ||
final var configuration = mock(Configuration.class); | ||
final var sessionizeConfig = new SessionizeConfig("BBAD", "file:src/test/resources/sessionize.json?eventId=%s"); | ||
when(configuration.getSessionize()).thenReturn(sessionizeConfig); | ||
|
||
final var sessionizePlugin = new SessionizePlugin(configuration); | ||
final var sessions = sessionizePlugin.getSessions(); | ||
assertEquals(8, sessions.size()); | ||
|
||
final var sessionIds = sessions.stream().map(Session::id).toList(); | ||
for (int counter = 1; counter <= 8; counter++) { | ||
final var sessionId = String.format("BBAD:%d", counter); | ||
assertTrue(sessionIds.contains(sessionId)); | ||
} | ||
|
||
// full check of session with ID "BBAD:5" | ||
final var session = sessions.get(4); | ||
assertEquals("BBAD:5", session.id()); | ||
assertEquals(LocalDateTime.of(2024, 1, 3, 19, 0), session.startDate()); | ||
assertEquals(LocalDateTime.of(2024, 1, 3, 19, 45), session.endDate()); | ||
assertEquals(new Room("Room A"), session.room()); | ||
assertEquals("Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat", session.title()); | ||
assertEquals(2, session.speakers().size()); | ||
assertEquals(new Speaker("Saul Goodman"), session.speakers().get(0)); | ||
assertEquals(new Speaker("Mike Ehrmantraut"), session.speakers().get(1)); | ||
assertEquals(Language.DE, session.language()); | ||
} | ||
|
||
@Test | ||
void parseExceptionHandling() { | ||
final var configuration = mock(Configuration.class); | ||
final var sessionizeConfig = new SessionizeConfig("1", "file:src/test/resources/sessionize-broken.json?eventId=%s"); | ||
when(configuration.getSessionize()).thenReturn(sessionizeConfig); | ||
|
||
final var sessionizePlugin = new SessionizePlugin(configuration); | ||
assertThrows(SessionImportException.class, sessionizePlugin::getSessions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[ | ||
{ | ||
"groupId": null, | ||
"groupName": "All", | ||
"sessions": [ | ||
{ | ||
"id": "1", | ||
"title": "Lorem ipsum dolor sit amet", | ||
"startsAt": "2024-01-01T09:45:00", | ||
"endsAt": "2024-01-01T10:00:00", | ||
"speakers": [ | ||
{ | ||
"name": "Walter White" | ||
}, | ||
{ | ||
"name": "Jesse Pinkman" | ||
} | ||
], | ||
"categories": [ | ||
{ | ||
"id": 68911, | ||
"name": "Language", | ||
"categoryItems": [ | ||
{ | ||
"id": 123456, | ||
"name": "Foobar" | ||
} | ||
] | ||
} | ||
], | ||
"room": "Room A" | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
[ | ||
{ | ||
"groupId": null, | ||
"groupName": "All", | ||
"sessions": [ | ||
{ | ||
"id": "1", | ||
"title": "Lorem ipsum dolor sit amet", | ||
"startsAt": "2024-01-01T09:45:00", | ||
"endsAt": "2024-01-01T10:00:00", | ||
"speakers": [ | ||
{ | ||
"name": "Walter White" | ||
}, | ||
{ | ||
"name": "Jesse Pinkman" | ||
} | ||
], | ||
"categories": [ | ||
{ | ||
"id": 68911, | ||
"name": "Language", | ||
"categoryItems": [ | ||
{ | ||
"id": 242156, | ||
"name": "German" | ||
} | ||
] | ||
} | ||
], | ||
"room": "Room A" | ||
}, | ||
{ | ||
"id": "2", | ||
"title": "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat", | ||
"startsAt": "2024-01-01T10:00:00", | ||
"endsAt": "2024-01-01T10:30:00", | ||
"speakers": [ | ||
{ | ||
"name": "Walter White" | ||
}, | ||
{ | ||
"name": "Jesse Pinkman" | ||
} | ||
], | ||
"categories": [ | ||
{ | ||
"id": 68911, | ||
"name": "Language", | ||
"categoryItems": [ | ||
{ | ||
"id": 242155, | ||
"name": "English" | ||
} | ||
] | ||
} | ||
], | ||
"room": "Room A" | ||
}, | ||
{ | ||
"id": "3", | ||
"title": "Ut wisi enim ad minim veniam", | ||
"startsAt": "2024-01-02T19:00:00", | ||
"endsAt": "2024-01-02T19:45:00", | ||
"speakers": [ | ||
{ | ||
"name": "Gustavo Fring" | ||
} | ||
], | ||
"categories": [ | ||
{ | ||
"id": 68911, | ||
"name": "Language", | ||
"categoryItems": [ | ||
{ | ||
"id": 242156, | ||
"name": "German" | ||
} | ||
] | ||
} | ||
], | ||
"room": "Room A" | ||
}, | ||
{ | ||
"id": "4", | ||
"title": "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum", | ||
"startsAt": "2024-01-02T11:00:00", | ||
"endsAt": "2024-01-02T11:45:00", | ||
"speakers": [ | ||
{ | ||
"name": "Hank Schrader" | ||
} | ||
], | ||
"categories": [ | ||
{ | ||
"id": 68911, | ||
"name": "Language", | ||
"categoryItems": [ | ||
{ | ||
"id": 242155, | ||
"name": "English" | ||
} | ||
] | ||
} | ||
], | ||
"room": "Room B" | ||
}, | ||
{ | ||
"id": "5", | ||
"title": "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat", | ||
"startsAt": "2024-01-03T19:00:00", | ||
"endsAt": "2024-01-03T19:45:00", | ||
"speakers": [ | ||
{ | ||
"name": "Saul Goodman" | ||
}, | ||
{ | ||
"name": "Mike Ehrmantraut" | ||
} | ||
], | ||
"categories": [ | ||
{ | ||
"id": 68911, | ||
"name": "Language", | ||
"categoryItems": [ | ||
{ | ||
"id": 242156, | ||
"name": "German" | ||
} | ||
] | ||
} | ||
], | ||
"room": "Room A" | ||
}, | ||
{ | ||
"id": "6", | ||
"title": "At vero eos et accusam et justo duo dolores et ea rebum", | ||
"startsAt": "2024-01-03T11:00:00", | ||
"endsAt": "2024-01-03T12:45:00", | ||
"speakers": [ | ||
{ | ||
"name": "Skyler White" | ||
} | ||
], | ||
"categories": [ | ||
{ | ||
"id": 68911, | ||
"name": "Language", | ||
"categoryItems": [ | ||
{ | ||
"id": 242155, | ||
"name": "English" | ||
} | ||
] | ||
} | ||
], | ||
"room": "Room B" | ||
}, | ||
{ | ||
"id": "7", | ||
"title": "Consetetur sadipscing elitr", | ||
"startsAt": "2024-01-04T10:00:00", | ||
"endsAt": "2024-01-04T12:45:00", | ||
"speakers": [ | ||
{ | ||
"name": "Marie Schrader" | ||
} | ||
], | ||
"categories": [ | ||
{ | ||
"id": 68911, | ||
"name": "Language", | ||
"categoryItems": [ | ||
{ | ||
"id": 242155, | ||
"name": "English" | ||
} | ||
] | ||
} | ||
], | ||
"room": "Room A" | ||
}, | ||
{ | ||
"id": "8", | ||
"title": "Consetetur sadipscing elitr", | ||
"startsAt": "2024-01-04T13:00:00", | ||
"endsAt": "2024-01-04T14:45:00", | ||
"speakers": [ | ||
{ | ||
"name": "Lydia Rodarte-Quayle" | ||
} | ||
], | ||
"categories": [ | ||
{ | ||
"id": 68911, | ||
"name": "Language", | ||
"categoryItems": [ | ||
{ | ||
"id": 242156, | ||
"name": "German" | ||
} | ||
] | ||
} | ||
], | ||
"room": "Room A" | ||
} | ||
] | ||
} | ||
] |