VerifyDelegator extends BaseDelegator implements IVerifyDelegator { @Override public List<IExtendedFileSpec> verifyFiles( final List<IFileSpec> fileSpecs, final VerifyFilesOptions opts) throws P4JavaException { List<Map<String, Object>> resultMaps = execMapCmdList( VERIFY, processParameters(opts, fileSpecs, server), null); return buildNonNullExtendedFileSpecListFromCommandResultMaps(resultMaps, server); } VerifyDelegator(IOptionsServer server); @Override List<IExtendedFileSpec> verifyFiles(
      final List<IFileSpec> fileSpecs,
      final VerifyFilesOptions opts);  }
@Test public void shouldReturnNonEmptyListWhenErrorMessageIsRealErrorMessage() throws Exception { givenErrorMessageCode(); when(server.handleFileErrorStr(eq(resultMap))).thenReturn(P4JavaUtil.dummyServerErrorMessage("not blank")); List<IExtendedFileSpec> extendedFileSpecs = verifyDelegator.verifyFiles(fileSpecs, opts); assertThat(extendedFileSpecs.size(), is(1)); assertThat(extendedFileSpecs.get(0).getOpStatus(), is(FileSpecOpStatus.ERROR)); }
@Test public void shouldReturnNonEmptyListWhenErrorMessageIsInfoMessage() throws Exception { givenInfoMessageCode(); when(server.handleFileErrorStr(eq(resultMap))).thenReturn(P4JavaUtil.dummyServerErrorMessage("not blank")); List<IExtendedFileSpec> extendedFileSpecs = verifyDelegator.verifyFiles(fileSpecs, opts); assertThat(extendedFileSpecs.size(), is(1)); assertThat(extendedFileSpecs.get(0).getOpStatus(), is(FileSpecOpStatus.INFO)); }
@Test public void shouldReturnEmptyListWhenNoErrorNoDepotPath() throws Exception { when(resultMap.containsKey(DEPOT_FILE)).thenReturn(false); List<IExtendedFileSpec> extendedFileSpecs = verifyDelegator.verifyFiles(fileSpecs, opts); assertThat(extendedFileSpecs.size(), is(0)); }
@Test public void shouldReturnEmptyListWhenNoErrorHasDepotPathButContainsDescField() throws Exception { when(resultMap.containsKey(DEPOT_FILE)).thenReturn(true); when(resultMap.containsKey(DESC)).thenReturn(true); List<IExtendedFileSpec> extendedFileSpecs = verifyDelegator.verifyFiles(fileSpecs, opts); assertThat(extendedFileSpecs.size(), is(0)); }
@Test public void shouldReturnEmptyListWhenResultMapsIsNull() throws Exception { when(server.execMapCmdList(eq(VERIFY.toString()), eq(CMD_ARGUMENTS), eq((Map<String, Object>) null))).thenReturn(null); List<IExtendedFileSpec> extendedFileSpecs = verifyDelegator.verifyFiles(fileSpecs, opts); assertThat(extendedFileSpecs.size(), is(0)); }
@SuppressWarnings("deprecation") @Test public void shouldReturnNonEmptyListWhenErrorMessageIsRealErrorMessage() throws Exception { givenErrorMessageCode(); when(server.handleFileErrorStr(eq(resultMap))).thenReturn("not blank"); List<IExtendedFileSpec> extendedFileSpecs = verifyDelegator.verifyFiles(fileSpecs, opts); assertThat(extendedFileSpecs.size(), is(1)); assertThat(extendedFileSpecs.get(0).getOpStatus(), is(FileSpecOpStatus.ERROR)); }
@SuppressWarnings("deprecation") @Test public void shouldReturnNonEmptyListWhenErrorMessageIsInfoMessage() throws Exception { givenInfoMessageCode(); when(server.handleFileErrorStr(eq(resultMap))).thenReturn("not blank"); List<IExtendedFileSpec> extendedFileSpecs = verifyDelegator.verifyFiles(fileSpecs, opts); assertThat(extendedFileSpecs.size(), is(1)); assertThat(extendedFileSpecs.get(0).getOpStatus(), is(FileSpecOpStatus.INFO)); }
@Test public void shouldReturnNonEmptyListWhenErrorMessageIsRealErrorMessage() throws Exception { givenErrorMessageCode(); when(server.handleFileErrorStr(eq(resultMap))).thenReturn("not blank"); List<IExtendedFileSpec> extendedFileSpecs = verifyDelegator.verifyFiles(fileSpecs, opts); assertThat(extendedFileSpecs.size(), is(1)); assertThat(extendedFileSpecs.get(0).getOpStatus(), is(FileSpecOpStatus.ERROR)); }
@Test public void shouldReturnNonEmptyListWhenErrorMessageIsInfoMessage() throws Exception { givenInfoMessageCode(); when(server.handleFileErrorStr(eq(resultMap))).thenReturn("not blank"); List<IExtendedFileSpec> extendedFileSpecs = verifyDelegator.verifyFiles(fileSpecs, opts); assertThat(extendedFileSpecs.size(), is(1)); assertThat(extendedFileSpecs.get(0).getOpStatus(), is(FileSpecOpStatus.INFO)); }