lots of exercises in java... from https://github.com/exercism/java

KindergartenGardenTest.java 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. import java.util.List;
  2. import java.util.Arrays;
  3. import org.junit.Test;
  4. import org.junit.Ignore;
  5. import static org.junit.Assert.assertEquals;
  6. public class KindergartenGardenTest {
  7. @Test
  8. public void singleStudent() {
  9. String student = "Alice";
  10. String plants = "RC\nGG";
  11. List<Plant> expected = Arrays.asList(Plant.RADISHES, Plant.CLOVER, Plant.GRASS, Plant.GRASS);
  12. assertEquals(
  13. expected,
  14. new KindergartenGarden(plants).getPlantsOfStudent(student)
  15. );
  16. }
  17. @Ignore("Remove to run test")
  18. @Test
  19. public void singleStudent2() {
  20. String student = "Alice";
  21. String plants = "VC\nRC";
  22. List<Plant> expected = Arrays.asList(Plant.VIOLETS, Plant.CLOVER, Plant.RADISHES, Plant.CLOVER);
  23. assertEquals(
  24. expected,
  25. new KindergartenGarden(plants).getPlantsOfStudent(student)
  26. );
  27. }
  28. @Ignore("Remove to run test")
  29. @Test
  30. public void twoStudents() {
  31. String student = "Bob";
  32. String plants = "VVCG\nVVRC";
  33. List<Plant> expected = Arrays.asList(Plant.CLOVER, Plant.GRASS, Plant.RADISHES, Plant.CLOVER);
  34. assertEquals(
  35. expected,
  36. new KindergartenGarden(plants).getPlantsOfStudent(student)
  37. );
  38. }
  39. @Ignore("Remove to run test")
  40. @Test
  41. public void oneGardenSecondStudent() {
  42. String student = "Bob";
  43. String plants = "VVCCGG\nVVCCGG";
  44. List<Plant> expected = Arrays.asList(Plant.CLOVER, Plant.CLOVER, Plant.CLOVER, Plant.CLOVER);
  45. assertEquals(
  46. expected,
  47. new KindergartenGarden(plants).getPlantsOfStudent(student)
  48. );
  49. }
  50. @Ignore("Remove to run test")
  51. @Test
  52. public void oneGardenThirdStudent() {
  53. String student = "Charlie";
  54. String plants = "VVCCGG\nVVCCGG";
  55. List<Plant> expected = Arrays.asList(Plant.GRASS, Plant.GRASS, Plant.GRASS, Plant.GRASS);
  56. assertEquals(
  57. expected,
  58. new KindergartenGarden(plants).getPlantsOfStudent(student)
  59. );
  60. }
  61. @Ignore("Remove to run test")
  62. @Test
  63. public void fullGardenFirstStudent() {
  64. String student = "Alice";
  65. String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV";
  66. List<Plant> expected = Arrays.asList(Plant.VIOLETS, Plant.RADISHES, Plant.VIOLETS, Plant.RADISHES);
  67. assertEquals(
  68. expected,
  69. new KindergartenGarden(plants).getPlantsOfStudent(student)
  70. );
  71. }
  72. @Ignore("Remove to run test")
  73. @Test
  74. public void fullGardenSecondStudent() {
  75. String student = "Bob";
  76. String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV";
  77. List<Plant> expected = Arrays.asList(Plant.CLOVER, Plant.GRASS, Plant.CLOVER, Plant.CLOVER);
  78. assertEquals(
  79. expected,
  80. new KindergartenGarden(plants).getPlantsOfStudent(student)
  81. );
  82. }
  83. @Ignore("Remove to run test")
  84. @Test
  85. public void fullGardenSecondToLastStudent() {
  86. String student = "Kincaid";
  87. String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV";
  88. List<Plant> expected = Arrays.asList(Plant.GRASS, Plant.CLOVER, Plant.CLOVER, Plant.GRASS);
  89. assertEquals(
  90. expected,
  91. new KindergartenGarden(plants).getPlantsOfStudent(student)
  92. );
  93. }
  94. @Ignore("Remove to run test")
  95. @Test
  96. public void fullGardenLastStudent() {
  97. String student = "Larry";
  98. String plants = "VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV";
  99. List<Plant> expected = Arrays.asList(Plant.GRASS, Plant.VIOLETS, Plant.CLOVER, Plant.VIOLETS);
  100. assertEquals(
  101. expected,
  102. new KindergartenGarden(plants).getPlantsOfStudent(student)
  103. );
  104. }
  105. }