-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show calendar event title of active shift in overview (#324)
- Loading branch information
Showing
18 changed files
with
150 additions
and
65 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
app/src/main/java/com/github/frimtec/android/pikettassist/domain/ShiftState.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,33 @@ | ||
package com.github.frimtec.android.pikettassist.domain; | ||
|
||
import static com.github.frimtec.android.pikettassist.domain.OnOffState.ON; | ||
|
||
import java.util.Optional; | ||
|
||
public class ShiftState { | ||
|
||
private final OnOffState state; | ||
private final Shift shift; | ||
|
||
public ShiftState(Shift shift) { | ||
this.state = ON; | ||
this.shift = shift; | ||
} | ||
|
||
public ShiftState(OnOffState state) { | ||
this.state = state; | ||
this.shift = null; | ||
} | ||
|
||
public boolean isOn() { | ||
return this.state == ON; | ||
} | ||
|
||
public OnOffState getState() { | ||
return this.state; | ||
} | ||
|
||
public Optional<Shift> getShift() { | ||
return Optional.ofNullable(this.shift); | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
41 changes: 41 additions & 0 deletions
41
app/src/test/java/com/github/frimtec/android/pikettassist/domain/ShiftStateTest.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,41 @@ | ||
package com.github.frimtec.android.pikettassist.domain; | ||
|
||
import static com.github.frimtec.android.pikettassist.domain.OnOffState.OFF; | ||
import static com.github.frimtec.android.pikettassist.domain.OnOffState.ON; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
class ShiftStateTest { | ||
|
||
@Test | ||
public void createWithShift() { | ||
Shift shift = mock(Shift.class); | ||
ShiftState shiftState = new ShiftState(shift); | ||
|
||
assertThat(shiftState.isOn()).isTrue(); | ||
assertThat(shiftState.getState()).isEqualTo(ON); | ||
assertThat(shiftState.getShift()).isPresent(); | ||
assertThat(shiftState.getShift().get()).isSameAs(shift); | ||
} | ||
|
||
@Test | ||
public void createWithStetOff() { | ||
ShiftState shiftState = new ShiftState(OFF); | ||
|
||
assertThat(shiftState.isOn()).isFalse(); | ||
assertThat(shiftState.getState()).isEqualTo(OFF); | ||
assertThat(shiftState.getShift()).isNotPresent(); | ||
} | ||
|
||
@Test | ||
public void createWithStetOn() { | ||
ShiftState shiftState = new ShiftState(ON); | ||
|
||
assertThat(shiftState.isOn()).isTrue(); | ||
assertThat(shiftState.getState()).isEqualTo(ON); | ||
assertThat(shiftState.getShift()).isNotPresent(); | ||
} | ||
|
||
} |
Oops, something went wrong.