Skip to content

Commit

Permalink
✨ Speaker now supports profile pictures #43
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Fihlon <[email protected]>
  • Loading branch information
McPringle committed Sep 26, 2024
1 parent dbd0fa3 commit 6dcba96
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/swiss/fihlon/apus/event/Speaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
*/
package swiss.fihlon.apus.event;

import com.vaadin.flow.component.avatar.Avatar;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public record Speaker(@NotNull String fullName) { }
public record Speaker(@NotNull String fullName, @Nullable String imageUrl) {

public Speaker(@NotNull String fullName) {
this(fullName, null);
}

public Avatar avatar() {
return new Avatar(fullName, imageUrl);
}

}
17 changes: 17 additions & 0 deletions src/test/java/swiss/fihlon/apus/event/SpeakerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,32 @@
*/
package swiss.fihlon.apus.event;

import com.vaadin.flow.component.avatar.Avatar;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

class SpeakerTest {

@Test
void fullName() {
assertEquals("Speaker 1", new Speaker("Speaker 1").fullName());
assertEquals("Speaker 2", new Speaker("Speaker 2", null).fullName());
}

@Test
void imageUrl() {
assertNull(new Speaker("").imageUrl());
assertNull(new Speaker("", null).imageUrl());
assertEquals("test.png", new Speaker("", "test.png").imageUrl());
assertEquals("https://foo.bar/test.png", new Speaker("", "https://foo.bar/test.png").imageUrl());
}

@Test
void avatar() {
final Avatar avatar = new Speaker("Speaker 1", "https://foo.bar/test.png").avatar();
assertEquals("Speaker 1", avatar.getName());
assertEquals("https://foo.bar/test.png", avatar.getImage());
}
}

0 comments on commit 6dcba96

Please sign in to comment.