/** * Argument that is either <code>null</code> or of the given type. * * <p> * See examples in javadoc for {@link ArgumentMatchers} class * </p> * * @param clazz Type to avoid casting * @return <code>null</code>. */ public static <T> T nullable(Class<T> clazz) { AdditionalMatchers.or(isNull(), isA(clazz)); return (T) Primitives.defaultValue(clazz); }
@Test public void shouldRegisterAnInstanceOfEachOfTheRequiredPluginServicesAfterOSGiFrameworkIsInitialized() { spy.start(); verify(bundleContext).registerService(eq(PluginHealthService.class), any(DefaultPluginHealthService.class), isNull(Dictionary.class)); verify(bundleContext).registerService(eq(LoggingService.class), any(DefaultPluginLoggingService.class), isNull(Dictionary.class)); }
@SuppressWarnings( "unchecked" ) void getsProcessedByStoreScanFrom( IndexStoreView mock ) { when( mock.visitNodes( any(int[].class), any( IntPredicate.class ), any( Visitor.class ), isNull(), anyBoolean() ) ).thenAnswer( this ); }
@Test public void return_since_version_detailed_label_when_date_is_set() { periods.label(LEAK_PERIOD_MODE_VERSION, VERSION, STRING_DATE); verify(i18n).message(any(Locale.class), eq("since_version_detailed"), isNull(String.class), eq(VERSION), eq(STRING_DATE)); }
@Test public void return_since_version_abbreviation_when_no_date() { periods.abbreviation(LEAK_PERIOD_MODE_VERSION, VERSION, null); verify(i18n).message(any(Locale.class), eq("since_version.short"), isNull(String.class), eq(VERSION)); }
@Test public void return_since_x_label() { periods.label(LEAK_PERIOD_MODE_DATE, null, STRING_DATE); verify(i18n).message(any(Locale.class), eq("since_x"), isNull(String.class), eq(STRING_DATE)); }
@Test public void return_over_x_days_abbreviation_when_no_date() { periods.abbreviation(LEAK_PERIOD_MODE_DAYS, NUMBER_OF_DAYS, null); verify(i18n).message(any(Locale.class), eq("over_x_days.short"), isNull(String.class), eq(NUMBER_OF_DAYS)); }
@Test public void return_over_x_days_label_when_no_date() { periods.label(LEAK_PERIOD_MODE_DAYS, NUMBER_OF_DAYS, (String) null); verify(i18n).message(any(Locale.class), eq("over_x_days"), isNull(String.class), eq(NUMBER_OF_DAYS)); }
@Test public void return_since_previous_version_with_only_date_label_when_no_param_and_date_is_set() { periods.label(LEAK_PERIOD_MODE_PREVIOUS_VERSION, null, STRING_DATE); verify(i18n).message(any(Locale.class), eq("since_previous_version_with_only_date"), isNull(String.class), eq(STRING_DATE)); }
@Test public void return_over_x_days_label_using_settings() { settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, NUMBER_OF_DAYS); periods.label(PERIOD_INDEX); verify(i18n).message(any(Locale.class), eq("over_x_days"), isNull(String.class), eq(NUMBER_OF_DAYS)); }
@Test public void return_since_x_label_using_settings() { settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, STRING_DATE); periods.label(PERIOD_INDEX); verify(i18n).message(any(Locale.class), eq("since_x"), isNull(String.class), anyString()); }
@Test public void return_since_previous_version_label_using_settings() { settings.setProperty(LEAK_PERIOD + PERIOD_INDEX, LEAK_PERIOD_MODE_PREVIOUS_VERSION); periods.label(PERIOD_INDEX); verify(i18n).message(any(Locale.class), eq("since_previous_version"), isNull(String.class)); }
@SuppressWarnings( "unchecked" ) @Test public void shouldRegisterAtRootByDefault() throws Exception { WebServer webServer = mock( WebServer.class ); Config config = mock( Config.class ); CommunityNeoServer neoServer = mock( CommunityNeoServer.class ); when( neoServer.baseUri() ).thenReturn( new URI( "http://localhost:7575" ) ); when( neoServer.getWebServer() ).thenReturn( webServer ); when( config.get( GraphDatabaseSettings.auth_enabled ) ).thenReturn( true ); DBMSModule module = new DBMSModule( webServer, config, () -> new DiscoverableURIs.Builder().build() ); module.start(); verify( webServer ).addJAXRSClasses( anyList(), anyString(), isNull() ); }
@Test public void shouldUpdateIndexesOnRemovedLabel() { // WHEN indexTxUpdater.onLabelChange( labelId2, node, propertyCursor, REMOVED_LABEL ); // THEN verifyIndexUpdate( uniqueOn2_2_3.schema(), node.nodeReference(), values( "hi2", "hi3" ), null ); verify( txState, times( 1 ) ).indexDoUpdateEntry( any(), anyLong(), any(), isNull() ); }
@Test public void performRetryRetriesIfNoNetworkScanning() { BitmapHunter hunter = mockHunter(URI_KEY_1, new RequestHandler.Result(bitmap1, MEMORY), mockAction(URI_KEY_1, URI_1)); when(hunter.shouldRetry(anyBoolean(), isNull(NetworkInfo.class))).thenReturn(true); Dispatcher dispatcher = createDispatcher(false); dispatcher.performRetry(hunter); assertThat(dispatcher.hunterMap).isEmpty(); assertThat(dispatcher.failedActions).isEmpty(); verify(service).submit(hunter); }
@Test public void testIndexAllNodes() throws FlipFailedKernelException { IndexPopulator indexPopulator1 = createIndexPopulator(); IndexPopulator indexPopulator2 = createIndexPopulator(); addPopulator( indexPopulator1, 1 ); addPopulator( indexPopulator2, 2 ); multipleIndexPopulator.create(); multipleIndexPopulator.indexAllEntities(); verify( indexStoreView ) .visitNodes( any( int[].class ), any( IntPredicate.class ), any( Visitor.class ), isNull(), anyBoolean() ); }
@Test public void testOnePortAndSearchArchivedIsTrueAndFileOffsetIs1AndByteOffsetIs100() throws IOException { LogviewerLogSearchHandler handler = getStubbedSearchHandler(); handler.deepSearchLogsForTopology("", null, "search", "20", "6700", "1", "100", true, null, null); verify(handler, times(1)).findNMatches(anyList(), anyInt(), anyInt(), anyInt(), anyString()); verify(handler, times(2)).logsForPort(isNull(), any(File.class)); }
@Test public void shouldUpdateIndexesOnAddedLabel() { // WHEN indexTxUpdater.onLabelChange( labelId1, node, propertyCursor, ADDED_LABEL ); // THEN verifyIndexUpdate( indexOn1_1.schema(), node.nodeReference(), null, values( "hi1" ) ); verifyIndexUpdate( uniqueOn1_2.schema(), node.nodeReference(), null, values( "hi2" ) ); verify( txState, times( 2 ) ).indexDoUpdateEntry( any(), anyLong(), isNull(), any() ); }
@Test public void shouldUpdateIndexesOnAddedProperty() { // WHEN indexTxUpdater.onPropertyAdd( node, propertyCursor, newPropId, Values.of( "newHi" ) ); // THEN verifyIndexUpdate( indexOn2_new.schema(), node.nodeReference(), null, values( "newHi" ) ); verifyIndexUpdate( indexOn1_1_new.schema(), node.nodeReference(), null, values( "hi1", "newHi" ) ); verify( txState, times( 2 ) ).indexDoUpdateEntry( any(), anyLong(), isNull(), any() ); }
@Test public void shouldUpdateIndexesOnRemovedProperty() { // WHEN indexTxUpdater.onPropertyRemove( node, propertyCursor, propId2, Values.of( "hi2" ) ); // THEN verifyIndexUpdate( uniqueOn1_2.schema(), node.nodeReference(), values( "hi2" ), null ); verifyIndexUpdate( uniqueOn2_2_3.schema(), node.nodeReference(), values( "hi2", "hi3" ), null ); verify( txState, times( 2 ) ).indexDoUpdateEntry( any(), anyLong(), any(), isNull() ); }