@Test public void testValidateFunctionNoActionRequiredValidDocument() { SearchResult jestResult = mock(SearchResult.class); // Build mocks when(jestClientHelper.execute(any())).thenReturn(jestResult); when(jestResult.getSourceAsString()).thenReturn("JSON"); indexFunctionsDao.validateDocumentIndex("INDEX_NAME", "DOCUMENT_TYPE", "ID", "JSON"); // Verify the calls to external methods verify(jestClientHelper, times(1)).execute(any()); verify(jestResult).getSourceAsString(); verifyNoMoreInteractions(jestClientHelper); }
@Test public void testIsValidFunction() { SearchResult jestResult = mock(SearchResult.class); // Build mocks when(jestClientHelper.execute(any())).thenReturn(jestResult); when(jestResult.getSourceAsString()).thenReturn("JSON"); // Call the method under test boolean isValid = indexFunctionsDao.isValidDocumentIndex("INDEX_NAME", "DOCUMENT_TYPE", "ID", "JSON"); assertThat("IsValid is false when it should have been true.", isValid, is(true)); verify(jestClientHelper, times(1)).execute(any()); verify(jestResult).getSourceAsString(); verifyNoMoreInteractions(jestClientHelper); }
@Test public void testIsValidFunctionNotEqual() { SearchResult jestResult = mock(SearchResult.class); // Build mocks when(jestClientHelper.execute(any())).thenReturn(jestResult); when(jestResult.getSourceAsString()).thenReturn("JSON_NOT_EQUAL"); // Call the method under test boolean isValid = indexFunctionsDao.isValidDocumentIndex("INDEX_NAME", "DOCUMENT_TYPE", "ID", "JSON"); assertThat("IsValid is true when it should have been false.", isValid, is(false)); verify(jestClientHelper, times(1)).execute(any()); verify(jestResult).getSourceAsString(); verifyNoMoreInteractions(jestClientHelper); }
@Test public void testValidateFunctionUpdate() { SearchResult jestResult = mock(SearchResult.class); // Build mocks when(jestClientHelper.execute(any())).thenReturn(jestResult); when(jestResult.getSourceAsString()).thenReturn("JSON_UPDATE"); indexFunctionsDao.validateDocumentIndex("INDEX_NAME", "DOCUMENT_TYPE", "ID", "JSON"); // Verify the calls to external methods verify(jestClientHelper, times(2)).execute(any()); verify(jestResult).getSourceAsString(); verify(jestResult).isSucceeded(); verifyNoMoreInteractions(jestClientHelper); }
@Test public void testIsValidFunctionEmpty() { SearchResult jestResult = mock(SearchResult.class); // Build mocks when(jestClientHelper.execute(any())).thenReturn(jestResult); when(jestResult.getSourceAsString()).thenReturn(""); // Call the method under test boolean isValid = indexFunctionsDao.isValidDocumentIndex("INDEX_NAME", "DOCUMENT_TYPE", "ID", "JSON"); assertThat("IsValid is true when it should have been false.", isValid, is(false)); verify(jestClientHelper, times(1)).execute(any()); verify(jestResult).getSourceAsString(); verifyNoMoreInteractions(jestClientHelper); }
@Test public void testIsValidFunctionNull() { SearchResult jestResult = mock(SearchResult.class); // Build mocks when(jestClientHelper.execute(any())).thenReturn(jestResult); when(jestResult.getSourceAsString()).thenReturn(null); // Call the method under test boolean isValid = indexFunctionsDao.isValidDocumentIndex("INDEX_NAME", "DOCUMENT_TYPE", "ID", "JSON"); assertThat("IsValid is true when it should have been false.", isValid, is(false)); verify(jestClientHelper, times(1)).execute(any()); verify(jestResult).getSourceAsString(); verifyNoMoreInteractions(jestClientHelper); }
@Test public void testValidateFunctionIndex() { SearchResult jestResult = mock(SearchResult.class); // Build mocks when(jestClientHelper.execute(any())).thenReturn(jestResult); when(jestResult.getSourceAsString()).thenReturn(""); indexFunctionsDao.validateDocumentIndex("INDEX_NAME", "DOCUMENT_TYPE", "ID", "JSON"); // Verify the calls to external methods verify(jestClientHelper, times(2)).execute(any()); verify(jestResult).getSourceAsString(); verify(jestResult).isSucceeded(); verifyNoMoreInteractions(jestClientHelper); }