package com.google.sps;

import com.google.common.collect.ImmutableSet;
import com.google.sps.data.VolunteeringOpportunity;
import java.util.HashSet;
import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** */
@RunWith(JUnit4.class)
public final class VolunteerOpportunityTest {
  private static final String NAME = "Performer";
  private static final int NUMBER_OF_SPOTS = 240;
  private static final Set<String> SKILLS = ImmutableSet.of("Playing an instrument", "Performing");
  public static final Set<String> NEW_SKILLS = ImmutableSet.of("Singing", "Performing");
  public static final Set<String> SKILLS_WITH_DANCING =
      ImmutableSet.of("Playing an instrument", "Performing", "Dancing");
  public static final String DANCING = "Dancing";

  @Test
  public void getAttributesAfterBuild() {
    VolunteeringOpportunity opportunity =
        new VolunteeringOpportunity.Builder(NAME, NUMBER_OF_SPOTS)
            .setRequiredSkills(SKILLS)
            .build();

    String actualName = opportunity.getName();
    String expectedName = NAME;
    int actualNumSpotsLeft = opportunity.getNumSpotsLeft();
    int expectedNumSpotsLeft = NUMBER_OF_SPOTS;
    Set<String> actualSkills = opportunity.getRequiredSkills();
    Set<String> expectedSkills = SKILLS;

    Assert.assertEquals(actualName, expectedName);
    Assert.assertEquals(actualNumSpotsLeft, expectedNumSpotsLeft);
    Assert.assertEquals(actualSkills, expectedSkills);
  }

  @Test
  public void getAttributesWithToBuild() {
    VolunteeringOpportunity opportunity =
        new VolunteeringOpportunity.Builder(NAME, NUMBER_OF_SPOTS)
            .setRequiredSkills(SKILLS)
            .build();
    VolunteeringOpportunity copyOfOpportunity = opportunity.toBuilder().build();

    String actualName = copyOfOpportunity.getName();
    String expectedName = NAME;
    int actualNumSpotsLeft = copyOfOpportunity.getNumSpotsLeft();
    int expectedNumSpotsLeft = NUMBER_OF_SPOTS;
    Set<String> actualSkills = copyOfOpportunity.getRequiredSkills();
    Set<String> expectedSkills = SKILLS;

    Assert.assertEquals(actualName, expectedName);
    Assert.assertEquals(actualNumSpotsLeft, expectedNumSpotsLeft);
    Assert.assertEquals(actualSkills, expectedSkills);
  }

  @Test
  public void addSkillsWithBuild() {
    Set<String> skills = new HashSet<String>();
    skills.add("Playing an instrument");
    skills.add("Performing");
    VolunteeringOpportunity opportunityWithSkills =
        new VolunteeringOpportunity.Builder(NAME, NUMBER_OF_SPOTS)
            .setRequiredSkills(skills)
            .build();

    VolunteeringOpportunity changedOpportunity =
        opportunityWithSkills.toBuilder().addRequiredSkill(DANCING).build();

    Set<String> actual = changedOpportunity.getRequiredSkills();
    Set<String> expected = SKILLS_WITH_DANCING;

    Assert.assertEquals(expected, actual);
  }

  @Test
  public void removeSkillsWithBuild() {
    Set<String> skills = new HashSet<String>();
    skills.add("Playing an instrument");
    skills.add("Performing");
    VolunteeringOpportunity opportunityWithSkills =
        new VolunteeringOpportunity.Builder(NAME, NUMBER_OF_SPOTS)
            .setRequiredSkills(skills)
            .build();
    VolunteeringOpportunity changedOpportunity =
        opportunityWithSkills.toBuilder().removeRequiredSkill(DANCING).build();

    Set<String> actual = changedOpportunity.getRequiredSkills();
    Set<String> expected = SKILLS;

    Assert.assertEquals(expected, actual);
  }
}

@@ -483,82 +483,214 @@
 nal 
-Set%3C
 String
-%3E SKILLS = ImmutableSet.of(%22Playing an instrument%22, %22Performing%22
+ PLAYING_AN_INSTRUMENT = %22Playing an instrument%22;%0A  private static final String PERFORMING = %22Performing%22;%0A  private static final Set%3CString%3E SKILLS = ImmutableSet.of(PLAYING_AN_INSTRUMENT, PERFORMING
 );%0A 
@@ -1044,32 +1044,24 @@
 pportunity =
-%0A       
  new Volunte
@@ -1124,35 +1124,103 @@
     
-.setRequiredSkills(SKILLS)%0A
+                                  .setRequiredSkills(SKILLS)%0A                                  
     
@@ -1801,24 +1801,16 @@
 tunity =
-%0A       
  new Vol
@@ -1877,35 +1877,103 @@
     
-.setRequiredSkills(SKILLS)%0A
+                                  .setRequiredSkills(SKILLS)%0A                                  
     
@@ -2669,39 +2669,37 @@
 lls.add(
-%22Playing an instrument%22
+PLAYING_AN_INSTRUMENT
 );%0A    s
@@ -2704,36 +2704,34 @@
  skills.add(
-%22Performing%22
+PERFORMING
 );%0A    Volun
@@ -3302,39 +3302,65 @@
 lls.add(
-%22Playing an instrument%22
+PLAYING_AN_INSTRUMENT);%0A    skills.add(PERFORMING
 );%0A    s
@@ -3369,28 +3369,23 @@
 lls.add(
-%22Performing%22
+DANCING
 );%0A    V

Add constants.