BranchDelegator extends BaseDelegator implements IBranchDelegator { @Override public String updateBranchSpec(@Nonnull final IBranchSpec branchSpec) throws ConnectionException, RequestException, AccessException { Validate.notNull(branchSpec); return asRequestException(() -> { List<Map<String, Object>> resultMaps = execMapCmdList( BRANCH, new String[]{"-i"}, InputMapper.map(branchSpec)); return ResultMapParser.parseCommandResultMapAsString(resultMaps); }); } BranchDelegator(IOptionsServer server); @Override String createBranchSpec(@Nonnull final IBranchSpec branchSpec); @Override IBranchSpec getBranchSpec(final String name); @Override IBranchSpec getBranchSpec(final String name, final GetBranchSpecOptions opts); @Override String updateBranchSpec(@Nonnull final IBranchSpec branchSpec); @Override String deleteBranchSpec(final String branchSpecName, final boolean force); @Override String deleteBranchSpec(final String branchSpecName, final DeleteBranchSpecOptions opts);  }
@Test(expected=NullPointerException.class) public void testUpdateNullBranchSpec() throws P4JavaException { branchSpecDelegator.updateBranchSpec(null); }
@Test public void testUpdateBranchSpec() throws P4JavaException { when(server.execMapCmdList(eq(BRANCH.toString()), any(String[].class), any(Map.class))) .thenReturn(resultMaps); when(resultMap.get(CODE0)).thenReturn("268435456"); when(resultMap.get(FMT0)).thenReturn("%branch%"); when(resultMap.get("branch")).thenReturn(mockBranchSpecName); String updateBranchSpec = branchSpecDelegator.updateBranchSpec(mockBranchSpec); assertEquals(mockBranchSpecName, updateBranchSpec); }