-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/test/java/de/vogel612/helper/data/TranslationTableRendererTests.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,50 @@ | ||
package de.vogel612.helper.data; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.mock; | ||
|
||
import java.awt.Color; | ||
import java.awt.Component; | ||
|
||
import javax.swing.JTable; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class TranslationTableRendererTests { | ||
|
||
private final TranslationTableRenderer cut = new TranslationTableRenderer(); | ||
|
||
JTable table; | ||
|
||
@Before | ||
public void setup() { | ||
table = mock(JTable.class); | ||
} | ||
|
||
@Test | ||
public void testNullTable_returnsDefaultTableRendererResult() { | ||
Component actual = cut.getTableCellRendererComponent(null, null, false, | ||
false, 0, 0); | ||
assertEquals(null, actual.getBackground()); | ||
} | ||
|
||
@Test | ||
public void testDifferentValues_returnsWhiteBackgroundComponent() { | ||
doReturn("").when(table).getValueAt(0, 0); | ||
doReturn("asd").when(table).getValueAt(0, 1); | ||
Component actual = cut.getTableCellRendererComponent(table, null, | ||
false, false, 0, 0); | ||
assertEquals(Color.WHITE, actual.getBackground()); | ||
} | ||
|
||
@Test | ||
public void testEqualValues_returnsYellowBackgroundComponent() { | ||
doReturn("asd").when(table).getValueAt(0, 0); | ||
doReturn("asd").when(table).getValueAt(0, 1); | ||
Component actual = cut.getTableCellRendererComponent(table, "asd", | ||
false, false, 0, 0); | ||
assertEquals(Color.YELLOW, actual.getBackground()); | ||
} | ||
} |