|
| 1 | +package com.codedifferently.lesson16.hiphopArtist; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 5 | + |
| 6 | +import com.codedifferently.lesson16.hiphopArtist.HipHopArtist.Genre; |
| 7 | +import java.util.ArrayList; |
| 8 | +import org.junit.jupiter.api.Test; |
| 9 | + |
| 10 | +public class HipHopArtistTest { |
| 11 | + |
| 12 | + @Test |
| 13 | + public void testCheckLegendStatus() { |
| 14 | + // Create a HipHopArtist object |
| 15 | + HipHopArtist artist = |
| 16 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 17 | + |
| 18 | + // Check legend status |
| 19 | + String expected = "Kendrick Lamar is a modern star."; |
| 20 | + String actual = artist.checkLegendStatus(); |
| 21 | + |
| 22 | + // Assert the result |
| 23 | + assertEquals(expected, actual); |
| 24 | + } |
| 25 | + |
| 26 | + @Test |
| 27 | + public void testAddAlbum() { |
| 28 | + // Create a HipHopArtist object |
| 29 | + HipHopArtist artist = |
| 30 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 31 | + |
| 32 | + // Add an album |
| 33 | + artist.addAlbum("good kid, m.A.A.d city"); |
| 34 | + |
| 35 | + // Check if the album was added |
| 36 | + assertTrue(artist.getAlbums().contains("good kid, m.A.A.d city")); |
| 37 | + } |
| 38 | + |
| 39 | + @Test |
| 40 | + public void testIsAlive() { |
| 41 | + // Create a HipHopArtist object |
| 42 | + HipHopArtist artist = |
| 43 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 44 | + |
| 45 | + // Check if the artist is alive |
| 46 | + boolean expected = true; |
| 47 | + boolean actual = artist.isAlive(); |
| 48 | + |
| 49 | + // Assert the result |
| 50 | + assertEquals(expected, actual); |
| 51 | + } |
| 52 | + |
| 53 | + @Test |
| 54 | + public void testGetStageName() { |
| 55 | + // Create a HipHopArtist object |
| 56 | + HipHopArtist artist = |
| 57 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 58 | + |
| 59 | + // Get stage name |
| 60 | + String expected = "Kendrick Lamar"; |
| 61 | + String actual = artist.getStageName(); |
| 62 | + |
| 63 | + // Assert the result |
| 64 | + assertEquals(expected, actual); |
| 65 | + } |
| 66 | + |
| 67 | + @Test |
| 68 | + public void testSetAlive() { |
| 69 | + // Create a HipHopArtist object |
| 70 | + HipHopArtist artist = |
| 71 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 72 | + |
| 73 | + // Set alive status to false |
| 74 | + artist.setAlive(false); |
| 75 | + |
| 76 | + // Check if the artist is alive |
| 77 | + boolean expected = false; |
| 78 | + boolean actual = artist.isAlive(); |
| 79 | + |
| 80 | + // Assert the result |
| 81 | + assertEquals(expected, actual); |
| 82 | + } |
| 83 | + |
| 84 | + @Test |
| 85 | + public void testSetStageName() { |
| 86 | + // Create a HipHopArtist object |
| 87 | + HipHopArtist artist = |
| 88 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 89 | + |
| 90 | + // Set stage name |
| 91 | + artist.setStageName("K.Dot"); |
| 92 | + |
| 93 | + // Get stage name |
| 94 | + String expected = "K.Dot"; |
| 95 | + String actual = artist.getStageName(); |
| 96 | + |
| 97 | + // Assert the result |
| 98 | + assertEquals(expected, actual); |
| 99 | + } |
| 100 | + |
| 101 | + @Test |
| 102 | + public void testGetDebutYear() { |
| 103 | + // Create a HipHopArtist object |
| 104 | + HipHopArtist artist = |
| 105 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 106 | + |
| 107 | + // Get debut year |
| 108 | + int expected = 2012; |
| 109 | + int actual = artist.getDebutYear(); |
| 110 | + |
| 111 | + // Assert the result |
| 112 | + assertEquals(expected, actual); |
| 113 | + } |
| 114 | + |
| 115 | + @Test |
| 116 | + public void testSetDebutYear() { |
| 117 | + // Create a HipHopArtist object |
| 118 | + HipHopArtist artist = |
| 119 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 120 | + |
| 121 | + // Set debut year |
| 122 | + artist.setDebutYear(2011); |
| 123 | + |
| 124 | + // Get debut year |
| 125 | + int expected = 2011; |
| 126 | + int actual = artist.getDebutYear(); |
| 127 | + |
| 128 | + // Assert the result |
| 129 | + assertEquals(expected, actual); |
| 130 | + } |
| 131 | + |
| 132 | + @Test |
| 133 | + public void testGetNetWorth() { |
| 134 | + // Create a HipHopArtist object |
| 135 | + HipHopArtist artist = |
| 136 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 137 | + |
| 138 | + // Get net worth |
| 139 | + double expected = 75_000_000; |
| 140 | + double actual = artist.getNetWorth(); |
| 141 | + |
| 142 | + // Assert the result |
| 143 | + assertEquals(expected, actual); |
| 144 | + } |
| 145 | + |
| 146 | + @Test |
| 147 | + public void testSetNetWorth() { |
| 148 | + // Create a HipHopArtist object |
| 149 | + HipHopArtist artist = |
| 150 | + new HipHopArtist(true, "Kendrick Lamar", 2012, 75_000_000, new ArrayList<>(), Genre.RAP); |
| 151 | + |
| 152 | + // Set net worth |
| 153 | + artist.setNetWorth(80_000_000); |
| 154 | + |
| 155 | + // Get net worth |
| 156 | + double expected = 80_000_000; |
| 157 | + double actual = artist.getNetWorth(); |
| 158 | + |
| 159 | + // Assert the result |
| 160 | + assertEquals(expected, actual); |
| 161 | + } |
| 162 | +} |
0 commit comments