Skip to content

Commit

Permalink
Merge branch 'McPringle:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
leem53 authored Oct 3, 2024
2 parents 9579548 + 143f44e commit fcd68f5
Show file tree
Hide file tree
Showing 14 changed files with 1,251 additions and 2,108 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ To modify the default configuration values, just specify environment variables w
|----------------------------|---------|------------------------------------------------------------------------------|
| ADMIN_PASSWORD | | The hashed password to get admin access (empty = disabled). |
| CUSTOM_STYLES | | Inject custom styles into the user interface (see explanations below). |
| DEMO_ROOM_COUNT | 0 | Number of rooms for the event demo plugin (0 = disabled). |
| DOAG_EVENT_API | [1] | The URL of the DOAG event API to read the conference agenda. |
| DOAG_EVENT_ID | 0 | The ID of the DOAG event to read the conference agenda (0 = disabled). |
| EVENT_DATE_ADJUST | | Adjust the date of the event in days, ISO-8601 formatted (empty = disabled). |
| EVENT_DEMO_ROOM_COUNT | 0 | Number of rooms for the event demo plugin (0 = disabled). |
| EVENT_IMAGE_URL | | The URL of the image to be shown below the event agenda (empty = no image). |
| EVENT_NEXT_SESSION_TIMEOUT | 60 | Number of minutes a session is shown before it starts (0 = disabled). |
| EVENT_SHOW_CLOSED_ROOMS | true | Show (true) or hide (false) closed event rooms. |
Expand Down
3,237 changes: 1,203 additions & 2,034 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"type": "module",
"dependencies": {
"@polymer/polymer": "3.5.1",
"@vaadin/bundles": "24.4.9",
"@vaadin/bundles": "24.4.10",
"@vaadin/common-frontend": "0.0.19",
"@vaadin/polymer-legacy-adapter": "24.4.9",
"@vaadin/react-components": "24.4.9",
"@vaadin/polymer-legacy-adapter": "24.4.10",
"@vaadin/react-components": "24.4.10",
"@vaadin/router": "1.7.5",
"@vaadin/vaadin-development-mode-detector": "2.0.7",
"@vaadin/vaadin-lumo-styles": "24.4.9",
"@vaadin/vaadin-material-styles": "24.4.9",
"@vaadin/vaadin-themable-mixin": "24.4.9",
"@vaadin/vaadin-lumo-styles": "24.4.10",
"@vaadin/vaadin-material-styles": "24.4.10",
"@vaadin/vaadin-themable-mixin": "24.4.10",
"@vaadin/vaadin-usage-statistics": "2.1.3",
"construct-style-sheets-polyfill": "3.1.0",
"date-fns": "2.29.3",
Expand All @@ -36,7 +36,7 @@
"strip-css-comments": "5.0.0",
"transform-ast": "2.4.4",
"typescript": "5.4.5",
"vite": "5.4.2",
"vite": "5.4.6",
"vite-plugin-checker": "0.6.4",
"workbox-build": "7.1.1",
"workbox-core": "7.1.0",
Expand Down Expand Up @@ -64,15 +64,15 @@
"vaadin": {
"dependencies": {
"@polymer/polymer": "3.5.1",
"@vaadin/bundles": "24.4.9",
"@vaadin/bundles": "24.4.10",
"@vaadin/common-frontend": "0.0.19",
"@vaadin/polymer-legacy-adapter": "24.4.9",
"@vaadin/react-components": "24.4.9",
"@vaadin/polymer-legacy-adapter": "24.4.10",
"@vaadin/react-components": "24.4.10",
"@vaadin/router": "1.7.5",
"@vaadin/vaadin-development-mode-detector": "2.0.7",
"@vaadin/vaadin-lumo-styles": "24.4.9",
"@vaadin/vaadin-material-styles": "24.4.9",
"@vaadin/vaadin-themable-mixin": "24.4.9",
"@vaadin/vaadin-lumo-styles": "24.4.10",
"@vaadin/vaadin-material-styles": "24.4.10",
"@vaadin/vaadin-themable-mixin": "24.4.10",
"@vaadin/vaadin-usage-statistics": "2.1.3",
"construct-style-sheets-polyfill": "3.1.0",
"date-fns": "2.29.3",
Expand All @@ -95,12 +95,12 @@
"strip-css-comments": "5.0.0",
"transform-ast": "2.4.4",
"typescript": "5.4.5",
"vite": "5.4.2",
"vite": "5.4.6",
"vite-plugin-checker": "0.6.4",
"workbox-build": "7.1.1",
"workbox-core": "7.1.0",
"workbox-precaching": "7.1.0"
},
"hash": "3368abe481bc47e72bc5efa93b18802e0219086d6df6a336b68a6c17c278f409"
"hash": "566200de64d387e1dfe7409fc25bec1e4f2079026ce4331c469b6ce3a4cf50fb"
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<properties>
<java.version>21</java.version>
<maven.version>3.9.7</maven.version>
<vaadin.version>24.4.12</vaadin.version>
<vaadin.version>24.4.13</vaadin.version>
</properties>

<parent>
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/swiss/fihlon/apus/configuration/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import swiss.fihlon.apus.plugin.event.EventConfig;
import swiss.fihlon.apus.plugin.event.demo.DemoConfig;
import swiss.fihlon.apus.plugin.event.doag.DoagConfig;
import swiss.fihlon.apus.plugin.event.jfs.JavaForumStuttgartConfig;
import swiss.fihlon.apus.plugin.event.sessionize.SessionizeConfig;
Expand All @@ -42,7 +41,6 @@ public class Configuration {
private FilterConfig filter;

// Event Plugin Configs
private DemoConfig demo;
private DoagConfig doag;
private JavaForumStuttgartConfig jfs;
private SessionizeConfig sessionize;
Expand Down Expand Up @@ -106,14 +104,6 @@ public void setEvent(@NotNull final EventConfig event) {
// Event Plugin Configs //
//////////////////////////

public DemoConfig getDemo() {
return demo;
}

public void setDemo(@NotNull final DemoConfig demo) {
this.demo = demo;
}

public DoagConfig getDoag() {
return doag;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/swiss/fihlon/apus/plugin/event/EventConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

import java.time.Period;

public record EventConfig(Period dateAdjust, String image, int nextSessionTimeout, boolean showClosedRooms, boolean showLegend,
int updateFrequency) { }
public record EventConfig(Period dateAdjust, int demoRoomCount, String image, int nextSessionTimeout, boolean showClosedRooms,
boolean showLegend, int updateFrequency) { }
20 changes: 0 additions & 20 deletions src/main/java/swiss/fihlon/apus/plugin/event/demo/DemoConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import java.util.stream.Stream;

@Service
public final class DemoPlugin implements EventPlugin {
public final class EventDemoPlugin implements EventPlugin {

private static final Locale LOCALE = Locale.getDefault();
private static final Random RANDOM = new Random();
Expand All @@ -49,8 +49,8 @@ public final class DemoPlugin implements EventPlugin {
private final int roomCount;
private final List<Session> sessions;

public DemoPlugin(@NotNull final Configuration configuration) {
roomCount = configuration.getDemo().roomCount();
public EventDemoPlugin(@NotNull final Configuration configuration) {
roomCount = configuration.getEvent().demoRoomCount();
sessions = roomCount > 0 ? createFakeSessions() : List.of();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
"type": "java.lang.String",
"description": "Inject custom styles into the user interface."
},
{
"name": "apus.demo.roomCount",
"type": "java.lang.Integer",
"description": "Number of rooms for the event demo plugin."
},
{
"name": "apus.doag.eventApi",
"type": "java.lang.String",
Expand All @@ -30,6 +25,11 @@
"type": "java.lang.String",
"description": "Adjust the date of the event in days (empty = disabled)."
},
{
"name": "apus.event.demoRoomCount",
"type": "java.lang.Integer",
"description": "Number of rooms for the event demo plugin."
},
{
"name": "apus.event.image",
"type": "java.lang.String",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ [email protected]@

apus.admin.password=${ADMIN_PASSWORD:}
apus.custom.styles=${CUSTOM_STYLES:}
apus.demo.roomCount=${DEMO_ROOM_COUNT:0}
apus.doag.eventApi=${DOAG_EVENT_API:https://meine.doag.org/api/event/action.getCPEventAgenda/eventId.%d/}
apus.doag.eventId=${DOAG_EVENT_ID:0}
apus.event.dateAdjust=${EVENT_DATE_ADJUST:0}
apus.event.demoRoomCount=${EVENT_DEMO_ROOM_COUNT:0}
apus.event.image=${EVENT_IMAGE_URL:}
apus.event.nextSessionTimeout=${EVENT_NEXT_SESSION_TIMEOUT:60}
apus.event.showClosedRooms=${EVENT_SHOW_CLOSED_ROOMS:true}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class EventServiceTest {
@BeforeAll
static void mockConfiguration() {
configurationMock = mock(Configuration.class);
when(configurationMock.getEvent()).thenReturn(new EventConfig(null, null, 60, true, true, 0));
when(configurationMock.getEvent()).thenReturn(new EventConfig(null, 0, null, 60, true, true, 0));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
class DemoConfigTest {
class EventDemoConfigTest {

@Autowired
private Configuration configuration;

@Test
void testDemoEventConfig() {
final var demoEventConfig = configuration.getDemo();
assertNotNull(demoEventConfig);
assertEquals(-1, demoEventConfig.roomCount());
final var eventConfig = configuration.getEvent();
assertNotNull(eventConfig);
assertEquals(-1, eventConfig.demoRoomCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,46 @@
import org.junit.jupiter.api.Test;
import swiss.fihlon.apus.configuration.Configuration;
import swiss.fihlon.apus.event.Session;
import swiss.fihlon.apus.plugin.event.EventConfig;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

class DemoPluginTest {
class EventDemoPluginTest {

@Test
void isEnabled() {
final var eventConfig = mock(EventConfig.class);
when(eventConfig.demoRoomCount()).thenReturn(1);
final var configuration = mock(Configuration.class);
final var demoEventConfig = new DemoConfig(1);
when(configuration.getDemo()).thenReturn(demoEventConfig);
when(configuration.getEvent()).thenReturn(eventConfig);

final var demoEventPlugin = new DemoPlugin(configuration);
final var demoEventPlugin = new EventDemoPlugin(configuration);
assertTrue(demoEventPlugin.isEnabled());
}

@Test
void isDisabled() {
final var eventConfig = mock(EventConfig.class);
when(eventConfig.demoRoomCount()).thenReturn(0);
final var configuration = mock(Configuration.class);
final var demoEventConfig = new DemoConfig(0);
when(configuration.getDemo()).thenReturn(demoEventConfig);
when(configuration.getEvent()).thenReturn(eventConfig);

final var demoEventPlugin = new DemoPlugin(configuration);
final var demoEventPlugin = new EventDemoPlugin(configuration);
assertFalse(demoEventPlugin.isEnabled());
}

@Test
void getSessions() {
final var eventConfig = mock(EventConfig.class);
when(eventConfig.demoRoomCount()).thenReturn(1);
final var configuration = mock(Configuration.class);
final var demoEventConfig = new DemoConfig(1);
when(configuration.getDemo()).thenReturn(demoEventConfig);
when(configuration.getEvent()).thenReturn(eventConfig);

final var demoEventPlugin = new DemoPlugin(configuration);
final var demoEventPlugin = new EventDemoPlugin(configuration);
final var sessions = demoEventPlugin.getSessions().toList();
assertEquals(24, sessions.size());

Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ [email protected]@

apus.admin.password=$2a$10$nybQbl/iY8SRJkfHJVncS.L5.OC3KJ6VRBYVAID7qnUqwylmn/BtK
apus.custom.styles=
apus.demo.roomCount=-1
apus.doag.eventApi=file:src/test/resources/DOAG.json?eventId=%d
apus.doag.eventId=-1
apus.event.dateAdjust=
apus.event.demoRoomCount=-1
apus.event.image=
apus.event.nextSessionTimeout=60
apus.event.showClosedRooms=true
Expand Down

0 comments on commit fcd68f5

Please sign in to comment.