Add tests

This commit is contained in:
d35h 2018-10-14 22:11:04 +02:00
parent 4efaa253b8
commit dc62f9ce63
2 changed files with 35 additions and 1 deletions

View File

@ -22,7 +22,7 @@ public class KeyboardRow extends ArrayList<KeyboardButton> implements Validable
}
public void addAll(List<String> buttonNames) {
buttonNames.forEach(KeyboardButton::new);
buttonNames.forEach(name -> super.add(new KeyboardButton(name)));
}
public boolean contains(String text) {

View File

@ -0,0 +1,34 @@
package org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static java.util.Arrays.asList;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class KeyboardRowTest {
private static final List<String> BUTTON_NAMES = asList("Carlotta Valdes", "Jimmy Stewart");
@Test
public void shouldAddAllButtons() {
final KeyboardRow keyboardRow = new KeyboardRow();
keyboardRow.addAll(BUTTON_NAMES);
assertThat(keyboardRow.size(), is(2));
assertThat(keyboardRow.get(0).getText(), is("Carlotta Valdes"));
assertThat(keyboardRow.get(1).getText(), is("Jimmy Stewart"));
}
@Test
public void shouldAddNoButtons() {
final KeyboardRow keyboardRow = new KeyboardRow();
keyboardRow.addAll(new ArrayList<String>());
assertTrue(keyboardRow.isEmpty());
}
}