package com.hubspot.blazar.data.service;

import com.google.common.base.Optional;
import com.hubspot.blazar.base.GitInfo;
import com.hubspot.blazar.data.BlazarDataTestBase;
import org.junit.Before;
import org.junit.Test;

import java.util.Set;

public class BranchServiceTest extends BlazarDataTestBase {
  private BranchService branchService;

  @Before
  public void before() {
    this.branchService = getFromGuice(BranchService.class);
  }

  @Test
  public void itCreatesABranch() {
    GitInfo gitInfo = branchService.upsert(new GitInfo(Optional.<Integer>absent(), "git.hubteam.com", "HubSpot", "Overwatch", 123, "master", true, System.currentTimeMillis(), System.currentTimeMillis()));
    Set<GitInfo> results = branchService.getAll();

    int i = 1;
  }

  @Test
  public void itReturnsAllBranches() {
    Set<GitInfo> results = branchService.getAll();
    System.out.println(results.size());
  }
}

@@ -226,20 +226,56 @@
 ort 
-java.util.Se
+static org.assertj.core.api.Assertions.assertTha
 t;%0A%0A
@@ -505,17 +505,16 @@
 tCreates
-A
 Branch()
@@ -532,208 +532,682 @@
 nfo 
-gitInfo = branchService.upsert(new GitInfo(Optional.%3CInteger%3Eabsent(), %22git.hubteam.com%22, %22HubSpot%22, %22Overwatch%22, 123, %22master%22, true, System.currentTimeMillis(), System.currentTimeMillis()
+original = newGitInfo(%22Overwatch%22);%0A    GitInfo inserted = branchService.upsert(original);%0A%0A    assertThat(inserted.getId().isPresent()).isTrue();%0A%0A    Optional%3CGitInfo%3E retrieved = branchService.get(inserted.getId().get());%0A%0A    assertThat(retrieved.isPresent()).isTrue();%0A    assertThat(retrieved.get()).isEqualTo(inserted);%0A  %7D%0A%0A  @Test%0A  public void itUpdatesRepositoryName() %7B%0A    GitInfo original = newGitInfo(%22Overwatch%22);%0A    GitInfo inserted = branchService.upsert(original);%0A%0A    GitInfo renamed = newGitInfo(%22Underwatch%22);%0A    GitInfo updated = branchService.upsert(renamed);%0A%0A    assertThat(updated.getId().get()).isEqualTo(inserted.getId().get(
 ));%0A
+%0A
     
-Set
+Optional
 %3CGit
@@ -1206,37 +1206,39 @@
 onal%3CGitInfo%3E re
-sults
+trieved
  = branchService
@@ -1245,87 +1245,205 @@
 .get
-All();%0A%0A    int i = 1;%0A  %7D%0A%0A  @Test%0A  public void itReturnsAllBranches(
+(inserted.getId().get());%0A%0A    assertThat(retrieved.isPresent()).isTrue();%0A    assertThat(retrieved.get()).isEqualTo(updated);%0A  %7D%0A%0A  private static GitInfo newGitInfo(String repositoryName
 ) %7B%0A    
 Set%3C
@@ -1442,90 +1442,165 @@
     
-Set%3CGitInfo%3E results = branchService.getAll();%0A    System.out.println(results.size
+return new GitInfo(Optional.%3CInteger%3Eabsent(), %22github%22, %22HubSpot%22, repositoryName, 123, %22master%22, true, System.currentTimeMillis(), System.currentTimeMillis
 ());

Add a few tests