FirstTokenBranchResolver implements BranchResolver { @Override public String getBranchNameFor(Environment environment) { String[] tokens = environment.getName().split("/"); String branchName = tokens[0].trim(); if (branchName.isEmpty()) { branchName = "master"; } return branchName; }  @Override String getBranchNameFor(Environment environment);  }
@Test void resolvesEmptyStringToMaster() { when(environment.getName()).thenReturn(""); assertThat(branchResolver.getBranchNameFor(environment)).isEqualTo("master"); }
@Test void resolvesWhitespacesToMaster() { when(environment.getName()).thenReturn(" "); assertThat(branchResolver.getBranchNameFor(environment)).isEqualTo("master"); }
@Test void supportsSingleToken() { when(environment.getName()).thenReturn("us-west-1"); assertThat(branchResolver.getBranchNameFor(environment)).isEqualTo("us-west-1"); }
@Test void usesFirstTokenAsBranchName() { when(environment.getName()).thenReturn("us-west-1/local/path"); assertThat(branchResolver.getBranchNameFor(environment)).isEqualTo("us-west-1"); }