Skip to content

feat: adds classes and unit tests to lesson16 homework #515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.codedifferently.lesson16.ezranyabuti;

import java.util.ArrayList;

public class Party {

private String name;
private String location;
private String localDate;
private Boolean isPrivate;
private double coverCharge;
private int ticketNumber;
private Vibe vibe;
private ArrayList<String> guestList;

public Party(
String name,
String location,
String localDate,
Boolean isPrivate,
Double coverCharge,
int ticketNumber,
Vibe vibe,
String[] guestList) {
this.name = name;
this.location = location;
this.isPrivate = isPrivate;
this.coverCharge = coverCharge;
this.ticketNumber = ticketNumber;
this.vibe = vibe;
this.guestList = new ArrayList<>();
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getLocation() {
return location;
}

public void setLocation(String location) {
this.location = location;
}

public String getLocalDate() {
return localDate;
}

public void setLocalDate(String localDate) {
this.localDate = localDate;
}

public Boolean getIsPrivate() {
return isPrivate;
}

public void setIsPrivate(Boolean isPrivate) {
this.isPrivate = isPrivate;
}

public double getCoverCharge() {
return coverCharge;
}

public void setCoverCharge(double coverCharge) {
this.coverCharge = coverCharge;
}

public int getTicketNumber() {
return ticketNumber;
}

public void setTicketNumber(int ticketNumber) {
this.ticketNumber = ticketNumber;
}

public Vibe getVibe() {
return vibe;
}

public void setVibe(Vibe vibe) {
this.vibe = vibe;
}

public ArrayList<String> getGuestList() {
ArrayList<String> copy = new ArrayList<>();
for (String guest : guestList) {
copy.add(guest);
}
return copy;
}

public void setGuestList(ArrayList<String> guestList) {
this.guestList = guestList;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.codedifferently.lesson16.ezranyabuti;

public class PartyCityException extends Exception {
public PartyCityException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.codedifferently.lesson16.ezranyabuti;

public enum Vibe {
CHILL,
PRIVATE,
ALL_WHITE,
RELAXED_LOUNGE,
COSTUME
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.codedifferently.lesson16.ezranyabuti;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Test;

public class PartyExceptionTest {
@Test
void testConstructor() {
String expectedMessage = "Party is not private";
PartyCityException exception = new PartyCityException(expectedMessage);
String actualMessage = exception.getMessage();
assertThat(actualMessage).isEqualTo(expectedMessage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
package com.codedifferently.lesson16.ezranyabuti;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.ArrayList;
import java.util.Arrays;
import org.junit.jupiter.api.Test;

public class PartyTest {

@Test
void testGetName() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
String expectedName = "Everyday People";
party.setName(expectedName);
String actualName = party.getName();
assertThat(actualName).isEqualTo(expectedName);
}

@Test
void testGetlocalDate() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
String expectedDate = "2025-06-012";
party.setLocalDate(expectedDate);
String actualDate = party.getLocalDate();
assertThat(actualDate).isEqualTo(expectedDate);
}

@Test
void testGetCoverCharge() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
Double expectedCharge = 50.0;
party.setCoverCharge(expectedCharge);
Double actualCharge = party.getCoverCharge();
assertThat(actualCharge).isEqualTo(expectedCharge);
}

@Test
void testGetVibe() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
Vibe expectedVibe = Vibe.CHILL;
party.setVibe(expectedVibe);
Vibe actualVibe = party.getVibe();
assertThat(actualVibe).isEqualTo(expectedVibe);
}

@Test
void testSetVibe() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
}

@Test
void testSetName() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
String expectedName = "Everyday People";
party.setName(expectedName);
String actualName = party.getName();
assertThat(actualName).isEqualTo(expectedName);
}

@Test
void testSetLocation() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
String expectedLocation = "Brooklyn";
party.setLocation(expectedLocation);
String actualLocation = party.getLocation();
assertThat(actualLocation).isEqualTo(expectedLocation);
}

@Test
void testGetLocation() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
String expectedLocation = "Brooklyn";
party.setLocation(expectedLocation);
String actualLocation = party.getLocation();
assertThat(actualLocation).isEqualTo(expectedLocation);
}

@Test
void testGetPrivate() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
Boolean expectedPrivate = false;
party.setIsPrivate(expectedPrivate);
Boolean actualPrivate = party.getIsPrivate();
assertThat(actualPrivate).isEqualTo(expectedPrivate);
}

@Test
void testSetPrivate() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
Boolean expectedPrivate = true;
party.setIsPrivate(expectedPrivate);
Boolean actualPrivate = party.getIsPrivate();
assertThat(actualPrivate).isEqualTo(expectedPrivate);
}

@Test
void testCoverCharge() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
Double expectedCharge = 50.0;
party.setCoverCharge(expectedCharge);
Double actualCharge = party.getCoverCharge();
assertThat(actualCharge).isEqualTo(expectedCharge);
}

@Test
void testGetTicketNum() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
int expectedNum = 10;
party.setTicketNumber(expectedNum);
int actualTicketNumber = party.getTicketNumber();
assertThat(actualTicketNumber).isEqualTo(expectedNum);
}

@Test
void testSetTicketNum() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
int expectedNum = 10;
party.setTicketNumber(expectedNum);
int actualTicketNumber = party.getTicketNumber();
assertThat(actualTicketNumber).isEqualTo(expectedNum);
}

@Test
void testGuestList() {
Party party =
new Party(
"Everyday People",
"Washington D.C.",
"2025-06-012",
false,
50.0,
0,
Vibe.CHILL,
new String[] {});
String[] expectedGuestList = {"Meiko", "Ezra", "Bryana", "Justin"};

ArrayList<String> guestList = new ArrayList<>(Arrays.asList(expectedGuestList));
party.setGuestList(guestList);

ArrayList<String> actualGuestList = party.getGuestList();
assertThat(actualGuestList).isEqualTo(new ArrayList<>(Arrays.asList(expectedGuestList)));
}
}
Loading