Skip to content

Commit

Permalink
feat(calendar): delete entry command without creating CalEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
knotekt committed Feb 15, 2024
1 parent 33257ad commit 3dfb6bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/main/java/cz/smarteon/loxone/calendar/CalendarCommand.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package cz.smarteon.loxone.calendar;

import cz.smarteon.loxone.LoxoneUuid;
import cz.smarteon.loxone.app.MiniserverType;
import cz.smarteon.loxone.message.LoxoneMessageCommand;
import cz.smarteon.loxone.message.LoxoneValue;
import cz.smarteon.loxone.user.EmptyValue;
import org.jetbrains.annotations.NotNull;

import static java.util.Objects.requireNonNull;

public class CalendarCommand<V extends LoxoneValue> extends LoxoneMessageCommand<V> {

private static final String GET_ENTRIES = "calendargetentries/";
private static final String DELETE_ENTRY = "calendardeleteentry/";

protected static final String COMMAND_PREFIX = "jdev/sps/";

Expand All @@ -29,6 +32,17 @@ public static CalendarCommand<CalEntryListValue> getEntries() {
return new CalendarCommand<>(GET_ENTRIES, CalEntryListValue.class);
}

/**
* Creates delete calendar entry command.
* Command deletes a calendar entry with the corresponding lox UUID.
*
* @param entryUuid - Lox UUID of a calendar entry
*/
@NotNull
public static CalendarCommand<EmptyValue> deleteEntry(LoxoneUuid entryUuid) {
return new CalendarCommand<>(DELETE_ENTRY + entryUuid, EmptyValue.class);
}

@Override
public String getCommand() {
return COMMAND_PREFIX + super.getCommand();
Expand Down
9 changes: 8 additions & 1 deletion src/test/kotlin/calendar/CalendarCommandTest.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package cz.smarteon.loxone.calendar

import cz.smarteon.loxone.LoxoneUuid
import org.junit.jupiter.api.Test
import strikt.api.expectThat
import strikt.assertions.isEqualTo

class CalendarCommandTest {

@Test
fun `should create command`() {
fun `should create get command`() {
expectThat(CalendarCommand.getEntries().command).isEqualTo("jdev/sps/calendargetentries/")
}

@Test
fun `should create delete command`() {
expectThat(CalendarCommand.deleteEntry(LoxoneUuid("00000000-0000-0000-0000000000000000")).command)
.isEqualTo("jdev/sps/calendardeleteentry/00000000-0000-0000-0000000000000000")
}
}

0 comments on commit 3dfb6bc

Please sign in to comment.