src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
ListenerCollection { public synchronized void remove(Listener listener) { listeners.remove(listener); } synchronized void add(Listener listener); synchronized void remove(Listener listener); synchronized void safeForEach(HandlerMethod<Listener> method); }
@Test public void testRemove() throws Exception { ListenerCollection<Runnable> collection = new ListenerCollection<>(); IMocksControl control = EasyMock.createControl(); Runnable l1 = control.createMock("l1", Runnable.class); Runnable l2 = control.createMock("l2", Runnable.class); control.checkOrder(true); l2.run(); Ea...
XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { public synchronized void addLayer(TileLayer tl) throws IllegalArgumentExcepti...
@Test public void testAddLayer() throws Exception { int count = config.getLayerCount(); TileLayer tl = createTestLayer("testLayer"); config.addLayer(tl); assertEquals(count + 1, config.getLayerCount()); assertSame(tl, config.getLayer("testLayer").get()); try { config.addLayer(tl); fail("Expected IllegalArgumentExceptio...
XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { public boolean canSave(TileLayer tl) { if (tl.isTransientLayer()) { return fa...
@Test public void testNotAddLayer() throws Exception { TileLayer tl = mock(WMSLayer.class); when(tl.getName()).thenReturn("testLayer"); when(tl.isTransientLayer()).thenReturn(true); assertFalse(config.canSave(tl)); }
XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { public synchronized void modifyLayer(TileLayer tl) throws NoSuchElementExcept...
@Test public void testModifyLayer() throws Exception { WMSLayer layer1 = createTestLayer("testLayer"); config.addLayer(layer1); int count = config.getLayerCount(); WMSLayer layer2 = createTestLayer("testLayer"); config.modifyLayer(layer2); assertEquals(count, config.getLayerCount()); assertSame(layer2, config.getLayer(...
XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { public synchronized void removeLayer(final String layerName) throws NoSuchEle...
@Test public void testRemoveLayer() { try { config.removeLayer("nonExistent"); fail("Expected exception removing nonExistant layer"); } catch (Exception e) { } Set<String> tileLayerNames = config.getLayerNames(); for (String name : tileLayerNames) { int count = config.getLayerCount(); config.removeLayer(name); assertEq...
XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { private synchronized void save() throws IOException { if (!resourceProvider.h...
@Test public void testSave() throws Exception { for (String name : config.getLayerNames()) { int count = config.getLayerCount(); config.removeLayer(name); assertEquals(count - 1, config.getLayerCount()); } String layerName = "testLayer"; String[] wmsURL = {"http: String wmsStyles = "default,line"; String wmsLayers = "s...
XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { private void saveGridSet(GridSet gridSet) throws IOException { addOrReplaceGr...
@Test public void testSaveGridSet() throws Exception { String name = "testGrid"; SRS srs = SRS.getEPSG4326(); BoundingBox extent = new BoundingBox(-1, -1, 1, 1); boolean alignTopLeft = true; double[] resolutions = {3, 2, 1}; double[] scaleDenoms = null; Double metersPerUnit = 1.5; double pixelSize = 2 * GridSetFactory....
XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { @Autowired @Override public void setGridSetBroker(@Qualifier("gwcGridSetBroke...
@Test public void testOverrideGridSetDefaults() throws Exception { URL source = XMLConfiguration.class.getResource("geowebcache_4326_override.xml"); FileUtils.copyURLToFile(source, configFile); XMLConfiguration config2 = new XMLConfiguration(null, configDir.getAbsolutePath()); final DefaultGridsets defaultGridSets = ne...
XMLConfiguration implements TileLayerConfiguration, InitializingBean, DefaultingConfiguration, ServerConfiguration, BlobStoreConfiguration, GridSetConfiguration { @Override public List<BlobStoreInfo> getBlobStores() { return Collections.unm...
@Test public void testNoBlobStores() throws Exception { assertNotNull(config.getBlobStores()); assertTrue(config.getBlobStores().isEmpty()); }
CompositeBlobStore implements BlobStore, BlobStoreConfigurationListener { @Override public boolean get(TileObject obj) throws StorageException { return readFunctionUnsafe(() -> store(obj.getLayerName()).get(obj)); } CompositeBlobStore( TileLayerDispatcher layers, DefaultStorageFinder defaultStor...
@Test public void noStoresDefinedCreatesLegacyDefaultStore() throws Exception { store = create(); assertEquals(1, store.blobStores.size()); LiveStore liveStore = store.blobStores.get(CompositeBlobStore.DEFAULT_STORE_DEFAULT_ID); assertNotNull(liveStore); assertTrue(liveStore.config instanceof FileBlobStoreInfo); FileBl...
CompositeBlobStore implements BlobStore, BlobStoreConfigurationListener { public static StoreSuitabilityCheck getStoreSuitabilityCheck() { return storeSuitability.get(); } CompositeBlobStore( TileLayerDispatcher layers, DefaultStorageFinder defaultStorageFinder, ServerConfiguration s...
@Test public void testSuitabilityOnStartup() throws Exception { assertThat( CompositeBlobStore.getStoreSuitabilityCheck(), equalTo(CompositeBlobStore.StoreSuitabilityCheck.EXISTING)); final BlobStoreInfo info = mock(BlobStoreInfo.class); when(info.getName()).thenReturn("testStore"); when(info.isEnabled()).thenReturn(tr...
GeoWebCacheExtensions implements ApplicationContextAware, ApplicationListener { @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") public void setApplicationContext(ApplicationContext context) throws BeansException { GeoWebCacheExtensions.context = context; extensionsCache.clear(); } @SuppressFBWarnings("S...
@Test public void testSetApplicationContext() { ApplicationContext appContext1 = createMock(ApplicationContext.class); ApplicationContext appContext2 = createMock(ApplicationContext.class); GeoWebCacheExtensions gse = new GeoWebCacheExtensions(); gse.setApplicationContext(appContext1); GeoWebCacheExtensions.extensionsC...
GeoWebCacheExtensions implements ApplicationContextAware, ApplicationListener { @SuppressWarnings("unchecked") public static final <T> List<T> extensions( Class<T> extensionPoint, ApplicationContext context) { String[] names; if (GeoWebCacheExtensions.context == context) { names = extensionsCache.get(extensionPoint); }...
@Test public void testExtensions() { ApplicationContext appContext = createMock(ApplicationContext.class); GeoWebCacheExtensions gse = new GeoWebCacheExtensions(); gse.setApplicationContext(appContext); Map<String, GeoWebCacheExtensionsTest> beans = new HashMap<>(); beans.put("testKey", this); beans.put("fakeKey", null...
GeoWebCacheExtensions implements ApplicationContextAware, ApplicationListener { public static String getProperty(String propertyName) { return getProperty(propertyName, context); } @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD") void setApplicationContext(ApplicationContext context); @SuppressWarnings("...
@Test public void testSystemProperty() { testProperty.setValue("ABC"); assertEquals( "ABC", GeoWebCacheExtensions.getProperty("TEST_PROPERTY", (ApplicationContext) null)); assertEquals( "ABC", GeoWebCacheExtensions.getProperty("TEST_PROPERTY", (ServletContext) null)); } @Test public void testWebProperty() { testPropert...
GridSetBroker implements ConfigurationAggregator<GridSetConfiguration>, ApplicationContextAware, InitializingBean { public @Nullable GridSet get(String gridSetId) { return getGridSet(gridSetId).orElse(null); } GridSetBroker(); GridSetBroker(List<GridSetConfiguration> configurations); vo...
@Test public void testGetDefaultGridsetOld() throws IOException { GridSet existingGridSet = gridSetBroker.get(GWCConfigIntegrationTestData.GRIDSET_EPSG4326); assertThat( existingGridSet, hasProperty("name", equalTo(GWCConfigIntegrationTestData.GRIDSET_EPSG4326))); } @Test public void testGetGridsetOld() throws IOExcept...
GridSetBroker implements ConfigurationAggregator<GridSetConfiguration>, ApplicationContextAware, InitializingBean { protected Optional<GridSet> getGridSet(String name) { for (GridSetConfiguration c : getConfigurations()) { Optional<GridSet> gridSet = c.getGridSet(name); if (gridSet.isPre...
@Test public void testGetDefaultGridSet() throws IOException { Optional<GridSet> existingGridSet = gridSetBroker.getGridSet(GWCConfigIntegrationTestData.GRIDSET_EPSG4326); assertThat( existingGridSet, isPresent( hasProperty( "name", equalTo(GWCConfigIntegrationTestData.GRIDSET_EPSG4326)))); } @Test public void testGetG...
GridSetBroker implements ConfigurationAggregator<GridSetConfiguration>, ApplicationContextAware, InitializingBean { public void addGridSet(GridSet gridSet) { log.debug("Adding " + gridSet.getName()); getConfigurations() .stream() .filter(c -> c.canSave(gridSet)) .findFirst() .orElseThrow...
@Test public void testAddGridset() throws GeoWebCacheException, IOException { String gridsetName = "EPSG:3005"; GridSet epsg3005 = GridSetFactory.createGridSet( gridsetName, SRS.getSRS(gridsetName), new BoundingBox(35043.6538, 440006.8768, 1885895.3117, 1735643.8497), false, null, new double[] {25000000, 1250000, 50000...
GridSetBroker implements ConfigurationAggregator<GridSetConfiguration>, ApplicationContextAware, InitializingBean { public synchronized void removeGridSet(final String gridSetName) { getConfigurations() .stream() .filter(c -> c.getGridSet(gridSetName).isPresent()) .forEach( c -> { c.remo...
@Test public void testRemoveGridset() throws IOException { String gridsetToRemove = GWCConfigIntegrationTestData.GRIDSET_EPSG2163; gridSetBroker.removeGridSet(gridsetToRemove); assertThat(gridSetBroker.getGridSetNames(), not(hasItem(gridsetToRemove))); assertThat(gridSetBroker.getGridSet(gridsetToRemove), notPresent())...
GridSubset { public long[][] getCoverageIntersections(BoundingBox reqBounds) { final int zoomStart = getZoomStart(); final int zoomStop = getZoomStop(); long[][] ret = new long[1 + zoomStop - zoomStart][5]; for (int level = zoomStart; level <= zoomStop; level++) { ret[level - zoomStart] = getCoverageIntersection(level,...
@Test public void testCreateTileRange() throws IOException, GeoWebCacheException { WMSLayer tl = createWMSLayer(); String gridSet = tl.getGridSubsets().iterator().next(); GridSubset gridSubSet = tl.getGridSubset(gridSet); BoundingBox bounds = new BoundingBox(0d, 0d, 1d, 1d); long[][] result = gridSubSet.getCoverageInte...
GridSet implements Info { public BoundingBox boundsFromIndex(long[] tileIndex) { final int tileZ = (int) tileIndex[2]; Grid grid = getGrid(tileZ); final long tileX = tileIndex[0]; final long tileY; if (yBaseToggle) { tileY = tileIndex[1] - grid.getNumTilesHigh(); } else { tileY = tileIndex[1]; } double width = grid.get...
@Test public void testBoundsFromIndex() throws Exception { long[] index = {0, 0, 1}; BoundingBox bboxTL = gridSetTL.boundsFromIndex(index); BoundingBox bboxBL = gridSetBL.boundsFromIndex(index); BoundingBox bboxTLswap = gridSetTLswap.boundsFromIndex(index); BoundingBox bboxBLswap = gridSetBLswap.boundsFromIndex(index);...
GridSet implements Info { public BoundingBox getBounds() { int i; long tilesWide, tilesHigh; for (i = (getNumLevels() - 1); i > 0; i--) { tilesWide = getGrid(i).getNumTilesWide(); tilesHigh = getGrid(i).getNumTilesHigh(); if (tilesWide == 1 && tilesHigh == 0) { break; } } tilesWide = getGrid(i).getNumTilesWide(); tiles...
@Test public void testBounds() throws Exception { BoundingBox bboxTL = gridSetTL.getBounds(); BoundingBox bboxBL = gridSetBL.getBounds(); BoundingBox bboxTLswap = gridSetTLswap.getBounds(); BoundingBox bboxBLswap = gridSetBLswap.getBounds(); BoundingBox solution = new BoundingBox(-180.0, -90.0, 180, 90); assertThat(bbo...
GridSet implements Info { protected BoundingBox boundsFromRectangle(long[] rectangleExtent) { Grid grid = getGrid((int) rectangleExtent[4]); double width = grid.getResolution() * getTileWidth(); double height = grid.getResolution() * getTileHeight(); long bottomY = rectangleExtent[1]; long topY = rectangleExtent[3]; if...
@Test public void testBoundsFromRectangle() throws Exception { long[] rect = {0, 0, 0, 0, 0}; BoundingBox bboxTL = gridSetTL.boundsFromRectangle(rect); BoundingBox bboxBL = gridSetBL.boundsFromRectangle(rect); BoundingBox bboxTLswap = gridSetTLswap.boundsFromRectangle(rect); BoundingBox bboxBLswap = gridSetBLswap.bound...
GridSet implements Info { protected long[] closestIndex(BoundingBox tileBounds) throws GridMismatchException { double wRes = tileBounds.getWidth() / getTileWidth(); double bestError = Double.MAX_VALUE; int bestLevel = -1; double bestResolution = -1.0; for (int i = 0; i < getNumLevels(); i++) { Grid grid = getGrid(i); d...
@Test public void testClosestIndex() throws Exception { BoundingBox box = new BoundingBox(-180.0, -90.0, -90.0, 0); long[] idxTL = gridSetTL.closestIndex(box); long[] idxBL = gridSetBL.closestIndex(box); long[] solution = {0, 0, 1}; assertTrue(Arrays.equals(idxTL, solution)); assertTrue(Arrays.equals(idxBL, solution));...
GridSet implements Info { public long[] closestRectangle(BoundingBox rectangleBounds) { double rectWidth = rectangleBounds.getWidth(); double rectHeight = rectangleBounds.getHeight(); double bestError = Double.MAX_VALUE; int bestLevel = -1; for (int i = 0; i < getNumLevels(); i++) { Grid grid = getGrid(i); double count...
@Test public void testClosestRectangle() throws Exception { BoundingBox box = new BoundingBox(-180.0, -90.0, 0.0, 0.0); long[] rectTL = gridSetTL.closestRectangle(box); long[] rectBL = gridSetBL.closestRectangle(box); long[] solution = {0, 0, 1, 0, 1}; assertTrue(Arrays.equals(rectTL, solution)); assertTrue(Arrays.equa...
GridSet implements Info { public double[] getOrderedTopLeftCorner(int gridIndex) { double[] leftTop = new double[2]; if (yBaseToggle) { leftTop[0] = tileOrigin()[0]; leftTop[1] = tileOrigin()[1]; } else { Grid grid = getGrid(gridIndex); double dTileHeight = getTileHeight(); double dGridExtent = grid.getNumTilesHigh(); ...
@Test public void testGetLeftTopCorner() throws Exception { double[] tlTL = gridSetTL.getOrderedTopLeftCorner(1); double[] tlBL = gridSetBL.getOrderedTopLeftCorner(1); assertThat(tlBL[1], Matchers.closeTo(90.0, 0.01)); assertThat(tlTL[1], Matchers.closeTo(90.0, 0.01)); }
TileLayerDispatcher implements DisposableBean, InitializingBean, ApplicationContextAware, ConfigurationAggregator<TileLayerConfiguration> { public synchronized void addLayer(final TileLayer tl) throws IllegalArgumentException { for (TileLayerConfiguration c : configs) { i...
@Test public void testAddLayer() throws GeoWebCacheException { String layerName = "newLayer"; WMSLayer layer = new WMSLayer( layerName, new String[] {"http: null, null, null, null, null, null, null, false, null); tileLayerDispatcher.addLayer(layer); assertTrue(tileLayerDispatcher.getLayerNames().contains(layerName)); a...
TileLayerDispatcher implements DisposableBean, InitializingBean, ApplicationContextAware, ConfigurationAggregator<TileLayerConfiguration> { public synchronized void removeLayer(final String layerName) throws IllegalArgumentException { for (TileLayerConfiguration config : ...
@Test public void testRemoveLayer() { String layerToRemove = GWCConfigIntegrationTestData.LAYER_TOPP_STATES; tileLayerDispatcher.removeLayer(layerToRemove); assertFalse(tileLayerDispatcher.getLayerNames().contains(layerToRemove)); try { tileLayerDispatcher.getTileLayer(layerToRemove); fail("Expected exception when tryi...
TileLayerDispatcher implements DisposableBean, InitializingBean, ApplicationContextAware, ConfigurationAggregator<TileLayerConfiguration> { public synchronized void modify(final TileLayer tl) throws IllegalArgumentException { TileLayerConfiguration config = getConfigurati...
@Test public void testModifyBadLayer() { String layerName = "newLayer"; WMSLayer layer = new WMSLayer( layerName, new String[] {"http: null, null, null, null, null, null, null, false, null); try { tileLayerDispatcher.modify(layer); fail("Expected exception when modifiying nonexistant layer"); } catch (IllegalArgumentEx...
TileLayerDispatcher implements DisposableBean, InitializingBean, ApplicationContextAware, ConfigurationAggregator<TileLayerConfiguration> { public synchronized void addGridSet(final GridSet gridSet) throws IllegalArgumentException, IOException { if (null != gridSetBroker....
@Test public void testAddGridset() throws GeoWebCacheException, IOException { String gridsetName = "EPSG:3005"; GridSet epsg3005 = GridSetFactory.createGridSet( gridsetName, SRS.getSRS(gridsetName), new BoundingBox(35043.6538, 440006.8768, 1885895.3117, 1735643.8497), false, null, new double[] {25000000, 1250000, 50000...
TileLayerDispatcher implements DisposableBean, InitializingBean, ApplicationContextAware, ConfigurationAggregator<TileLayerConfiguration> { public synchronized void removeGridSet(String gridsetToRemove) { if (StreamSupport.stream(getLayerList().spliterator(), true) .anyMa...
@Test public void testRemoveGridset() throws IOException { String gridsetToRemove = GWCConfigIntegrationTestData.GRIDSET_EPSG2163; tileLayerDispatcher.removeLayer(GWCConfigIntegrationTestData.LAYER_TOPP_STATES); tileLayerDispatcher.removeGridSet(gridsetToRemove); assertFalse(gridSetBroker.getNames().contains(gridsetToR...
RuntimeStats { public String getHTMLStats() { long runningTime = (clock.millis() - startTime) / 1000; StringBuilder str = new StringBuilder(); str.append("<table border=\"0\" cellspacing=\"5\" class=\"stats\">"); synchronized (bytes) { if (runningTime > 0) { str.append("<tbody>"); str.append("<tr><th colspan=\"2\" scop...
@Test public void test() { Clock clock = EasyMock.createMock("Clock", Clock.class); EasyMock.expect(clock.millis()).andStubAnswer(() -> time); EasyMock.replay(clock); time = 0; RuntimeStats stats = new RuntimeStats(1, Arrays.asList(60), Arrays.asList("Minutes"), clock); time += 500; stats.getHTMLStats(); EasyMock.verif...
HelloControllerWithRepository { @GetMapping("/hello/data/{name}") public Hello sayHi(@PathVariable String name) { Optional<Person> foundPerson = personRepository.findByFirstName(name); String result = foundPerson .map(person -> String.format("Hello %s", person.getFirstName())) .orElse("Data not found"); return new Hell...
@Test public void shouldReturnHelloSomkiat() { Person somkiat = new Person("somkiat", "pui"); given(personRepository.findByFirstName("somkiat")) .willReturn(Optional.of(somkiat)); Hello hello = controllerWithRepository.sayHi("somkiat"); assertEquals("Hello somkiat", hello.getMessage()); }
Hello { public String getMessage() { return message; } Hello(String message); String getMessage(); void setMessage(String message); }
@Test public void success_to_create_model_with_constructor() { Hello hello = new Hello("Somkiat"); assertEquals("Somkiat", hello.getMessage()); }
HelloWithRepositoryController { @GetMapping("/hello/data/{name}") public Hello sayHi(@PathVariable String name) { Optional<Person> person = personRepository.findByFirstName(name); String message = person.map(person1 -> String.format("Hello %s", person1.getFirstName())) .orElse("Data not found"); return new Hello(messag...
@Test public void shouldReturnHelloSomkiat() { Person somkiat = new Person("somkiat", "pui"); given(personRepository.findByFirstName("somkiat")) .willReturn(Optional.of(somkiat)); Hello hello = controller.sayHi("somkiat"); assertEquals("Hello somkiat", hello.getMessage()); }
Hello { public String getMessage() { return message; } Hello(String message); String getMessage(); }
@Test public void shouldReturnSomkiat() { Hello hello = new Hello("somkiat"); assertEquals("somkiat", hello.getMessage()); }
Recommendations extends SimpleBenchmark { public Map<Integer, List<Integer>> calculateRecommendations(int reps) { Map<Integer, List<Integer>> results = null; for (int i = 0; i < reps; i++) { results = lambdaRecommendations.calculateRecommendations(); } return results; } void setPurchases(Purchases purchases); Map<Inte...
@Test public void lambdaVariant() { LambdaRecommendations recommendations = new LambdaRecommendations(makePurchases()); Map<Integer, List<Integer>> results = recommendations.calculateRecommendations(); assertTrue("product 5 is similar to 4", recommendations.alsoBought(4, 1, results).contains(5)); assertTrue("product 4 ...
BaseController extends Controller { @NonNull @Override protected final View onCreateView(@NonNull LayoutInflater inflater, @NonNull ViewGroup container) { U view = createView(inflater, container); view.setController(getThis()); return view; } BaseController(); BaseController(@Nullable Bundle args); }
@Test public void setView() { DummyView dummyView = (DummyView) dummyController.onCreateView(null, null); Assert.assertEquals(dummyController, dummyView.getController()); }
LoginPresenter extends BasePresenter<V, I> implements LoginMvpPresenter<V, I> { @Override public void onServerLoginClick(String email, String password) { if (email == null || email.isEmpty()) { getMvpView().onError(R.string.empty_email); return; } if (!CommonUtils.isEmailValid(email)) { getMvpView().onError(R.string.in...
@Test public void testServerLoginSuccess() { String email = "dummy@gmail.com"; String password = "password"; LoginResponse loginResponse = new LoginResponse(); doReturn(Observable.just(loginResponse)) .when(mMockLoginMvpInteractor) .doServerLoginApiCall(new LoginRequest .ServerLoginRequest(email, password)); mLoginPres...
TasksRepository implements TasksDataSource { @Override public void getTask(@NonNull final String taskId, @NonNull final GetTaskCallback callback) { checkNotNull(taskId); checkNotNull(callback); Task cachedTask = getTaskWithId(taskId); if (cachedTask != null) { callback.onTaskLoaded(cachedTask); return; } mTasksLocalDat...
@Test public void getTask_requestsSingleTaskFromLocalDataSource() { mTasksRepository.getTask(TASK_TITLE, mGetTaskCallback); verify(mTasksLocalDataSource).getTask(eq(TASK_TITLE), any( TasksDataSource.GetTaskCallback.class)); } @Test public void getTaskWithBothDataSourcesUnavailable_firesOnDataUnavailable() { final Strin...
TasksPresenter implements TasksContract.Presenter { @Override public void addNewTask() { if (mTasksView != null) { mTasksView.showAddTask(); } } @Inject TasksPresenter(TasksRepository tasksRepository); @Override void result(int requestCode, int resultCode); @Override void loadTasks(boolean forceUpdate); @Override void...
@Test public void clickOnFab_ShowsAddTaskUi() { mTasksPresenter.addNewTask(); verify(mTasksView).showAddTask(); }
TasksPresenter implements TasksContract.Presenter { @Override public void openTaskDetails(@NonNull Task requestedTask) { checkNotNull(requestedTask, "requestedTask cannot be null!"); if (mTasksView != null) { mTasksView.showTaskDetailsUi(requestedTask.getId()); } } @Inject TasksPresenter(TasksRepository tasksRepositor...
@Test public void clickOnTask_ShowsDetailUi() { Task requestedTask = new Task("Details Requested", "For this task"); mTasksPresenter.openTaskDetails(requestedTask); verify(mTasksView).showTaskDetailsUi(any(String.class)); }
TasksPresenter implements TasksContract.Presenter { @Override public void completeTask(@NonNull Task completedTask) { checkNotNull(completedTask, "completedTask cannot be null!"); mTasksRepository.completeTask(completedTask); if (mTasksView != null) { mTasksView.showTaskMarkedComplete(); } loadTasks(false, false); } @I...
@Test public void completeTask_ShowsTaskMarkedComplete() { Task task = new Task("Details Requested", "For this task"); mTasksPresenter.completeTask(task); verify(mTasksRepository).completeTask(task); verify(mTasksView).showTaskMarkedComplete(); }
TaskDetailPresenter implements TaskDetailContract.Presenter { @Override public void takeView(TaskDetailContract.View taskDetailView) { mTaskDetailView = taskDetailView; openTask(); } @Inject TaskDetailPresenter(@Nullable String taskId, TasksRepository tasksRepository); @Override void editTask()...
@Test public void getActiveTaskFromRepositoryAndLoadIntoView() { mTaskDetailPresenter = new TaskDetailPresenter( ACTIVE_TASK.getId(), mTasksRepository); mTaskDetailPresenter.takeView(mTaskDetailView); verify(mTasksRepository).getTask(eq(ACTIVE_TASK.getId()), mGetTaskCallbackCaptor.capture()); InOrder inOrder = inOrder(...
TaskDetailPresenter implements TaskDetailContract.Presenter { @Override public void deleteTask() { if (Strings.isNullOrEmpty(mTaskId)) { if (mTaskDetailView != null) { mTaskDetailView.showMissingTask(); } return; } mTasksRepository.deleteTask(mTaskId); if (mTaskDetailView != null) { mTaskDetailView.showTaskDeleted(); }...
@Test public void deleteTask() { Task task = new Task(TITLE_TEST, DESCRIPTION_TEST); mTaskDetailPresenter = new TaskDetailPresenter( task.getId(), mTasksRepository); mTaskDetailPresenter.takeView(mTaskDetailView); mTaskDetailPresenter.deleteTask(); verify(mTasksRepository).deleteTask(task.getId()); verify(mTaskDetailVi...
TaskDetailPresenter implements TaskDetailContract.Presenter { @Override public void completeTask() { if (Strings.isNullOrEmpty(mTaskId)) { if (mTaskDetailView != null) { mTaskDetailView.showMissingTask(); } return; } mTasksRepository.completeTask(mTaskId); if (mTaskDetailView != null) { mTaskDetailView.showTaskMarkedCo...
@Test public void completeTask() { Task task = new Task(TITLE_TEST, DESCRIPTION_TEST); mTaskDetailPresenter = new TaskDetailPresenter( task.getId(), mTasksRepository); mTaskDetailPresenter.takeView(mTaskDetailView); mTaskDetailPresenter.completeTask(); verify(mTasksRepository).completeTask(task.getId()); verify(mTaskDe...
TaskDetailPresenter implements TaskDetailContract.Presenter { @Override public void activateTask() { if (Strings.isNullOrEmpty(mTaskId)) { if (mTaskDetailView != null) { mTaskDetailView.showMissingTask(); } return; } mTasksRepository.activateTask(mTaskId); if (mTaskDetailView != null) { mTaskDetailView.showTaskMarkedAc...
@Test public void activateTask() { Task task = new Task(TITLE_TEST, DESCRIPTION_TEST, true); mTaskDetailPresenter = new TaskDetailPresenter( task.getId(), mTasksRepository); mTaskDetailPresenter.takeView(mTaskDetailView); mTaskDetailPresenter.activateTask(); verify(mTasksRepository).activateTask(task.getId()); verify(m...
TasksRepository implements TasksDataSource { @Override public Flowable<List<Task>> getTasks() { if (mCachedTasks != null && !mCacheIsDirty) { return Flowable.fromIterable(mCachedTasks.values()).toList().toFlowable(); } else if (mCachedTasks == null) { mCachedTasks = new LinkedHashMap<>(); } Flowable<List<Task>> remoteT...
@Test public void getTasks_repositoryCachesAfterFirstSubscription_whenTasksAvailableInLocalStorage() { setTasksAvailable(mTasksLocalDataSource, TASKS); setTasksNotAvailable(mTasksRemoteDataSource); TestSubscriber<List<Task>> testSubscriber1 = new TestSubscriber<>(); mTasksRepository.getTasks().subscribe(testSubscriber1...
TasksRepository implements TasksDataSource { @Override public void saveTask(@NonNull Task task) { checkNotNull(task); mTasksRemoteDataSource.saveTask(task); mTasksLocalDataSource.saveTask(task); if (mCachedTasks == null) { mCachedTasks = new LinkedHashMap<>(); } mCachedTasks.put(task.getId(), task); } private TasksRep...
@Test public void saveTask_savesTaskToServiceAPI() { Task newTask = new Task(TASK_TITLE, "Some Task Description"); mTasksRepository.saveTask(newTask); verify(mTasksRemoteDataSource).saveTask(newTask); verify(mTasksLocalDataSource).saveTask(newTask); assertThat(mTasksRepository.mCachedTasks.size(), is(1)); }
TasksRepository implements TasksDataSource { @Override public Flowable<Optional<Task>> getTask(@NonNull final String taskId) { checkNotNull(taskId); final Task cachedTask = getTaskWithId(taskId); if (cachedTask != null) { return Flowable.just(Optional.of(cachedTask)); } if (mCachedTasks == null) { mCachedTasks = new Li...
@Test public void getTask_requestsSingleTaskFromLocalDataSource() { Task task = new Task(TASK_TITLE, "Some Task Description", true); Optional<Task> taskOptional = Optional.of(task); setTaskAvailable(mTasksLocalDataSource, taskOptional); setTaskNotAvailable(mTasksRemoteDataSource, taskOptional.get().getId()); TestSubscr...
AddEditTaskPresenter implements AddEditTaskContract.Presenter { @Override public void populateTask() { if (isNewTask()) { throw new RuntimeException("populateTask() was called but task is new."); } mCompositeDisposable.add(mTasksRepository .getTask(mTaskId) .subscribeOn(mSchedulerProvider.computation()) .observeOn(mSch...
@Test public void populateTask_callsRepoAndUpdatesViewOnAbsentTask() { Task testTask = new Task("TITLE", "DESCRIPTION"); when(mTasksRepository.getTask(testTask.getId())).thenReturn(Flowable.just(Optional.absent())); mAddEditTaskPresenter = new AddEditTaskPresenter(testTask.getId(), mTasksRepository, mAddEditTaskView, t...
ByteArrayDequeue { public void push(byte[] src) { push(src, 0, src.length); } ByteArrayDequeue(); ByteArrayDequeue(int initalCapacity); int getRemaining(); void push(byte[] src); void push(byte[] src, int srcOffset, int srcLengthToPush); void pushLast(byte[] src); void pushLast(byte[] src, int srcOffset, int srcLengt...
@Test public void testCombineArrays() { for (int i = 0; i < 200; i++) { push("ABCDEFGH"); push("IJK"); assertEquals("ABCDE", pop(5)); assertEquals("FGHIJK", pop(6)); } }
ClassUtils { public static String getMethodsList(Class<?> type) { final String SEPARATOR = ","; final List<Method> methods = Arrays.asList(type.getDeclaredMethods()); StringBuilder result = new StringBuilder(); Collections.sort(methods, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName())); for (Method method : m...
@Test public void testGetFieldsReturnsCorrectString_forAutoValueClass() { String detectedAVFields = ClassUtils.getMethodsList(ComicVolumeInfoList.class); String actualFields = "count_of_issues,id,image,name,publisher,start_year"; assertEquals("getMethodsList method returned incorrect list!", actualFields, detectedAVFie...
IssueTextUtils { public static String getFormattedIssueName(String issue, String volume, int number) { String name; if (issue != null) { name = String.format(Locale.US, "%s #%d - %s", volume, number, issue); } else { name = String.format(Locale.US, "%s #%d", volume, number); } return name; } static String getFormatted...
@Test public void testGetFormattedIssueName() { assertEquals("getFormattedIssueName method returned incorrect string!", FORMATTED_NAME_FULL, IssueTextUtils.getFormattedIssueName(ISSUE_NAME, VOLUME_NAME, ISSUE_NUMBER)); assertEquals("getFormattedIssueName method returned incorrect string!", FORMATTED_NAME_SHORT, IssueTe...
IssueTextUtils { public static String getFormattedIssueTitle(String volume, int number) { return String.format(Locale.US, "%s #%d", volume, number); } static String getFormattedIssueName(String issue, String volume, int number); static String getFormattedIssueTitle(String volume, int number); }
@Test public void testGetFormattedIssueDetailsTitle() { assertEquals("getFormattedIssueTitle method returned incorrect string!", FORMATTED_NAME_SHORT, IssueTextUtils.getFormattedIssueTitle(VOLUME_NAME, ISSUE_NUMBER)); }
AvroHeadersFunction implements Function<AvroWrapper, List<String>> { List<String> getColumns(List<Schema.Field> fields) { List<String> columns = new ArrayList<>(fields.size()); for (Schema.Field field : fields) { switch (field.schema().getType()) { case RECORD: case MAP: case ARRAY: break; default: columns.add(field.na...
@Test public void test() { List<Schema.Field> fields = Arrays.asList( new Schema.Field(Schema.Type.ARRAY.getName(), Schema.createArray(Schema.create(Schema.Type.BOOLEAN)), null, null), new Schema.Field(Schema.Type.RECORD.getName(), Schema.createRecord(Collections.emptyList()), null, null), new Schema.Field(Schema.Type....
SparkVerifier { static int getMaximumNumberOfGroups(BoundedDouble approxCountBoundedDouble, int maxGroupSize) { long countApprox = Math.round(approxCountBoundedDouble.mean()); LOGGER.info("Approximate count of expected results: " + countApprox); LOGGER.info("Maximum group size: " + maxGroupSize); long maximumNumberOfGr...
@Test public void getMaximumNumberOfGroups() { Assert.assertEquals(1, SparkVerifier.getMaximumNumberOfGroups(new BoundedDouble(100.0, 50.0, 0.0, 200.0), 10_000)); Assert.assertEquals(5, SparkVerifier.getMaximumNumberOfGroups(new BoundedDouble(100.0, 50.0, 0.0, 200.0), 20)); Assert.assertEquals(100, SparkVerifier.getMax...
TableVerifier extends TestWatcher { public final TableVerifier withoutPartialMatchTimeout() { return this.withPartialMatchTimeoutMillis(0); } final TableVerifier withExpectedDir(String expectedDirPath); final TableVerifier withExpectedDir(File expectedDir); final TableVerifier withOutputDir(String outputDirPath); fina...
@Test public void withoutPartialMatchTimeout() { this.verifier.starting(this.description.get()); this.verifier.withoutPartialMatchTimeout().verify("table1", TableTestUtils.ACTUAL, TableTestUtils.ACTUAL); this.verifier.succeeded(this.description.get()); }
TableAdapters { public static VerifiableTable withRows(VerifiableTable delegate, IntPredicate rowFilter) { return new RowFilterAdapter(delegate, rowFilter); } private TableAdapters(); static VerifiableTable withRows(VerifiableTable delegate, IntPredicate rowFilter); static VerifiableTable withColumns(VerifiableTable d...
@Test public void testAllRows() { this.verify( TableTestUtils.createTable(1, "C", 1, 2, 3, 4, 5), TableAdapters.withRows(TableTestUtils.createTable(1, "C", 1, 2, 3, 4, 5), i -> true)); } @Test public void testNoRows() { VerifiableTable table = TableTestUtils.createTable(1, "C", 1, 2, 3, 4, 5); this.verify( TableTestUti...
TableAdapters { public static VerifiableTable withColumns(VerifiableTable delegate, Predicate<String> columnFilter) { return new ColumnFilterAdapter(delegate, columnFilter); } private TableAdapters(); static VerifiableTable withRows(VerifiableTable delegate, IntPredicate rowFilter); static VerifiableTable withColumns(...
@Test public void testAllColumns() { this.verify( TableTestUtils.createTable(5, "C1", "C2", "C3", "C4", "C5"), TableAdapters.withColumns(TableTestUtils.createTable(5, "C1", "C2", "C3", "C4", "C5"), name -> true)); } @Test public void testSomeColumns() { this.verify( TableTestUtils.createTable(3, "C1", "C3", "C5"), Tabl...
ExpectedResultsParser { public ExpectedResults parse() { this.results = new ExpectedResults(); try (InputStream inputStream = this.loader.load(this.file)) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); parse(reader); return this.results; } catch (IOException e)...
@Test public void testParse() { File expected = new File(TableTestUtils.getExpectedDirectory(), ExpectedResultsParserTest.class.getSimpleName() + ".txt"); ExpectedResults results = new ExpectedResultsParser(new FileSystemExpectedResultsLoader(), expected).parse(); VerifiableTable summary = results.getTable("Summary"); ...
ExpectedResultsParser { ExpectedResults getExpectedResults() { return this.results; } ExpectedResultsParser(ExpectedResultsLoader loader, File file); ExpectedResults parse(); }
@Test public void testCache() { File expected = new File(TableTestUtils.getExpectedDirectory(), ExpectedResultsParserTest.class.getSimpleName() + ".txt"); Map<ExpectedResults, String> results = new IdentityHashMap<>(); for (int i = 0; i < 10; i++) { results.put(ExpectedResultsCache.getExpectedResults(new FileSystemExpe...
SparkVerifier { public SparkVerifier withMaxGroupSize(int maxGroupSize) { this.maxGroupSize = maxGroupSize; return this; } SparkVerifier(List<String> groupKeyColumns); final SparkVerifier withMetadata(String name, String value); SparkVerifier withIgnoreSurplusColumns(boolean ignoreSurplusColumns); SparkVerifier withCol...
@Test public void runTestFail() throws IOException { runTest(AVRO, AVRO_X, false, newSparkVerifier(Arrays.asList("k2", "k1")) .withMaxGroupSize(2)); } @Test public void runTestPass() throws IOException { runTest(AVRO, AVRO, true, newSparkVerifier(Collections.emptyList()) .withMaxGroupSize(2)); } @Test public void runTe...
CellComparator implements Serializable { protected abstract boolean compare(Object actual, Object expected); CellComparator(CellFormatter formatter); CellFormatter getFormatter(); static boolean isFloatingPoint(Object object); boolean equals(Object actual, Object expected); int computeHashCode(Object object); }
@Test public void testCompareToleranceStringInputsFail() { Assert.assertFalse(this.varianceCellComparator.compare("ActualAndExpected", "ActualAndExpected")); Assert.assertFalse(this.varianceCellComparator.compare("Actual", "Expected")); } @Test public void testCompareNumbersWithinTolerance() { Assert.assertTrue("Result...
ResultSetTable { public static VerifiableTable create(ResultSet resultSet) throws SQLException { ResultSetMetaData metaData = resultSet.getMetaData(); int columnCount = metaData.getColumnCount(); List<String> headers = new ArrayList<>(columnCount); for (int n = 1; n <= columnCount; n++) { headers.add(metaData.getColumn...
@Test public void create() throws SQLException { SimpleResultSet resultSet = new SimpleResultSet(); resultSet.addColumn("Name", Types.VARCHAR, 0, 0); resultSet.addColumn("Age", Types.INTEGER, 0, 0); resultSet.addColumn("Height", Types.DOUBLE, 0, 0); resultSet.addColumn("DoB", Types.DATE, 0, 0); resultSet.addRow("Joe", ...
ListVerifiableTable implements VerifiableTable { @Override public int getRowCount() { return this.data.size(); } ListVerifiableTable(List<List<Object>> headersAndData); ListVerifiableTable(List<?> headers, List<List<Object>> data); static VerifiableTable create(Iterable<List> headersAndRows); static VerifiableTable cr...
@Test public void testHeaderTypes() throws Exception { List<Object> headersAsObjects = Collections.singletonList("Col"); List<List<Object>> headersAndDataAsObjects = Arrays.asList(headersAsObjects, Collections.<Object>singletonList("Val")); Assert.assertEquals("Test constructor with headers and rows in one List<List<Ob...
ListVerifiableTable implements VerifiableTable { public static VerifiableTable create(Iterable<List> headersAndRows) { Iterator<List> iterator = headersAndRows.iterator(); List headers = iterator.next(); headers.forEach(ListVerifiableTable::verifyHeader); List rowList = new ArrayList(); iterator.forEachRemaining(verify...
@Test(expected = IllegalArgumentException.class) public void createList_headersNotStrings() { ListVerifiableTable.create(Arrays.asList(Arrays.asList('A', 'B'), Arrays.asList(1, 2))); } @Test(expected = IllegalArgumentException.class) public void createList_wrongRowSize() { ListVerifiableTable.create(Arrays.asList(Array...
CellFormatter implements Function<Object, String>, Serializable { public String format(Object value) { if (isNumber(value)) { if (value.equals(Double.NaN) || value.equals(Float.NaN)) { return "NaN"; } String formatted = this.numberFormat.format(value); if (isNegativeZero(formatted)) { return formatted.substring(1); } r...
@Test public void formatNumbers() { CellFormatter formatter = new CellFormatter(0.01, true); Assert.assertEquals("1", formatter.format(1.0d)); Assert.assertEquals("1.1", formatter.format(1.10d)); Assert.assertEquals("1.11", formatter.format(1.11d)); Assert.assertEquals("1.11", formatter.format(1.111d)); Assert.assertEq...
CellFormatter implements Function<Object, String>, Serializable { private String formatString(String untrimmedValue) { String value = untrimmedValue.trim(); this.builder.setLength(0); boolean changed = false; for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); if (Character.isWhitespace(c)) { this.buil...
@Test public void formatString() { CellFormatter formatter = new CellFormatter(0, false); Assert.assertEquals("", formatter.format("")); Assert.assertEquals("foo", formatter.format("foo")); Assert.assertEquals("foo", formatter.format(" foo ")); Assert.assertEquals("foo bar", formatter.format("foo bar")); Assert.assertE...
ExceptionHtml { static String stackTraceToString(Throwable e) throws UnsupportedEncodingException { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); PrintStream out = new PrintStream(bytes, false, "UTF-8"); stackTraceToString(e, out); out.close(); return bytes.toString("UTF-8"); } private ExceptionHtml(); st...
@Test public void testException() throws IOException { String stackTraceToString = ExceptionHtml.stackTraceToString(new RuntimeException(new IllegalArgumentException(new UnsupportedOperationException()))); List<Map.Entry<String, List<String>>> stackTraces = getStackLineCount(stackTraceToString); Assert.assertEquals(3, ...
UnmatchedIndexMap extends IndexMap { public void addMatch(int matchScore, UnmatchedIndexMap match) { if (this.equals(match)) { throw new IllegalArgumentException("Cannot add this as partial match"); } if (this.partialMatches == null) { this.partialMatches = new TreeSet<>(); } if (match.partialMatches == null) { match.p...
@Test(expected = IllegalArgumentException.class) public void testAddPartialMatchFailsIfSelf() { this.unmatched.addMatch(2, this.unmatched); }
UnmatchedIndexMap extends IndexMap { public UnmatchedIndexMap getBestMutualMatch() { return this.bestMutualMatch; } UnmatchedIndexMap(int expectedIndex, int actualIndex); void addMatch(int matchScore, UnmatchedIndexMap match); boolean match(); UnmatchedIndexMap getBestMutualMatch(); }
@Test public void testInitialState() { Assert.assertNull(this.unmatched.getBestMutualMatch()); }
TimeBoundPartialMatcher implements PartialMatcher { @Override public void match(final List<UnmatchedIndexMap> allMissingRows, final List<UnmatchedIndexMap> allSurplusRows, final List<IndexMap> matchedColumns) { LOGGER.debug("Starting partial match"); ExecutorService executorService = Executors.newSingleThreadExecutor()...
@Test public void executionTimesOut() { try { PartialMatcher endlessMatcher = (allMissingRows, allSurplusRows, matchedColumns) -> { while (true); }; new TimeBoundPartialMatcher(endlessMatcher, 1L).match(null, null, null); Assert.fail("timeout expected"); } catch (RuntimeException e) { Assert.assertTrue(e.getCause() ins...
IndexMap implements Comparable<IndexMap> { @Override public int compareTo(IndexMap that) { if (this.equals(that)) { return 0; } if (this.isMatched()) { if (that.actualIndex >= 0) { return compareUnequals(this.actualIndex, that.actualIndex, this.isSurplus()); } return compareUnequals(this.expectedIndex, that.expectedInd...
@Test public void compareTo1() { IndexMap im1 = new IndexMap(1, 2); IndexMap im2 = new IndexMap(2, 1); Assert.assertTrue(im1.compareTo(im2) > 0); Assert.assertTrue(im2.compareTo(im1) < 0); } @Test public void compareTo2() { IndexMap im1 = new IndexMap(1, 2); IndexMap im2 = new IndexMap(2, -1); Assert.assertTrue(im1.com...
SummaryResultTable implements FormattableTable, Serializable { public SummaryResultTable merge(SummaryResultTable resultTable) { List<ResultCell> nextHeaders = resultTable.getHeaders(); if (this.headers == null || nextHeaders.size() > this.headers.size()) { this.headers = nextHeaders; } this.passedCellCount += resultTa...
@Test public void merge() { CellComparator cellComparator = new ToleranceCellComparator(new CellFormatter(1.0, false)); SummaryResultTable table1 = new SummaryResultTable(new ResultTable(new boolean[2], Arrays.asList( Arrays.asList(ResultCell.createMatchedCell(cellComparator, "Key", "Val")), Arrays.asList(ResultCell.cr...
MultiTableVerifier { public Map<String, ResultTable> verifyTables(Map<String, ? extends VerifiableTable> expectedResults, Map<String, ? extends VerifiableTable> actualResults) { Map<String, ResultTable> results = new LinkedHashMap<>(); List<String> allTableNames = new ArrayList<>(expectedResults.keySet()); for (String ...
@Test public void missingTable() { Map<String, ResultTable> results = verifyTables(createTables("assets"), createTables("assets", "liabs")); Assert.assertEquals(newPassTable(), results.get("assets").getVerifiedRows()); Assert.assertEquals(newMissingTable(), results.get("liabs").getVerifiedRows()); this.expectedTables =...
SparkVerifier { public SparkVerifier withTolerance(double tolerance) { this.columnComparatorsBuilder.withTolerance(tolerance); return this; } SparkVerifier(List<String> groupKeyColumns); final SparkVerifier withMetadata(String name, String value); SparkVerifier withIgnoreSurplusColumns(boolean ignoreSurplusColumns); Sp...
@Test public void withTolerance() throws IOException { List<GenericRecord> actual = Arrays.asList( row(AVSC, 12301, "123011", 12301, 123011.1), row(AVSC, 12301, "123012", 12302, 123012.2), row(AVSC, 12301, "123013", 12303, 123012.9), row(AVSC, 12302, "123021", 12301, 123020.8) ); List<GenericRecord> expected = Arrays.a...
UnitOfWorkInvokerFactory { public Invoker create(Object service, Invoker rootInvoker, SessionFactory sessionFactory) { ImmutableMap.Builder<String, UnitOfWork> unitOfWorkMethodsBuilder = new ImmutableMap.Builder<>(); for (Method m : service.getClass().getMethods()) { if (m.isAnnotationPresent(UnitOfWork.class)) { unitO...
@Test public void noAnnotation() { Invoker invoker = invokerBuilder.create(fooService, new FooInvoker(), null); this.setTargetMethod(exchange, "foo"); Object result = invoker.invoke(exchange, null); assertEquals("foo return", result); verifyZeroInteractions(sessionFactory); verifyZeroInteractions(session); verifyZeroIn...
JAXWSEnvironment { public Endpoint publishEndpoint(EndpointBuilder endpointBuilder) { checkArgument(endpointBuilder != null, "EndpointBuilder is null"); EndpointImpl cxfendpoint = new EndpointImpl(bus, endpointBuilder.getService()); if(endpointBuilder.publishedEndpointUrl() != null) { cxfendpoint.setPublishedEndpointUr...
@Test public void publishEndpointWithProperties() throws Exception { HashMap<String, Object> props = new HashMap<>(); props.put("key", "value"); Endpoint e = jaxwsEnvironment.publishEndpoint( new EndpointBuilder("local: .properties(props)); assertThat(e, is(notNullValue())); assertThat(e.getProperties().get("key"), equ...
JAXWSEnvironment { public <T> T getClient(ClientBuilder<T> clientBuilder) { JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean(); proxyFactory.setServiceClass(clientBuilder.getServiceClass()); proxyFactory.setAddress(clientBuilder.getAddress()); if (clientBuilder.getHandlers() != null) { for (Handler h : cl...
@Test public void getClient() { String address = "http: Handler handler = mock(Handler.class); DummyInterface clientProxy = jaxwsEnvironment.getClient( new ClientBuilder<>(DummyInterface.class, address) ); assertThat(clientProxy, is(instanceOf(Proxy.class))); Client c = ClientProxy.getClient(clientProxy); assertThat(c....
ValidatingInvoker extends AbstractInvoker { @Override public Object invoke(Exchange exchange, Object o) { Annotation[][] parameterAnnotations = this.getTargetMethod(exchange).getParameterAnnotations(); List<Object> params = null; if (o instanceof List) { params = CastUtils.cast((List<?>) o); } else if (o != null) { par...
@Test public void invokeWithoutParams() { setTargetMethod(exchange, "noParams"); invoker.invoke(exchange, null); verify(underlying).invoke(exchange, null); } @Test public void invokeWithoutValidation() { setTargetMethod(exchange, "noValidation", RootParam1.class, RootParam2.class); List<Object> params = Arrays.asList(n...
InstrumentedInvokerFactory { public Invoker create(Object service, Invoker rootInvoker) { List<Method> timedmethods = new ArrayList<>(); List<Method> meteredmethods = new ArrayList<>(); List<Method> exceptionmeteredmethods = new ArrayList<>(); for (Method m : service.getClass().getMethods()) { if (m.isAnnotationPresent...
@Test public void noAnnotation() { Timer timer = testMetricRegistry.timer("timed"); Meter meter = testMetricRegistry.meter("metered"); when(mockMetricRegistry.timer(anyString())).thenReturn(timer); when(mockMetricRegistry.meter(anyString())).thenReturn(meter); long oldtimervalue = timer.getCount(); long oldmetervalue =...
JAXWSBundle implements ConfiguredBundle<C> { public Endpoint publishEndpoint(EndpointBuilder endpointBuilder) { checkArgument(endpointBuilder != null, "EndpointBuilder is null"); return this.jaxwsEnvironment.publishEndpoint(endpointBuilder); } JAXWSBundle(); JAXWSBundle(String servletPath); JAXWSBundle(String servlet...
@Test public void publishEndpoint() { JAXWSBundle<?> jaxwsBundle = new JAXWSBundle<>("/soap", jaxwsEnvironment); Object service = new Object(); try { jaxwsBundle.publishEndpoint(new EndpointBuilder("foo", null)); fail(); } catch (Exception e) { assertThat(e, is(instanceOf(IllegalArgumentException.class))); } try { jaxw...
JAXWSBundle implements ConfiguredBundle<C> { @Deprecated public <T> T getClient(Class<T> serviceClass, String address, Handler...handlers) { checkArgument(serviceClass != null, "ServiceClass is null"); checkArgument(address != null, "Address is null"); checkArgument((address).trim().length() > 0, "Address is empty"); r...
@Test public void getClient() { JAXWSBundle<?> jaxwsBundle = new JAXWSBundle<>("/soap", jaxwsEnvironment); Class<?> cls = Object.class; String url = "http: try { jaxwsBundle.getClient(new ClientBuilder<>(null, null)); fail(); } catch (Exception e) { assertThat(e, is(instanceOf(IllegalArgumentException.class))); } try {...
JAXWSEnvironment { public HttpServlet buildServlet() { CXFNonSpringServlet cxf = new CXFNonSpringServlet(); cxf.setBus(bus); return cxf; } JAXWSEnvironment(String defaultPath); String getDefaultPath(); HttpServlet buildServlet(); void setPublishedEndpointUrlPrefix(String publishedEndpointUrlPrefix); void setInstrumente...
@Test public void buildServlet() { Object result = jaxwsEnvironment.buildServlet(); assertThat(result, is(instanceOf(CXFNonSpringServlet.class))); assertThat(((CXFNonSpringServlet) result).getBus(), is(instanceOf(Bus.class))); }
TranslationUtils { public static Date toDate(DateTime date) { return (date == null) ? null : date.toDate(); } private TranslationUtils(); static Date toDate(DateTime date); static Date toDate(LocalDate ldate); static Date toDate(Calendar date); static Date toDate(Number timestamp); static Date toDate(Number timestamp,...
@Test public void testToDateDateTime() { DateTime time = new DateTime(1000); assertEquals(new Date(1000), TranslationUtils.toDate(time)); } @SuppressWarnings("boxing") @Test public void testToDateNumberTimeUnit() { Calendar calendar = Calendar.getInstance(); calendar.setTimeZone(TimeZone.getTimeZone("GMT")); calendar.s...
CertificateEnrollmentListOptions extends ListOptions { @Override public CertificateEnrollmentListOptions clone() { final CertificateEnrollmentListOptions opt = new CertificateEnrollmentListOptions(); opt.setOptions(this); return opt; } @Internal CertificateEnrollmentListOptions(Integer pageSize, Long maxResults, Order...
@SuppressWarnings("resource") @Test public void testClone() { try { CertificateEnrollmentListOptions certificateenrollmentlistoptions1 = new CertificateEnrollmentListOptions(Integer.valueOf(48), Long.valueOf(36), Order.getDefault(), "b0f5fbe1-99ac-48ae-9b47-721559e6ccff", null, null); CertificateEnrollmentListOptions c...
CertificateEnrollmentListOptions extends ListOptions { @Override @SuppressWarnings("PMD.UselessOverridingMethod") public int hashCode() { return super.hashCode(); } @Internal CertificateEnrollmentListOptions(Integer pageSize, Long maxResults, Order order, String after, List<...
@SuppressWarnings("resource") @Test public void testHashCode() { try { CertificateEnrollmentListOptions certificateenrollmentlistoptions1 = new CertificateEnrollmentListOptions(Integer.valueOf(58), Long.valueOf(40), Order.getDefault(), "a079c181-0afe-4474-a989-af61026abaab", null, null); CertificateEnrollmentListOption...
CertificateEnrollmentListOptions extends ListOptions { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!super.equals(obj)) { return false; } if (!(obj instanceof CertificateEnrollmentListOptions)) { return false; } final CertificateEnrollmentListOpt...
@SuppressWarnings("resource") @Test public void testEquals() { try { CertificateEnrollmentListOptions certificateenrollmentlistoptions1 = new CertificateEnrollmentListOptions(Integer.valueOf(1), Long.valueOf(-38), Order.getDefault(), "4c2f0459-26a3-4bf3-930d-2cc2a4358b6e", null, null); CertificateEnrollmentListOptions ...
SubtenantTrustedCertificateListOptions extends ListOptions { @Override public SubtenantTrustedCertificateListOptions clone() { final SubtenantTrustedCertificateListOptions opt = new SubtenantTrustedCertificateListOptions(); opt.setOptions(this); return opt; } @Internal SubtenantTrustedCertificateListOptions(Integer pa...
@SuppressWarnings("resource") @Test public void testClone() { try { SubtenantTrustedCertificateListOptions subtenanttrustedcertificatelistoptions1 = new SubtenantTrustedCertificateListOptions(Integer.valueOf(50), Long.valueOf(-30), Order.getDefault(), "23d23473-f6f1-4a08-a77d-a56d2983c571", null, null); SubtenantTruste...
SubtenantTrustedCertificateListOptions extends ListOptions { @Override @SuppressWarnings("PMD.UselessOverridingMethod") public int hashCode() { return super.hashCode(); } @Internal SubtenantTrustedCertificateListOptions(Integer pageSize, Long maxResults, Order order, String after, ...
@SuppressWarnings("resource") @Test public void testHashCode() { try { SubtenantTrustedCertificateListOptions subtenanttrustedcertificatelistoptions1 = new SubtenantTrustedCertificateListOptions(Integer.valueOf(38), Long.valueOf(79), Order.getDefault(), "f2d79052-cdeb-468c-81c9-c72f1883423c", null, null); SubtenantTrus...
SubtenantTrustedCertificateListOptions extends ListOptions { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!super.equals(obj)) { return false; } if (!(obj instanceof SubtenantTrustedCertificateListOptions)) { return false; } final SubtenantTrusted...
@SuppressWarnings("resource") @Test public void testEquals() { try { SubtenantTrustedCertificateListOptions subtenanttrustedcertificatelistoptions1 = new SubtenantTrustedCertificateListOptions(Integer.valueOf(65), Long.valueOf(61), Order.getDefault(), "6646edc5-d533-4033-b553-763fb25382fd", null, null); SubtenantTruste...
CertificateEnrollmentDao extends AbstractModelDao<CertificateEnrollment> implements ReadDao<CertificateEnrollment> { @Override @SuppressWarnings({ "resource", "unused" }) public CertificateEnrollmentDao clone() { try { return new CertificateEnrollmentDao().configureAndGet(getModuleOrThrow() == null ? null : getModuleOr...
@SuppressWarnings("resource") @Test public void testClone() { try { CertificateEnrollmentDao certificateenrollmentdao1 = new CertificateEnrollmentDao(); CertificateEnrollmentDao certificateenrollmentdao2 = certificateenrollmentdao1.clone(); assertNotNull(certificateenrollmentdao1); assertNotNull(certificateenrollmentda...
PreSharedKeyDao extends AbstractPreSharedKeyDao { @Override @SuppressWarnings({ "resource", "unused" }) public PreSharedKeyDao clone() { try { return new PreSharedKeyDao().configureAndGet(getModuleOrThrow() == null ? null : getModuleOrThrow().clone()); } catch (MbedCloudException exception) { return null; } } PreShared...
@SuppressWarnings("resource") @Test public void testClone() { try { PreSharedKeyDao presharedkeydao1 = new PreSharedKeyDao(); PreSharedKeyDao presharedkeydao2 = presharedkeydao1.clone(); assertNotNull(presharedkeydao1); assertNotNull(presharedkeydao2); assertNotSame(presharedkeydao2, presharedkeydao1); assertEquals(pre...
CertificateEnrollmentListDao extends AbstractModelListDao<CertificateEnrollment, CertificateEnrollmentListOptions> implements ModelListDao<CertificateEnrollment, CertificateEnrollmentListOptions> { @Override @SuppressWarnings({ "resourc...
@SuppressWarnings("resource") @Test public void testClone() { try { CertificateEnrollmentListDao certificateenrollmentlistdao1 = new CertificateEnrollmentListDao(); CertificateEnrollmentListDao certificateenrollmentlistdao2 = certificateenrollmentlistdao1.clone(); assertNotNull(certificateenrollmentlistdao1); assertNot...
CertificateIssuerConfigListDao extends AbstractModelListDao<CertificateIssuerConfig, CertificateIssuerConfigListOptions> implements ModelListDao<CertificateIssuerConfi...
@SuppressWarnings("resource") @Test public void testClone() { try { CertificateIssuerConfigListDao certificateissuerconfiglistdao1 = new CertificateIssuerConfigListDao(); CertificateIssuerConfigListDao certificateissuerconfiglistdao2 = certificateissuerconfiglistdao1.clone(); assertNotNull(certificateissuerconfiglistda...
TranslationUtils { public static double toDouble(Number value) { return toDouble(value, 0.0); } private TranslationUtils(); static Date toDate(DateTime date); static Date toDate(LocalDate ldate); static Date toDate(Calendar date); static Date toDate(Number timestamp); static Date toDate(Number timestamp, TimeUnit unit...
@Test public void testToDoubleConversion() { double doubleValue = 156433465.45464564; String doubleString = String.valueOf(doubleValue); assertEquals(doubleValue, TranslationUtils.toDouble(doubleString, 0), 0); doubleValue = Double.MAX_VALUE; doubleString = String.valueOf(doubleValue); assertEquals(doubleValue, Transla...
CertificateIssuerConfigDao extends AbstractModelDao<CertificateIssuerConfig> implements CrudDao<CertificateIssuerConfig> { @Override @SuppressWarnings({ "resource", "unused" }) public CertificateIssuerConfigDao clone() { try { return new CertificateIssuerConfigDao().configureAndGet(getModuleOrThrow() == null ? null : g...
@SuppressWarnings("resource") @Test public void testClone() { try { CertificateIssuerConfigDao certificateissuerconfigdao1 = new CertificateIssuerConfigDao(); CertificateIssuerConfigDao certificateissuerconfigdao2 = certificateissuerconfigdao1.clone(); assertNotNull(certificateissuerconfigdao1); assertNotNull(certifica...
ServerCredentialsDao extends AbstractModelDao<ServerCredentials> { @Override @SuppressWarnings({ "resource", "unused" }) public ServerCredentialsDao clone() { try { return new ServerCredentialsDao().configureAndGet(getModuleOrThrow() == null ? null : getModuleOrThrow().clone()); } catch (MbedCloudException exception) {...
@SuppressWarnings("resource") @Test public void testClone() { try { ServerCredentialsDao servercredentialsdao1 = new ServerCredentialsDao(); ServerCredentialsDao servercredentialsdao2 = servercredentialsdao1.clone(); assertNotNull(servercredentialsdao1); assertNotNull(servercredentialsdao2); assertNotSame(servercredent...
TrustedCertificateListDao extends AbstractModelListDao<TrustedCertificate, TrustedCertificateListOptions> implements ModelListDao<TrustedCertificate, TrustedCertificateListOptions> { @Override @SuppressWarnings({ "resource", "unused" }) public TrustedCertificateListDao clone() { try { return new TrustedCertificateListD...
@SuppressWarnings("resource") @Test public void testClone() { try { TrustedCertificateListDao trustedcertificatelistdao1 = new TrustedCertificateListDao(); TrustedCertificateListDao trustedcertificatelistdao2 = trustedcertificatelistdao1.clone(); assertNotNull(trustedcertificatelistdao1); assertNotNull(trustedcertifica...
CertificateIssuerDao extends AbstractCertificateIssuerDao { @Override @SuppressWarnings({ "resource", "unused" }) public CertificateIssuerDao clone() { try { return new CertificateIssuerDao().configureAndGet(getModuleOrThrow() == null ? null : getModuleOrThrow().clone()); } catch (MbedCloudException exception) { return...
@SuppressWarnings("resource") @Test public void testClone() { try { CertificateIssuerDao certificateissuerdao1 = new CertificateIssuerDao(); CertificateIssuerDao certificateissuerdao2 = certificateissuerdao1.clone(); assertNotNull(certificateissuerdao1); assertNotNull(certificateissuerdao2); assertNotSame(certificateis...