src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
WaynameFeatureFilter { @Nullable Point findPointFromCurrentPoint(@Nullable Point currentPoint, @NonNull LineString lineString) { List<Point> lineStringCoordinates = lineString.coordinates(); int coordinateSize = lineStringCoordinates.size(); if (coordinateSize < TWO_POINTS) { return null; } Point lastLinePoint = lineSt... | @Test public void findPointFromCurrentPoint() { Feature featureOne = Feature.fromJson(loadJsonFixture("feature_one.json")); Point currentPoint = Point.fromLngLat(1.234, 4.567); WaynameFeatureFilter waynameFeatureFilter = buildFilter(); Point featureAheadOfUser = waynameFeatureFilter.findPointFromCurrentPoint(currentPoi... |
LocationFpsDelegate implements MapboxMap.OnCameraIdleListener { @Override public void onCameraIdle() { if (!isEnabled) { return; } updateMaxFps(); } LocationFpsDelegate(@NonNull MapboxMap mapboxMap, @NonNull LocationComponent locationComponent); @Override void onCameraIdle(); } | @Test public void onCameraIdle_newFpsIsSetZoom16() { double zoom = 16d; MapboxMap mapboxMap = mock(MapboxMap.class); when(mapboxMap.getCameraPosition()).thenReturn(buildCameraPosition(zoom)); LocationComponent locationComponent = mock(LocationComponent.class); LocationFpsDelegate locationFpsDelegate = new LocationFpsDe... |
LocationFpsDelegate implements MapboxMap.OnCameraIdleListener { void onStart() { mapboxMap.addOnCameraIdleListener(this); } LocationFpsDelegate(@NonNull MapboxMap mapboxMap, @NonNull LocationComponent locationComponent); @Override void onCameraIdle(); } | @Test public void onStart_idleListenerAdded() { MapboxMap mapboxMap = mock(MapboxMap.class); LocationComponent locationComponent = mock(LocationComponent.class); LocationFpsDelegate locationFpsDelegate = new LocationFpsDelegate(mapboxMap, locationComponent); locationFpsDelegate.onStart(); verify(mapboxMap, times(2)).ad... |
LocationFpsDelegate implements MapboxMap.OnCameraIdleListener { void onStop() { mapboxMap.removeOnCameraIdleListener(this); } LocationFpsDelegate(@NonNull MapboxMap mapboxMap, @NonNull LocationComponent locationComponent); @Override void onCameraIdle(); } | @Test public void onStop_idleListenerRemoved() { MapboxMap mapboxMap = mock(MapboxMap.class); LocationComponent locationComponent = mock(LocationComponent.class); LocationFpsDelegate locationFpsDelegate = new LocationFpsDelegate(mapboxMap, locationComponent); locationFpsDelegate.onStop(); verify(mapboxMap).removeOnCame... |
LocationFpsDelegate implements MapboxMap.OnCameraIdleListener { void updateEnabled(boolean isEnabled) { this.isEnabled = isEnabled; resetMaxFps(); } LocationFpsDelegate(@NonNull MapboxMap mapboxMap, @NonNull LocationComponent locationComponent); @Override void onCameraIdle(); } | @Test public void updateEnabled_falseResetsToMax() { MapboxMap mapboxMap = mock(MapboxMap.class); LocationComponent locationComponent = mock(LocationComponent.class); LocationFpsDelegate locationFpsDelegate = new LocationFpsDelegate(mapboxMap, locationComponent); locationFpsDelegate.updateEnabled(false); verify(locatio... |
MapWayName { void updateWayNameWithPoint(PointF point) { if (!isAutoQueryEnabled) { return; } List<Feature> roadLabelFeatures = findRoadLabelFeatures(point); boolean invalidLabelFeatures = roadLabelFeatures.isEmpty(); if (invalidLabelFeatures) { return; } executeFeatureFilterTask(roadLabelFeatures); } MapWayName(Waynam... | @Test public void onFeatureWithoutNamePropertyReturned_updateIsIgnored() { PointF point = mock(PointF.class); SymbolLayer waynameLayer = mock(SymbolLayer.class); List<Feature> roads = new ArrayList<>(); Feature road = mock(Feature.class); roads.add(road); MapWayName mapWayName = buildMapWayname(point, roads); mapWayNam... |
NavigationViewSubscriber implements LifecycleObserver { @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY) void unsubscribe() { navigationViewModel.retrieveRoute().removeObservers(lifecycleOwner); navigationViewModel.retrieveDestination().removeObservers(lifecycleOwner); navigationViewModel.retrieveNavigationLocation().remo... | @Test public void checkObserversAreRemovedWhenUnsubscribe() { when(navigationViewModel.retrieveRoute()).thenReturn(mock(MutableLiveData.class)); when(navigationViewModel.retrieveNavigationLocation()).thenReturn(mock(MutableLiveData.class)); when(navigationViewModel.retrieveDestination()).thenReturn(mock(MutableLiveData... |
NavigationViewSubscriber implements LifecycleObserver { void subscribe() { navigationViewModel.retrieveRoute().observe(lifecycleOwner, directionsRoute -> { if (directionsRoute != null) { navigationPresenter.onRouteUpdate(directionsRoute); } }); navigationViewModel.retrieveDestination().observe(lifecycleOwner, point -> ... | @Test public void checkObserversAreAddedWhenSubscribe() { when(navigationViewModel.retrieveRoute()).thenReturn(mock(MutableLiveData.class)); when(navigationViewModel.retrieveNavigationLocation()).thenReturn(mock(MutableLiveData.class)); when(navigationViewModel.retrieveDestination()).thenReturn(mock(MutableLiveData.cla... |
NavigationOnCameraTrackingChangedListener implements OnCameraTrackingChangedListener { @Override public void onCameraTrackingDismissed() { if (summaryBehavior.getState() != BottomSheetBehavior.STATE_HIDDEN) { navigationPresenter.onCameraTrackingDismissed(); } } NavigationOnCameraTrackingChangedListener(NavigationPresen... | @Test public void onCameraTrackingDismissed_presenterNotifiedWithVisibleBottomsheet() { NavigationPresenter presenter = mock(NavigationPresenter.class); BottomSheetBehavior behavior = mock(BottomSheetBehavior.class); when(behavior.getState()).thenReturn(BottomSheetBehavior.STATE_EXPANDED); NavigationOnCameraTrackingCha... |
AbbreviationCreator extends NodeCreator<AbbreviationCreator.AbbreviationNode, AbbreviationVerifier> { @Override void preProcess(@NonNull TextView textView, @NonNull List<BannerComponentNode> bannerComponentNodes) { String text = abbreviateBannerText(textView, bannerComponentNodes); textView.setText(text); } Abbreviatio... | @Test public void preProcess_abbreviate() { String abbreviation = "smtxt"; BannerComponents bannerComponents = BannerComponentsFaker.bannerComponentsBuilder() .abbreviation(abbreviation) .abbreviationPriority(0) .build(); TextView textView = mock(TextView.class); AbbreviationVerifier abbreviationVerifier = mock(Abbrevi... |
AbbreviationCreator extends NodeCreator<AbbreviationCreator.AbbreviationNode, AbbreviationVerifier> { @NonNull @Override AbbreviationNode setupNode(@NonNull BannerComponents components, int index, int startIndex, String modifier) { addPriorityInfo(components, index); return new AbbreviationNode(components, startIndex);... | @Test public void setupNode() { String abbreviation = "smtxt"; int abbreviationPriority = 0; BannerComponents bannerComponents = BannerComponentsFaker.bannerComponentsBuilder() .abbreviation(abbreviation) .abbreviationPriority(abbreviationPriority) .build(); AbbreviationVerifier abbreviationVerifier = mock(Abbreviation... |
NavigationPresenter { void onRouteOverviewClick() { view.setWayNameActive(false); view.setWayNameVisibility(false); view.updateCameraRouteOverview(); view.showRecenterBtn(); } NavigationPresenter(NavigationContract.View view); } | @Test public void onRouteOverviewButtonClick_cameraIsAdjustedToRoute() { NavigationContract.View view = mock(NavigationContract.View.class); NavigationPresenter presenter = new NavigationPresenter(view); presenter.onRouteOverviewClick(); verify(view).updateCameraRouteOverview(); }
@Test public void onRouteOverviewButto... |
BannerComponentTree { void loadInstruction(TextView textView) { for (NodeCreator nodeCreator : nodeCreators) { nodeCreator.preProcess(textView, bannerComponentNodes); } for (NodeCreator nodeCreator : nodeCreators) { nodeCreator.postProcess(textView, bannerComponentNodes); } } BannerComponentTree(@NonNull BannerText ban... | @Test public void loadInstruction() { BannerComponents bannerComponents = BannerComponentsFaker.bannerComponents(); List<BannerComponents> bannerComponentsList = Collections.singletonList(bannerComponents); TestNode testNode = mock(TestNode.class); TestCreator testCreator = mock(TestCreator.class); when(testCreator.isN... |
NavigationPresenter { void onRecenterClick() { view.setSummaryBehaviorHideable(false); view.setSummaryBehaviorState(BottomSheetBehavior.STATE_EXPANDED); view.setWayNameActive(true); if (!TextUtils.isEmpty(view.retrieveWayNameText())) { view.setWayNameVisibility(true); } view.resetCameraPosition(); view.hideRecenterBtn(... | @Test public void onRecenterBtnClick_recenterBtnIsHidden() { NavigationContract.View view = mock(NavigationContract.View.class); NavigationPresenter presenter = new NavigationPresenter(view); presenter.onRecenterClick(); verify(view).hideRecenterBtn(); }
@Test public void onRecenterBtnClick_cameraIsResetToTracking() { ... |
NavigationPresenter { void onWayNameChanged(@NonNull String wayName) { if (TextUtils.isEmpty(wayName) || view.isSummaryBottomSheetHidden()) { view.setWayNameActive(false); view.setWayNameVisibility(false); return; } view.updateWayNameView(wayName); view.setWayNameActive(true); view.setWayNameVisibility(true); } Navigat... | @Test public void onWayNameChanged_mapWayNameIsShown() { NavigationContract.View view = mock(NavigationContract.View.class); NavigationPresenter presenter = new NavigationPresenter(view); presenter.onWayNameChanged("Some way name"); verify(view).setWayNameActive(true); verify(view).setWayNameVisibility(true); }
@Test p... |
NavigationPresenter { void onNavigationStopped() { view.setWayNameActive(false); view.setWayNameVisibility(false); } NavigationPresenter(NavigationContract.View view); } | @Test public void onNavigationStopped_mapWayNameIsHidden() { NavigationContract.View view = mock(NavigationContract.View.class); NavigationPresenter presenter = new NavigationPresenter(view); presenter.onNavigationStopped(); verify(view).setWayNameActive(false); verify(view).setWayNameVisibility(false); } |
NavigationPresenter { void onRouteUpdate(DirectionsRoute directionsRoute) { view.drawRoute(directionsRoute); if (resumeState && view.isRecenterButtonVisible()) { view.updateCameraRouteOverview(); } else { view.startCamera(directionsRoute); } } NavigationPresenter(NavigationContract.View view); } | @Test public void onRouteUpdate_routeIsDrawn() { DirectionsRoute directionsRoute = mock(DirectionsRoute.class); NavigationContract.View view = mock(NavigationContract.View.class); NavigationPresenter presenter = new NavigationPresenter(view); presenter.onRouteUpdate(directionsRoute); verify(view).drawRoute(directionsRo... |
MapRouteClickListener implements MapboxMap.OnMapClickListener { @Override public boolean onMapClick(@NonNull LatLng point) { if (!isRouteVisible()) { return false; } Map<LineString, DirectionsRoute> routeLineStrings = routeLine.retrieveRouteLineStrings(); if (invalidMapClick(routeLineStrings)) { return false; } List<Di... | @Test public void checksOnRouteSelectionChangeListenerIsCalledWhenClickedRouteIsFound() { DirectionsRoute anyRoute = buildMockDirectionsRoute(); List<DirectionsRoute> anyDirectionsRoutes = buildDirectionsRoutes(anyRoute); LineString anyRouteGeometry = LineString.fromPolyline(anyRoute.geometry(), Constants.PRECISION_6);... |
AlertViewAnimatorListener implements Animator.AnimatorListener { @Override public void onAnimationEnd(Animator animation) { hideAlertView(); } AlertViewAnimatorListener(AlertView alertView); @Override void onAnimationStart(Animator animation); @Override void onAnimationEnd(Animator animation); @Override void onAnimatio... | @Test public void onAnimationEnd_alertViewIsHidden() { AlertView alertView = mock(AlertView.class); AlertViewAnimatorListener listener = new AlertViewAnimatorListener(alertView); listener.onAnimationEnd(mock(Animator.class)); verify(alertView).hide(); } |
DynamicCamera extends SimpleCamera { @Override public double zoom(@NonNull RouteInformation routeInformation) { if (isShutdown) { return DEFAULT_ZOOM; } if (validLocationAndProgress(routeInformation) && shouldUpdateZoom(routeInformation)) { return createZoom(routeInformation); } else if (routeInformation.getRoute() != ... | @Test public void onInformationFromRoute_engineCreatesCorrectZoom() throws Exception { DynamicCamera cameraEngine = buildDynamicCamera(); RouteInformation routeInformation = new RouteInformation(buildDirectionsRoute(), null, null); double zoom = cameraEngine.zoom(routeInformation); assertEquals(15d, zoom, 0.1); }
@Test... |
DynamicCamera extends SimpleCamera { @Override public double tilt(@NonNull RouteInformation routeInformation) { if (isShutdown) { return DEFAULT_TILT; } RouteProgress progress = routeInformation.getRouteProgress(); if (progress != null) { double distanceRemaining = progress.getCurrentLegProgress().getCurrentStepProgres... | @Test public void onInformationFromRoute_engineCreatesCorrectTilt() throws Exception { DynamicCamera cameraEngine = buildDynamicCamera(); RouteInformation routeInformation = new RouteInformation(buildDirectionsRoute(), null, null); double tilt = cameraEngine.tilt(routeInformation); assertEquals(50d, tilt, 0.1); }
@Test... |
NavigationCameraTrackingChangedListener implements OnCameraTrackingChangedListener { @Override public void onCameraTrackingDismissed() { camera.updateCameraTrackingMode(NavigationCamera.NAVIGATION_TRACKING_MODE_NONE); } NavigationCameraTrackingChangedListener(NavigationCamera camera); @Override void onCameraTrackingDis... | @Test public void onCameraTrackingDismissed_cameraSetToTrackingNone() { NavigationCamera camera = mock(NavigationCamera.class); NavigationCameraTrackingChangedListener listener = new NavigationCameraTrackingChangedListener(camera); listener.onCameraTrackingDismissed(); verify(camera).updateCameraTrackingMode(eq(Navigat... |
NavigationCameraTrackingChangedListener implements OnCameraTrackingChangedListener { @Override public void onCameraTrackingChanged(int currentMode) { Integer trackingMode = camera.findTrackingModeFor(currentMode); if (trackingMode != null) { camera.updateCameraTrackingMode(trackingMode); } } NavigationCameraTrackingCha... | @Test public void onCameraTrackingChanged_navigationCameraTrackingUpdated() { NavigationCamera camera = mock(NavigationCamera.class); when(camera.findTrackingModeFor(CameraMode.TRACKING_GPS)).thenReturn(NavigationCamera.NAVIGATION_TRACKING_MODE_GPS); NavigationCameraTrackingChangedListener listener = new NavigationCame... |
NavigationCameraTransitionListener implements OnLocationCameraTransitionListener { @Override public void onLocationCameraTransitionFinished(int cameraMode) { camera.updateTransitionListenersFinished(cameraMode); } NavigationCameraTransitionListener(NavigationCamera camera); @Override void onLocationCameraTransitionFini... | @Test public void onLocationCameraTransitionFinished() { NavigationCamera camera = mock(NavigationCamera.class); NavigationCameraTransitionListener listener = new NavigationCameraTransitionListener(camera); int trackingGps = CameraMode.TRACKING_GPS; listener.onLocationCameraTransitionFinished(trackingGps); verify(camer... |
NavigationCameraTransitionListener implements OnLocationCameraTransitionListener { @Override public void onLocationCameraTransitionCanceled(int cameraMode) { camera.updateTransitionListenersCancelled(cameraMode); camera.updateIsResetting(false); } NavigationCameraTransitionListener(NavigationCamera camera); @Override v... | @Test public void onLocationCameraTransitionCanceled() { NavigationCamera camera = mock(NavigationCamera.class); NavigationCameraTransitionListener listener = new NavigationCameraTransitionListener(camera); int trackingGpsNorth = CameraMode.TRACKING_GPS_NORTH; listener.onLocationCameraTransitionCanceled(trackingGpsNort... |
ResetCancelableCallback implements MapboxMap.CancelableCallback { @Override public void onFinish() { camera.updateIsResetting(false); } ResetCancelableCallback(NavigationCamera camera); @Override void onCancel(); @Override void onFinish(); } | @Test public void onFinish_dynamicCameraIsReset() { NavigationCamera camera = mock(NavigationCamera.class); ResetCancelableCallback callback = new ResetCancelableCallback(camera); callback.onFinish(); verify(camera).updateIsResetting(eq(false)); } |
ResetCancelableCallback implements MapboxMap.CancelableCallback { @Override public void onCancel() { camera.updateIsResetting(false); } ResetCancelableCallback(NavigationCamera camera); @Override void onCancel(); @Override void onFinish(); } | @Test public void onCancel_dynamicCameraIsReset() { NavigationCamera camera = mock(NavigationCamera.class); ResetCancelableCallback callback = new ResetCancelableCallback(camera); callback.onCancel(); verify(camera).updateIsResetting(eq(false)); } |
InstructionListPresenter { void update(@NonNull RouteProgress routeProgress, @NonNull InstructionListAdapter adapter) { drivingSide = getDrivingSide(routeProgress); final List<BannerInstructions> routeInstructions = getBannerInstructionsFromRouteProgress(routeProgress); final List<BannerInstructions> filteredRouteInstr... | @Test public void update_notifyItemRangeInserted() throws Exception { RouteProgress routeProgress = buildRouteProgress(); InstructionListAdapter adapter = mock(InstructionListAdapter.class); DistanceFormatter distanceFormatter = mock(DistanceFormatter.class); InstructionListPresenter presenter = new InstructionListPres... |
InstructionListPresenter { @Nullable BannerInstructions findCurrentBannerInstructions(@Nullable LegStep currentStep, double stepDistanceRemaining) { if (currentStep == null) { return null; } List<BannerInstructions> instructions = currentStep.bannerInstructions(); if (instructions != null && !instructions.isEmpty()) { ... | @Test public void findCurrentBannerInstructions_returnsNullWithNullCurrentStep() throws Exception { LegStep currentStep = null; double stepDistanceRemaining = 0; SpannableString spannableString = mock(SpannableString.class); InstructionListPresenter presenter = buildPresenter(spannableString); BannerInstructions curren... |
NavigationViewModelProgressObserver implements RouteProgressObserver, LocationObserver { @Override public void onRouteProgressChanged(@NotNull RouteProgress routeProgress) { viewModel.updateRouteProgress(routeProgress); } NavigationViewModelProgressObserver(NavigationViewModel viewModel); @Override void onRawLocationCh... | @Test public void checksNavigationViewModelRouteProgressIsUpdatedWhenOnProgressChange() { NavigationViewModel mockedNavigationViewModel = mock(NavigationViewModel.class); NavigationViewModelProgressObserver theNavigationViewModelProgressObserver = new NavigationViewModelProgressObserver(mockedNavigationViewModel); Rout... |
NavigationViewModelProgressObserver implements RouteProgressObserver, LocationObserver { @Override public void onEnhancedLocationChanged( @NotNull Location enhancedLocation, @NotNull List<? extends Location> keyPoints ) { viewModel.updateLocation(enhancedLocation); } NavigationViewModelProgressObserver(NavigationViewMo... | @Test @SuppressWarnings("unchecked assignment") public void checksNavigationViewModelLocationIsUpdatedWhenOnProgressChange() { NavigationViewModel mockedNavigationViewModel = mock(NavigationViewModel.class); NavigationViewModelProgressObserver theNavigationViewModelProgressChangeListener = new NavigationViewModelProgre... |
NavigationViewEventDispatcher { void initializeListeners( @NonNull NavigationViewOptions navigationViewOptions, @NonNull NavigationViewModel navigationViewModel ) { assignFeedbackListener(navigationViewOptions.feedbackListener()); assignNavigationListener(navigationViewOptions.navigationListener(), navigationViewModel)... | @Test public void onRouteProgressObserverAddedInOptions_isAddedToNavigation() { NavigationViewEventDispatcher eventDispatcher = new NavigationViewEventDispatcher(); NavigationViewOptions options = mock(NavigationViewOptions.class); RouteProgressObserver routeProgressObserver = setupRouteProgressObserver(options); Navig... |
NavigationViewEventDispatcher { VoiceInstructions onAnnouncement(VoiceInstructions announcement) { if (speechAnnouncementListener != null) { return speechAnnouncementListener.willVoice(announcement); } return announcement; } } | @Test public void onNewVoiceAnnouncement_instructionListenerIsCalled() { VoiceInstructions originalAnnouncement = mock(VoiceInstructions.class); SpeechAnnouncementListener speechAnnouncementListener = mock(SpeechAnnouncementListener.class); VoiceInstructions newAnnouncement = VoiceInstructions.builder() .announcement("... |
InstructionCacheCallback implements Callback<ResponseBody> { @Override public void onResponse(@NonNull Call<ResponseBody> call, @NonNull Response<ResponseBody> response) { if (closeResponseBody(response)) { String url = call.request().url().toString(); loader.addCachedUrl(url); } } InstructionCacheCallback(VoiceInstruc... | @Test public void onResponse_cachedUrlIsAdded() { VoiceInstructionLoader loader = mock(VoiceInstructionLoader.class); Response<ResponseBody> response = mock(Response.class); ResponseBody body = mock(ResponseBody.class); when(response.body()).thenReturn(body); String url = "http: Call call = buildMockCall(url); Instruct... |
NavigationSpeechPlayer implements SpeechPlayer { @Override public void play(VoiceInstructions voiceInstructions) { voiceInstructionsQueue.offer(voiceInstructions); SpeechPlayer player = speechPlayerProvider.retrieveSpeechPlayer(); if (player != null) { player.play(voiceInstructionsQueue.poll()); } } NavigationSpeechPla... | @Test public void onPlayAnnouncement_mapboxSpeechPlayerIsGivenAnnouncement() { MapboxSpeechPlayer speechPlayer = mock(MapboxSpeechPlayer.class); NavigationSpeechPlayer navigationSpeechPlayer = buildNavigationSpeechPlayer(speechPlayer); VoiceInstructions announcement = mock(VoiceInstructions.class); navigationSpeechPlay... |
NavigationSpeechPlayer implements SpeechPlayer { @Override public void setMuted(boolean isMuted) { this.isMuted = isMuted; voiceInstructionsQueue.clear(); speechPlayerProvider.setMuted(isMuted); } NavigationSpeechPlayer(SpeechPlayerProvider speechPlayerProvider); @Override void play(VoiceInstructions voiceInstructions)... | @Test public void onSetMuted_providerIsSetMuted() { SpeechPlayerProvider provider = mock(SpeechPlayerProvider.class); NavigationSpeechPlayer navigationSpeechPlayer = new NavigationSpeechPlayer(provider); navigationSpeechPlayer.setMuted(true); verify(provider).setMuted(true); } |
NavigationSpeechPlayer implements SpeechPlayer { @Override public void onOffRoute() { voiceInstructionsQueue.clear(); speechPlayerProvider.onOffRoute(); } NavigationSpeechPlayer(SpeechPlayerProvider speechPlayerProvider); @Override void play(VoiceInstructions voiceInstructions); @Override boolean isMuted(); @Override v... | @Test public void onOffRoute_providerOnOffRouteIsCalled() { SpeechPlayerProvider provider = mock(SpeechPlayerProvider.class); NavigationSpeechPlayer navigationSpeechPlayer = new NavigationSpeechPlayer(provider); navigationSpeechPlayer.onOffRoute(); verify(provider).onOffRoute(); }
@Test public void onDestroy_providerOn... |
NavigationVoiceListener implements VoiceListener { @Override public void onStart(@NonNull SpeechPlayerState state) { speechPlayerProvider.onSpeechPlayerStateChanged(state); audioFocusManager.requestAudioFocus(); } NavigationVoiceListener(SpeechPlayerProvider speechPlayerProvider,
SpeechAudioFocusManager audioFocu... | @Test public void onStart_audioFocusIsRequested() { SpeechAudioFocusManager audioFocusManager = mock(SpeechAudioFocusManager.class); NavigationVoiceListener navigationSpeechListener = buildSpeechListener(audioFocusManager); navigationSpeechListener.onStart(SpeechPlayerState.ONLINE_PLAYING); verify(audioFocusManager).re... |
NavigationVoiceListener implements VoiceListener { @Override public void onDone(@NonNull SpeechPlayerState state) { speechPlayerProvider.onSpeechPlayerStateChanged(state); if (state == SpeechPlayerState.IDLE) { audioFocusManager.abandonAudioFocus(); } } NavigationVoiceListener(SpeechPlayerProvider speechPlayerProvider,... | @Test public void onDone_audioFocusIsAbandoned() { SpeechAudioFocusManager audioFocusManager = mock(SpeechAudioFocusManager.class); NavigationVoiceListener navigationSpeechListener = buildSpeechListener(audioFocusManager); navigationSpeechListener.onDone(SpeechPlayerState.IDLE); verify(audioFocusManager).abandonAudioFo... |
NavigationVoiceListener implements VoiceListener { @Override public void onError(String errorText, VoiceInstructions voiceInstructions) { Timber.e(errorText); speechPlayerProvider.onSpeechPlayerStateChanged(SpeechPlayerState.IDLE); speechPlayerProvider.retrieveAndroidSpeechPlayer().play(voiceInstructions); } Navigation... | @Test public void onError_fallbackGoesToAndroidSpeechPlayer() { SpeechPlayerProvider provider = mock(SpeechPlayerProvider.class); AndroidSpeechPlayer androidSpeechPlayer = mock(AndroidSpeechPlayer.class); when(provider.retrieveAndroidSpeechPlayer()).thenReturn(androidSpeechPlayer); NavigationVoiceListener navigationSpe... |
SpeechPlayerProvider { @Nullable SpeechPlayer retrieveSpeechPlayer() { if (speechPlayerState == SpeechPlayerState.OFFLINE_PLAYING) { return null; } if (voiceInstructionLoader.hasCache() || connectivityStatus.isConnectedFast() || (connectivityStatus.isConnected() && !isFallbackAlwaysEnabled)) { speechPlayerState = Speec... | @Test public void voiceLanguageSupported_returnsMapboxSpeechPlayer() { boolean voiceLanguageSupported = true; SpeechPlayerProvider provider = buildSpeechPlayerProvider(voiceLanguageSupported); SpeechPlayer speechPlayer = provider.retrieveSpeechPlayer(); assertTrue(speechPlayer instanceof MapboxSpeechPlayer); }
@Test pu... |
SpeechPlayerProvider { AndroidSpeechPlayer retrieveAndroidSpeechPlayer() { return androidSpeechPlayer; } SpeechPlayerProvider(@NonNull Context context, String language,
boolean voiceLanguageSupported, @NonNull VoiceInstructionLoader voiceInstructionLoader); SpeechPlayerProvider(@NonNull ... | @Test public void retrieveAndroidSpeechPlayer_alwaysReturnsAndroidSpeechPlayer() { SpeechPlayerProvider provider = buildSpeechPlayerProvider(true); AndroidSpeechPlayer speechPlayer = provider.retrieveAndroidSpeechPlayer(); assertNotNull(speechPlayer); } |
VoiceInstructionLoader { void requestInstruction(@NonNull String instruction, String textType, Callback<ResponseBody> callback) { if (context != null && !cache.isClosed() && mapboxSpeechBuilder != null) { MapboxSpeech mapboxSpeech = mapboxSpeechBuilder .instruction(instruction) .textType(textType) .build(); mapboxSpeec... | @Test public void checksRequestEnqueuedIfCacheIsNotClosedAndMapboxSpeechBuilderIsNotNull() { Cache anyCache = mock(Cache.class); when(anyCache.isClosed()).thenReturn(false); MapboxSpeech.Builder aSpeechBuilder = mock(MapboxSpeech.Builder.class); when(aSpeechBuilder.instruction(anyString())).thenReturn(aSpeechBuilder); ... |
RouteCallStatus { boolean isRouting(@NonNull Date currentDate) { if (responseReceived) { return false; } return diffInMilliseconds(callDate, currentDate) < FIVE_SECONDS_IN_MILLISECONDS; } RouteCallStatus(Date callDate); } | @Test public void isRouting_returnsTrueUnderTwoSeconds() { Date callDate = mock(Date.class); when(callDate.getTime()).thenReturn(0L); Date currentDate = mock(Date.class); when((currentDate.getTime())).thenReturn(1000L); RouteCallStatus callStatus = new RouteCallStatus(callDate); boolean isRouting = callStatus.isRouting... |
NavigationViewWayNameListener implements OnWayNameChangedListener { @Override public void onWayNameChanged(@NonNull String wayName) { presenter.onWayNameChanged(wayName); } NavigationViewWayNameListener(NavigationPresenter presenter); @Override void onWayNameChanged(@NonNull String wayName); } | @Test public void onWayNameChanged_presenterReceivesNewWayName() { NavigationPresenter presenter = mock(NavigationPresenter.class); String newWayName = "New way name"; OnWayNameChangedListener listener = new NavigationViewWayNameListener(presenter); listener.onWayNameChanged(newWayName); verify(presenter).onWayNameChan... |
SymbolOnStyleLoadedListener implements MapView.OnDidFinishLoadingStyleListener { @Override public void onDidFinishLoadingStyle() { mapboxMap.getStyle().addImage(MAPBOX_NAVIGATION_MARKER_NAME, markerBitmap); } SymbolOnStyleLoadedListener(MapboxMap mapboxMap, Bitmap markerBitmap); @Override void onDidFinishLoadingStyle()... | @Test public void onDidFinishLoadingStyle_markerIsAdded() { MapboxMap mapboxMap = mock(MapboxMap.class); Style style = mock(Style.class); when(mapboxMap.getStyle()).thenReturn(style); Bitmap markerBitmap = mock(Bitmap.class); SymbolOnStyleLoadedListener listener = new SymbolOnStyleLoadedListener(mapboxMap, markerBitmap... |
MapFpsDelegate implements OnTrackingModeChangedListener, OnTrackingModeTransitionListener { void addProgressChangeListener(@NonNull MapboxNavigation navigation) { this.navigation = navigation; navigation.registerRouteProgressObserver(fpsProgressListener); } MapFpsDelegate(MapView mapView, MapBatteryMonitor batteryMonit... | @Test public void addProgressChangeListener_navigationReceivesListener() { MapboxNavigation navigation = mock(MapboxNavigation.class); MapFpsDelegate delegate = new MapFpsDelegate(mock(MapView.class), mock(MapBatteryMonitor.class)); delegate.addProgressChangeListener(navigation); verify(navigation).registerRouteProgres... |
Maybe { public abstract <B> Maybe<B> map(Function<A, B> func); private Maybe(); abstract Maybe<B> map(Function<A, B> func); abstract Maybe<B> bind(Function<A, Maybe<B>> func); abstract Maybe<A> filter(Predicate<A> predicate); abstract A getOrElse(A def); abstract boolean isDefined(); abstract Maybe<C> lift2(BiFunction... | @Test public void testMap() { Map<String, String> param = new HashMap<>(); param.put("a", "5"); param.put("b", "true"); param.put("c", "-3"); assertEquals(5, readPositiveIntParam(param, "a")); assertEquals(0, readPositiveIntParam(param, "b")); assertEquals(0, readPositiveIntParam(param, "c")); assertEquals(0, readPosit... |
CashMachine { public static Maybe<Integer> unitsLeft(List<Tuple<Integer, Integer>> currencySupply, Integer value, Integer unitsWanted) { return lookup(currencySupply, value) .bind(numUnits -> (unitsWanted < 0 || numUnits - unitsWanted < 0) ? Maybe.<Integer>nothing() : just(numUnits - unitsWanted)); } static Maybe<V> l... | @Test public void testUnitsLeftAfterTakeThreeTwenties() { Maybe<Integer> result = CashMachine.unitsLeft(currencySupply, 20, 3); assert (result.equals(just(2))); }
@Test public void testUnitsLeftAfterTakeOneHundred() { Maybe<Integer> result = CashMachine.unitsLeft(currencySupply, 100, 1); assert (result.equals(nothing()... |
CashMachine { public static <A> List<String> listNotes(List<A> amounts, List<String> currencies) { return amounts.bind(amount -> (List<String>) currencies.bind(currency -> List.itemList(currency + amount.toString()))); } static Maybe<V> lookup(List<Tuple<K, V>> tupleList, K key); static Maybe<Integer> unitsLeft(List<T... | @Test public void testListMachineNotes() { List<String> currencies = itemList("$AU", "$NZ"); List<String> result = CashMachine.listNotes(itemList(20, 50, 100), currencies); assert (result.equals(itemList("$AU20", "$NZ20", "$AU50", "$NZ50", "$AU100", "$NZ100"))); } |
CashMachine { public static Maybe<List<Integer>> checkAmountServiceable(List<Tuple<Integer, Integer>> currencySupply, List<Tuple<Integer, Integer>> combination) { return sequence(combination.foldRight((tuple, acc) -> List.cons(unitsLeft(currencySupply, tuple.first(), tuple.second()), acc), (List<Maybe<Integer>>) List.<... | @Test public void testSeventyComboServiceable() { List<Tuple<Integer, Integer>> combination = itemList(tuple(20, 1), tuple(50, 1)); Maybe<List<Integer>> result = CashMachine.checkAmountServiceable(currencySupply, combination); assert (result.equals(just(List.itemList(4, 9)))); }
@Test public void testOneHundredAndSeven... |
CashMachine { public static List<Tuple<Integer, Integer>> createValueUnitTuplesForValue(Integer amount, Integer currencyValue) { List<Tuple<Integer, Integer>> result = List.emptyList(); for (int i = amount/currencyValue; i >= 0; i--) { result = List.cons(Tuple.tuple(currencyValue, i), result); } return result; } stati... | @Test public void testCreateValueUnitTuples() { List<Tuple<Integer, Integer>> result = CashMachine.createValueUnitTuplesForValue(100, 50); assert (result.equals(List.itemList(tuple(50, 0), tuple(50, 1), tuple(50, 2)))); } |
CashMachine { public static List<List<Tuple<Integer, Integer>>> findCombinationSearchSpaceForAmount(Integer amount, List<Integer> machineCurrencies) { return List.sequence(machineCurrencies.foldRight((value, acc) -> List.cons(createValueUnitTuplesForValue(amount, value), acc), (List<List<Tuple<Integer, Integer>>>) List... | @Test public void testFindAllPossibleCombosForAmount() { List<List<Tuple<Integer, Integer>>> result = CashMachine.findCombinationSearchSpaceForAmount(50, itemList(20, 50)); assert (result.equals(itemList(itemList(tuple(20, 0), tuple(50, 0)), itemList(tuple(20, 0), tuple(50, 1)), itemList(tuple(20, 1), tuple(50, 0)), it... |
CashMachine { public static List<List<Tuple<Integer, Integer>>> findCombinationsForAmount(Integer amount, List<Integer> machineCurrencies) { return findCombinationSearchSpaceForAmount(amount, machineCurrencies).filter(list -> (list.foldRight((tuple, acc) -> acc + (tuple.first() * tuple.second()), 0)).equals(amount)); }... | @Test public void testFindCombosForAmount() { List<List<Tuple<Integer, Integer>>> result = CashMachine.findCombinationsForAmount(100, itemList(20, 50, 100)); assert (result.equals(itemList(itemList(tuple(20, 0), tuple(50, 0), tuple(100, 1)), itemList(tuple(20, 0), tuple(50, 2), tuple(100, 0)), itemList(tuple(20, 5), tu... |
CashMachine { public static List<List<Tuple<Integer, Integer>>> findServiceableCombinations(Integer amount, List<Tuple<Integer, Integer>> machineSupply) { List<Integer> machineCurrencies = machineSupply.foldRight((tuple, acc) -> List.cons(tuple.first(), acc), (List<Integer>) List.<Integer>emptyList()); return findCombi... | @Test public void testFindServiceableCombos() { List<List<Tuple<Integer, Integer>>> result = CashMachine.findServiceableCombinations(100, currencySupply); assert (result.equals(itemList(itemList(tuple(20, 0), tuple(50, 2), tuple(100, 0)), itemList(tuple(20, 5), tuple(50, 0), tuple(100, 0))))); } |
Maybe { public abstract <B, C> Maybe<C> lift2(BiFunction<A, B, C> func, Maybe<B> maybe); private Maybe(); abstract Maybe<B> map(Function<A, B> func); abstract Maybe<B> bind(Function<A, Maybe<B>> func); abstract Maybe<A> filter(Predicate<A> predicate); abstract A getOrElse(A def); abstract boolean isDefined(); abstract... | @Test public void testLift2() { BiFunction<Integer, Integer, Integer> function = (a, b) -> a + b; Maybe<Integer> maybe = just(1); Maybe<Integer> maybe2 = just(2); Maybe<Integer> result = maybe.lift2(function, maybe2); assert (result.equals(just(3))); } |
Maybe { public static <A> Maybe<List<A>> sequence(List<Maybe<A>> list) { return list.foldRight((o, a) -> o.lift2(List::cons, a), (Maybe<List<A>>) Maybe.<List<A>>just(List.<A>emptyList())); } private Maybe(); abstract Maybe<B> map(Function<A, B> func); abstract Maybe<B> bind(Function<A, Maybe<B>> func); abstract Maybe<... | @Test public void testSequence() { List<Maybe<Integer>> list = itemList(fromNullable(1), fromNullable(2), fromNullable(3)); Maybe<List<Integer>> result = Maybe.sequence(list); assert (result.equals(just(itemList(1, 2, 3)))); } |
List { public abstract List<A> append(List<A> list); private List(); abstract List<B> map(Function<A, B> func); abstract List<B> bind(Function<A, List<B>> func); abstract List<A> filter(Predicate<A> predicate); abstract boolean isEmpty(); abstract B foldRight(BiFunction<A, B, B> function, B accumulator); abstract List... | @Test public void testAppend() { List<Integer> list = itemList(1, 2, 3); List<Integer> list2 = itemList(4, 5); List<Integer> result = list.append(list2); assert(result.equals(itemList(1, 2, 3, 4, 5))); } |
List { public abstract <B> B foldRight(BiFunction<A, B, B> function, B accumulator); private List(); abstract List<B> map(Function<A, B> func); abstract List<B> bind(Function<A, List<B>> func); abstract List<A> filter(Predicate<A> predicate); abstract boolean isEmpty(); abstract B foldRight(BiFunction<A, B, B> functio... | @Test public void testFoldRight() { List<Integer> list = itemList(1, 2, 3); List<Integer> acc = List.emptyList(); List<Integer> result = list.foldRight((integer, accumulator) -> cons(integer + 1, accumulator), acc); assert(result.equals(itemList(2, 3, 4))); } |
List { public abstract List<A> filter(Predicate<A> predicate); private List(); abstract List<B> map(Function<A, B> func); abstract List<B> bind(Function<A, List<B>> func); abstract List<A> filter(Predicate<A> predicate); abstract boolean isEmpty(); abstract B foldRight(BiFunction<A, B, B> function, B accumulator); abs... | @Test public void testFilter() { List<Integer> list = itemList(1, 2, 3); List<Integer> result = list.filter(i -> i % 2 == 0); assert(result.equals(itemList(2))); } |
List { public abstract <B> List<B> map(Function<A, B> func); private List(); abstract List<B> map(Function<A, B> func); abstract List<B> bind(Function<A, List<B>> func); abstract List<A> filter(Predicate<A> predicate); abstract boolean isEmpty(); abstract B foldRight(BiFunction<A, B, B> function, B accumulator); abstr... | @Test public void testMap() { List<Integer> list = itemList(1, 2, 3); List<Integer> result = list.map(i -> i + 1); assert(result.equals(itemList(2, 3, 4))); } |
List { public abstract <B> List<B> bind(Function<A, List<B>> func); private List(); abstract List<B> map(Function<A, B> func); abstract List<B> bind(Function<A, List<B>> func); abstract List<A> filter(Predicate<A> predicate); abstract boolean isEmpty(); abstract B foldRight(BiFunction<A, B, B> function, B accumulator)... | @Test public void testBind() { List<Integer> list = itemList(1, 2, 3); List<Integer> result = list.bind(integer -> itemList(integer * 2)); assert(result.equals(itemList(2, 4, 6))); } |
List { public abstract <B, C> List<C> lift2(BiFunction<A, B, C> function, List<B> list); private List(); abstract List<B> map(Function<A, B> func); abstract List<B> bind(Function<A, List<B>> func); abstract List<A> filter(Predicate<A> predicate); abstract boolean isEmpty(); abstract B foldRight(BiFunction<A, B, B> fun... | @Test public void testLift2() { BiFunction<Integer, Integer, Integer> function = (a, b) -> a + b; List<Integer> list = itemList(1, 2, 3); List<Integer> list2 = itemList(4, 5, 6); List<Integer> result = list.lift2(function, list2); assert(result.equals(itemList(5, 6, 7, 6, 7, 8, 7, 8, 9))); } |
List { public static <A> List<List<A>> sequence(List<List<A>> list) { return list.foldRight((l, a) -> l.lift2(List::cons, a), itemList((List<A>) List.<A>emptyList())); } private List(); abstract List<B> map(Function<A, B> func); abstract List<B> bind(Function<A, List<B>> func); abstract List<A> filter(Predicate<A> pre... | @Test public void testSequence() { List<List<Integer>> list = itemList(itemList(1, 2), itemList(3, 4)); List<List<Integer>> result = List.sequence(list); assert(result.equals(itemList(itemList(1, 3), itemList(1, 4), itemList(2, 3), itemList(2, 4)))); } |
JbpmRestClient { public void newProcessInstance(String processId) throws URISyntaxException, IOException { URI startProcessUrl = new URL(jbpmUrl + "/rs/process/definition/" + processId + "/new_instance").toURI(); HttpPost newInstance = new HttpPost(startProcessUrl); httpclient.execute(newInstance); } JbpmRestClient(Htt... | @Test @Ignore public void testNewProcessInstance() throws Exception { HttpClient httpclient = new DefaultHttpClient(); JbpmRestClient jbpmClient = new JbpmRestClient(httpclient, "http: try { jbpmClient.logon("admin", "admin"); Map<String,Object> parameters = new HashMap<String,Object>(); parameters.put("DevDeploymentUr... |
WorkflowFactory { public static BpmManager newInstance() { BpmManager bpmManager = ServiceRegistryUtil.getSingleService(BpmManager.class); if (bpmManager == null) throw new RuntimeException(Messages.i18n.format("WorkflowFactory.MissingBPMProvider")); return bpmManager; } static BpmManager newInstance(); } | @Test public void testPersistenceFactory() throws Exception { BpmManager bpmManager = WorkflowFactory.newInstance(); Assert.assertEquals(EmbeddedJbpmManager.class, bpmManager.getClass()); }
@Test @Ignore public void testNewProcessInstance() throws Exception { BpmManager bpmManager = WorkflowFactory.newInstance(); Strin... |
QueryExecutor { public static synchronized void execute() throws SrampClientException, MalformedURLException, ConfigException { BpmManager bpmManager = WorkflowFactory.newInstance(); SrampAtomApiClient client = SrampAtomApiClientFactory.createAtomApiClient(); QueryAccessor accesor = new QueryAccessor(); WorkflowAccesor... | @Test @Ignore public void testMonitor() throws ConfigException, SrampClientException, SrampAtomException, URISyntaxException, IOException { QueryExecutor.execute(); } |
UiConfigurationServlet extends HttpServlet { protected static String generateJSONConfig(HttpServletRequest request, DtgovUIConfig config, IDtgovClient client) throws Exception { StringWriter json = new StringWriter(); JsonFactory f = new JsonFactory(); JsonGenerator g = f.createJsonGenerator(json); g.useDefaultPrettyPr... | @Test public void testGenerateJSONConfig_Configured() throws Exception { final PropertiesConfiguration config = new PropertiesConfiguration(); config.addProperty(DtgovUIConfig.DEPLOYMENT_TYPE_PREFIX + ".switchyard", "SwitchYard Application:ext/SwitchYardApplication"); config.addProperty(DtgovUIConfig.DEPLOYMENT_TYPE_PR... |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public void destroy() throws ImplementationException { killWorkflowSubprocess(); removeFromShutdownHooks(); deleteWorkingDirectory(); deleteSecurityManagerDirectory(); core.deleteLocalResources(); } protected LocalWorker(String executeWorkf... | @Test public void testDestroy1() throws Exception { lw.destroy(); assertEquals(l(), events); } |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { File validateFilename(String filename) throws RemoteException { if (filename == null) throw new IllegalArgumentException("filename must be non-null"); try { return getValidatedFile(base, filename.split("/")); } catch (IOException e) { throw new Illega... | @Test public void testValidateFilename() throws Exception { lw.validateFilename("foobar"); lw.validateFilename("foo/bar"); lw.validateFilename("foo.bar"); lw.validateFilename("foo..bar"); }
@Test(expected = IllegalArgumentException.class) public void testValidateFilenameBad0() throws Exception { lw.validateFilename("./... |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public RemoteInput makeInput(String name) throws RemoteException { return new InputDelegate(name); } protected LocalWorker(String executeWorkflowCommand, String workflow,
UsageRecordReceiver urReceiver, UUID id,
Map<String, String> se... | @Test public void testMakeInput() throws Exception { assertEquals(0, lw.getInputs().size()); RemoteInput ri = lw.makeInput("TEST"); assertNotNull(ri); assertEquals(1, lw.getInputs().size()); assertNotSame(ri, lw.getInputs().get(0)); assertEquals("TEST", ri.getName()); assertNull(ri.getFile()); assertNull(ri.getValue())... |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public RemoteListener makeListener(String type, String configuration) throws RemoteException { throw new RemoteException("listener manufacturing unsupported"); } protected LocalWorker(String executeWorkflowCommand, String workflow,
Usage... | @Test public void testMakeListener() { Throwable t = null; try { lw.makeListener("?", "?"); } catch (Throwable caught) { t = caught; } assertNotNull(t); assertSame(RemoteException.class, t.getClass()); assertNotNull(t.getMessage()); assertEquals("listener manufacturing unsupported", t.getMessage()); } |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public void addListener(RemoteListener listener) throws RemoteException, ImplementationException { throw new ImplementationException("not implemented"); } protected LocalWorker(String executeWorkflowCommand, String workflow,
UsageRecordR... | @Test public void testAddListener() { Throwable t = null; try { lw.addListener(null); } catch (Throwable caught) { t = caught; } assertNotNull(t); assertSame(ImplementationException.class, t.getClass()); assertNotNull(t.getMessage()); assertEquals("not implemented", t.getMessage()); } |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public void setOutputBaclavaFile(String filename) throws RemoteException { if (status != Initialized) throw new IllegalStateException("not initializing"); if (filename != null) outputBaclavaFile = validateFilename(filename); else outputBacla... | @Test(expected = IllegalArgumentException.class) public void testSetOutputBaclavaFile2() throws Exception { lw.setOutputBaclavaFile("/foobar"); }
@Test(expected = IllegalArgumentException.class) public void testSetOutputBaclavaFile3() throws Exception { lw.setOutputBaclavaFile("foo/../bar"); } |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public void setStatus(RemoteStatus newStatus) throws IllegalStateTransitionException, RemoteException, ImplementationException, StillWorkingOnItException { if (status == newStatus) return; switch (newStatus) { case Initialized: throw new Ill... | @Test public void testSetStatus0() throws Exception { lw.setStatus(RemoteStatus.Initialized); lw.setStatus(RemoteStatus.Initialized); lw.setStatus(RemoteStatus.Operating); lw.setStatus(RemoteStatus.Operating); lw.setStatus(RemoteStatus.Stopped); lw.setStatus(RemoteStatus.Stopped); lw.setStatus(RemoteStatus.Operating); ... |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public String getInputBaclavaFile() { return inputBaclava; } protected LocalWorker(String executeWorkflowCommand, String workflow,
UsageRecordReceiver urReceiver, UUID id,
Map<String, String> seedEnvironment, List<String> javaParams,
... | @Test public void testGetInputBaclavaFile() throws Exception { assertNull(lw.getInputBaclavaFile()); lw.setInputBaclavaFile("IBaclava"); assertNotNull(lw.getInputBaclavaFile()); assertEquals("IBaclava", lw.getInputBaclavaFile()); lw.makeInput("FOO").setValue("BAR"); assertNull(lw.getInputBaclavaFile()); } |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public List<String> getListenerTypes() { return emptyList(); } protected LocalWorker(String executeWorkflowCommand, String workflow,
UsageRecordReceiver urReceiver, UUID id,
Map<String, String> seedEnvironment, List<String> javaParams... | @Test public void testGetListenerTypes() { assertEquals("[]", lw.getListenerTypes().toString()); } |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public List<RemoteListener> getListeners() { return singletonList(core.getDefaultListener()); } protected LocalWorker(String executeWorkflowCommand, String workflow,
UsageRecordReceiver urReceiver, UUID id,
Map<String, String> seedEnv... | @Test public void testGetListeners() throws Exception { assertEquals(1, lw.getListeners().size()); RemoteListener rl = lw.getListeners().get(0); assertEquals("RLNAME", rl.getName()); assertEquals("RLCONFIG", rl.getConfiguration()); assertEquals("RLTYPE", rl.getType()); assertEquals("[RLP1, RLP2]", Arrays.asList(rl.list... |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public String getOutputBaclavaFile() { return outputBaclava; } protected LocalWorker(String executeWorkflowCommand, String workflow,
UsageRecordReceiver urReceiver, UUID id,
Map<String, String> seedEnvironment, List<String> javaParams... | @Test public void testGetOutputBaclavaFile() throws Exception { assertNull(lw.getOutputBaclavaFile()); lw.setOutputBaclavaFile("notnull"); assertEquals("notnull", lw.getOutputBaclavaFile()); lw.setOutputBaclavaFile(null); assertNull(lw.getOutputBaclavaFile()); } |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public RemoteSecurityContext getSecurityContext() throws RemoteException, ImplementationException { try { return new SecurityDelegate(masterToken); } catch (RemoteException e) { if (e.getCause() != null) throw new ImplementationException( "p... | @Test public void testGetSecurityContext() throws Exception { boolean md = DO_MKDIR; LocalWorker.DO_MKDIR = false; try { assertNotNull(lw.getSecurityContext()); } finally { LocalWorker.DO_MKDIR = md; } } |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public RemoteStatus getStatus() { if (status == Operating) { status = core.getWorkerStatus(); if (status == Finished && finish == null) finish = new Date(); } return status; } protected LocalWorker(String executeWorkflowCommand, String work... | @Test public void testGetStatusInitial() { assertEquals(RemoteStatus.Initialized, lw.getStatus()); }
@Test public void testGetStatus() throws Exception { assertEquals(RemoteStatus.Initialized, lw.getStatus()); returnThisStatus = RemoteStatus.Operating; assertEquals(RemoteStatus.Initialized, lw.getStatus()); lw.setStatu... |
LocalWorker extends UnicastRemoteObject implements RemoteSingleRun { @Override public RemoteDirectory getWorkingDirectory() { return baseDir; } protected LocalWorker(String executeWorkflowCommand, String workflow,
UsageRecordReceiver urReceiver, UUID id,
Map<String, String> seedEnvironment, List<String> javaPara... | @Test public void testGetWorkingDirectory() throws Exception { RemoteDirectory rd = lw.getWorkingDirectory(); assertNotNull(rd); assertNotNull(rd.getContents()); assertNull(rd.getContainingDirectory()); assertNotNull(rd.getName()); assertEquals(-1, rd.getName().indexOf('/')); assertFalse("..".equals(rd.getName())); ass... |
Generate { public static void main(final String[] args) { final File baseDirectory = new File(args.length == 0 ? "." : args[0]); if (!baseDirectory.isDirectory()) { LOGGER.log(Level.SEVERE, baseDirectory.getAbsolutePath() + " is not a directory."); } else { new Generate().handleDirectory(baseDirectory); } } static voi... | @Test public void test() throws IOException { createFile("base/withinfo/ClassA.java", "package base.withinfo;\n\npublic ClassA {\n}\n"); createFile("base/withinfo/package-info.java", "base withinfo.second;\n"); createFile("base/noinfo/ClassA.java", "package base.noinfo;\n\npublic ClassA {\n}\n"); Generate.main(new Stri... |
EfferentCouplingRule extends AbstractPackageAnalyzerRule implements PackageAnalyzerRule { @Override public void scanModel(final SensorContext context, final ActiveRule rule, final Model<Location> model) { final Integer maximum = Integer.valueOf(rule.param(PARAM_MAXIMUM)); for (final Package<Location> packageToCheck : m... | @Test public void test() { final Model<Location> model = createModel(); subject.scanModel(sensorContext, activeRule, model); Assert.assertEquals(1, sensorContext.allIssues().size()); final Issue issue = sensorContext.allIssues().iterator().next(); final String message = issue.primaryLocation().message(); System.out.pri... |
MissingPackageInfoRule extends AbstractPackageAnalyzerRule implements PackageAnalyzerRule { @Override public void scanModel(final SensorContext context, final ActiveRule rule, final Model<Location> model) { for (final Package<Location> packageToCheck : model.getPackages()) { LOGGER.debug("Package {}: extenal={}", packa... | @Test public void test() { final Model<Location> model = new Model<>(); model.addPackage("packageA", location("packageA/package-info.java")); model.addClass(Name.of("packageA.ClassA"), true, location("packageA/ClassA.java")); model.addClass(Name.of("packageA.ClassB"), true, location("packageA/ClassB.java")); model.addP... |
AbstractPackageAnalyzerRule implements PackageAnalyzerRule { @Override public final void scanModel(final SensorContext context, final String language, final Model<Location> model) { final ActiveRule rule = context.activeRules().find(RuleKey.of(BaseRules.getRepositoryKey(language), ruleKey)); if (rule == null) { LOGGER.... | @Test public void active() { final ActiveRules activeRules = Mockito.mock(ActiveRules.class); sensorContext.setActiveRules(activeRules); Mockito.when(activeRules.find(RuleKey.of("package-analyzer-test-no", "test"))).thenReturn(null); Mockito.when(activeRules.find(RuleKey.of("package-analyzer-test-yes", "test"))).thenRe... |
AbstractnessRule extends AbstractPackageAnalyzerRule implements PackageAnalyzerRule { @Override public void scanModel(final SensorContext context, final ActiveRule rule, final Model<Location> model) { final Integer maximum = Integer.valueOf(rule.param(PARAM_MAXIMUM)); for (final Package<Location> packageToCheck : model... | @Test public void test() { final Model<Location> model = createModel(); subject.scanModel(sensorContext, activeRule, model); Assert.assertEquals(3, sensorContext.allIssues().size()); Map<String, Issue> issues = sensorContext.allIssues().stream().collect( Collectors.toMap(issue -> issue.primaryLocation().inputComponent(... |
NumberOfClassesAndInterfacesRule extends AbstractPackageAnalyzerRule implements PackageAnalyzerRule { @Override public void scanModel(final SensorContext context, final ActiveRule rule, final Model<Location> model) { final Integer maximum = Integer.valueOf(rule.param(PARAM_MAXIMUM)); for (final Package<Location> packag... | @Test public void test() { final Model<Location> model = createModel(); subject.scanModel(sensorContext, activeRule, model); Assert.assertEquals(1, sensorContext.allIssues().size()); final Issue issue = sensorContext.allIssues().iterator().next(); final String message = issue.primaryLocation().message(); System.out.pri... |
AfferentCouplingRule extends AbstractPackageAnalyzerRule implements PackageAnalyzerRule { @Override public void scanModel(final SensorContext context, final ActiveRule rule, final Model<Location> model) { final Integer maximum = Integer.valueOf(rule.param(PARAM_MAXIMUM)); for (final Package<Location> packageToCheck : m... | @Test public void test() { final Model<Location> model = createModel(); subject.scanModel(sensorContext, activeRule, model); Assert.assertEquals(1, sensorContext.allIssues().size()); final Issue issue = sensorContext.allIssues().iterator().next(); final String message = issue.primaryLocation().message(); System.out.pri... |
PackageDependencyCyclesRule extends AbstractPackageAnalyzerRule implements PackageAnalyzerRule { @Override public void scanModel(final SensorContext context, final ActiveRule rule, final Model<Location> model) { final Analyzer<Location> analyzer = new Analyzer<>(); final List<PackageCycle<Location>> packageCycles = ana... | @Test public void test() { final Model<Location> model = createModel(); subject.scanModel(sensorContext, activeRule, model); Assert.assertEquals(1, sensorContext.allIssues().size()); final Issue issue = sensorContext.allIssues().iterator().next(); String message = issue.primaryLocation().message(); System.out.println("... |
InstabilityRule extends AbstractPackageAnalyzerRule implements PackageAnalyzerRule { @Override public void scanModel(final SensorContext context, final ActiveRule rule, final Model<Location> model) { final Integer maximum = Integer.valueOf(rule.param(PARAM_MAXIMUM)); for (final Package<Location> packageToCheck : model.... | @Test public void test() { final Model<Location> model = createModel(); subject.scanModel(sensorContext, activeRule, model); Assert.assertEquals(1, sensorContext.allIssues().size()); final Issue issue = sensorContext.allIssues().iterator().next(); final String message = issue.primaryLocation().message(); System.out.pri... |
PackageAnalyzerPlugin implements Plugin { @Override public void define(final Context context) { LOGGER.debug("Defining plugin ..."); context.addExtensions(AbstractnessRule.class, AfferentCouplingRule.class, EfferentCouplingRule.class, InstabilityRule.class, MissingPackageInfoRule.class, NumberOfClassesAndInterfacesRule... | @Test public void test() { final PackageAnalyzerPlugin subject = new PackageAnalyzerPlugin(); final Plugin.Context context = new Plugin.Context(SonarRuntimeImpl.forSonarQube(Version.create(5, 6), SonarQubeSide.SERVER)); Assert.assertEquals(0, context.getExtensions().size()); subject.define(context); Assert.assertTrue(c... |
Johnson { public synchronized List<List<T>> getElementaryCircuits() { if (elementaryCircuits == null) { calculate(); } return elementaryCircuits; } Johnson(final Map<T, Set<T>> edges); synchronized List<List<T>> getElementaryCircuits(); } | @Test public void testStackOverflowExample() { final Map<String, Set<String>> input = new HashMap<>(); input.put("Node 0", new HashSet<>(Arrays.asList("Node 1", "Node 2"))); input.put("Node 1", new HashSet<>(Arrays.asList("Node 0", "Node 2"))); input.put("Node 2", new HashSet<>(Arrays.asList("Node 0", "Node 1"))); fina... |
AbstractSensor implements Sensor { @Override public final void describe(final SensorDescriptor descriptor) { descriptor.name("Package Analyzer Sensor (" + language + ")"); descriptor.onlyOnLanguage(language); descriptor.createIssuesForRuleRepository(BaseRules.getRepositoryKey(language)); } AbstractSensor(final String l... | @Test public void describe() { DefaultSensorDescriptor descriptor = new DefaultSensorDescriptor(); sensor.describe(descriptor); Assert.assertEquals("Package Analyzer Sensor (TEST)", descriptor.name()); Assert.assertEquals(Arrays.asList("TEST"), descriptor.languages()); } |
Analyzer { public List<PackageCycle<T>> findPackageCycles(final Model<T> model) { final Map<Package<T>, Set<Package<T>>> edges = createEdges(model.getPackages()); final List<List<Package<T>>> elementaryCircuits = new Johnson<>(edges).getElementaryCircuits(); return createPackageCycles(elementaryCircuits); } List<Packa... | @Test public void test() { Model<String> model = new Model<>(); model.addPackage("packageA", "packageA"); model.addPackage("packageB", "packageB"); model.addPackage("packageC", "packageC"); Class<String> classA = model.addClass(Name.of("packageA.ClassA"), false, "ClassA"); classA.addUsage(Name.of("packageB.ClassB")); c... |
Tarjan { public synchronized List<List<T>> getStronglyConnectedComponents() { if (stronglyConnectedComponents == null) { calculate(); } return stronglyConnectedComponents; } Tarjan(final Map<T, Set<T>> edges); synchronized List<List<T>> getStronglyConnectedComponents(); } | @Test public void testWikipediaExample() { final Map<String, Set<String>> input = new HashMap<>(); input.put("Node 1", new HashSet<>(Arrays.asList("Node 2"))); input.put("Node 2", new HashSet<>(Arrays.asList("Node 3"))); input.put("Node 3", new HashSet<>(Arrays.asList("Node 1"))); input.put("Node 4", new HashSet<>(Arra... |
AbstractSensor implements Sensor { @Override public final void execute(final SensorContext context) { LOGGER.info("Build package model ..."); final Model<Location> model = buildModel(context); LOGGER.info("Package model built, analyzing model for issues ..."); for (final PackageAnalyzerRule rule : rules) { if (rule.sup... | @Test public void execute() { Assert.assertFalse(sensor.called); Assert.assertFalse(rule1.called); Assert.assertFalse(rule2.called); sensor.execute(null); Assert.assertTrue(sensor.called); Assert.assertTrue(rule1.called); Assert.assertTrue(rule2.called); } |
PackageAnalyzerMetrics implements Metrics { @Override @SuppressWarnings("rawtypes") public List<Metric> getMetrics() { return asList(PACKAGE_DEPENDENCY_CYCLES, PACKAGE_DEPENDENCY_CYCLES_IDENTIFIER, PACKAGE_DEPENDENCY_CYCLES_IDENTIFIERS); } @Override @SuppressWarnings("rawtypes") List<Metric> getMetrics(); static final... | @Test public void test() { Assert.assertEquals(3, new PackageAnalyzerMetrics().getMetrics().size()); } |
PackageAnalyzerComputer implements MeasureComputer { @Override public MeasureComputerDefinition define(final MeasureComputerDefinitionContext definitionContext) { return definitionContext.newDefinitionBuilder() .setInputMetrics(PackageAnalyzerMetrics.PACKAGE_DEPENDENCY_CYCLES_IDENTIFIER.key(), PackageAnalyzerMetrics.PA... | @Test public void testDefinition() { final TestMeasureComputerDefinitionContext definitionContext = new TestMeasureComputerDefinitionContext(); final MeasureComputerDefinition definition = subject.define(definitionContext); Assert.assertNotNull(definition); Assert.assertEquals(3, definition.getInputMetrics().size()); A... |
PackageAnalyzerComputer implements MeasureComputer { @Override public void compute(final MeasureComputerContext context) { rollupIdentifiers(context); countIdentifiers(context); } @Override MeasureComputerDefinition define(final MeasureComputerDefinitionContext definitionContext); @Override void compute(final MeasureC... | @Test public void testEmpty() { subject.compute(context); Assert.assertEquals("", context.getMeasure(PackageAnalyzerMetrics.PACKAGE_DEPENDENCY_CYCLES_IDENTIFIERS.key()).getStringValue()); Assert.assertEquals(0, context.getMeasure(PackageAnalyzerMetrics.PACKAGE_DEPENDENCY_CYCLES.key()).getIntValue()); }
@Test public voi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.