ProtectDelegator extends BaseDelegator implements IProtectDelegator { @Override public String createProtectionEntries(@Nonnull final List<IProtectionEntry> entryList) throws P4JavaException { Validate.notNull(entryList); List<Map<String, Object>> resultMaps = execMapCmdList(PROTECT, new String[] { "-i" }, InputMapper.map(new ProtectionsTable(entryList))); return parseCommandResultMapIfIsInfoMessageAsString(resultMaps); } ProtectDelegator(IOptionsServer server); @Override String createProtectionEntries(@Nonnull final List<IProtectionEntry> entryList); @Override String updateProtectionEntries(@Nonnull final List<IProtectionEntry> entryList); @Override InputStream getProtectionsTable();  }
@SuppressWarnings("unchecked") @Test public void testCreateProtectionEntriesShouldReturnNonBlankString() throws Exception { resultMaps = buildProtectionEntries(); when(server.execMapCmdList(eq(PROTECT.toString()), eq(CREATE_CMD_ARGUMENTS), any(Map.class))) .thenReturn(resultMaps); String protectionEntries = protectDelegator.createProtectionEntries(entryList); assertThat(protectionEntries, is(infoMessage)); }
@Test public void testCreateProtectionEntriesShouldThrownNullPointerExceptionWhenEntryListIsNull() throws Exception { thrown.expect(NullPointerException.class); protectDelegator.createProtectionEntries(null); }
@Test public void testCreateProtectionEntriesShouldReturnNonBlankString() throws Exception { resultMaps = buildProtectionEntries(); when(server.execMapCmdList(eq(PROTECT.toString()), eq(CREATE_CMD_ARGUMENTS), anyMap())) .thenReturn(resultMaps); String protectionEntries = protectDelegator.createProtectionEntries(entryList); assertThat(protectionEntries, is(infoMessage)); }