Search in sources :

Example 96 with Mock

use of org.mockito.Mock in project kie-wb-common by kiegroup.

the class PopulatedLibraryScreenTest method setup.

@Before
public void setup() {
    libraryServiceCaller = new CallerMock<>(libraryService);
    libraryScreen = spy(new PopulatedLibraryScreen(view, libraryPlaces, libraryServiceCaller, projectController, projectContext, tileWidgets, addProjectButtonPresenter, projectCountUpdateEvent));
    doReturn(true).when(projectController).canCreateProjects(any());
    project1 = mockProject(PROJECT_1);
    project2 = mockProject(PROJECT_2);
    project3 = mockProject(PROJECT_3);
    final List<WorkspaceProject> projects = new ArrayList<>();
    projects.add(project1);
    projects.add(project2);
    projects.add(project3);
    when(projectContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
    when(projectContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    when(projectContext.getActiveModule()).thenReturn(Optional.empty());
    when(projectContext.getActiveRepositoryRoot()).thenReturn(Optional.empty());
    when(projectContext.getActivePackage()).thenReturn(Optional.empty());
    final LibraryInfo libraryInfo = new LibraryInfo(projects);
    doReturn(libraryInfo).when(libraryService).getLibraryInfo(organizationalUnit);
    doReturn(mock(TileWidget.View.class)).when(tileWidget).getView();
    when(tileWidgets.get()).thenAnswer((Answer<TileWidget<WorkspaceProject>>) invocationOnMock -> {
        TileWidget tile = mock(TileWidget.class);
        doReturn(mock(TileWidget.View.class)).when(tile).getView();
        doAnswer((Answer<Void>) invocationOnMock1 -> {
            when(tile.getContent()).thenReturn(invocationOnMock1.getArgument(0, WorkspaceProject.class));
            return null;
        }).when(tile).setContent(any());
        return tile;
    });
    doReturn(mock(AddProjectButtonPresenter.View.class)).when(addProjectButtonPresenter).getView();
    libraryScreen.setup();
}
Also used : TileWidget(org.kie.workbench.common.screens.library.client.widgets.common.TileWidget) CallerMock(org.uberfire.mocks.CallerMock) Space(org.uberfire.spaces.Space) Mock(org.mockito.Mock) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) RunWith(org.junit.runner.RunWith) ProjectAssetListUpdated(org.kie.workbench.common.screens.library.api.ProjectAssetListUpdated) Mockito.spy(org.mockito.Mockito.spy) ArrayList(java.util.ArrayList) LibraryPlaces(org.kie.workbench.common.screens.library.client.util.LibraryPlaces) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Module(org.guvnor.common.services.project.model.Module) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Mockito.doReturn(org.mockito.Mockito.doReturn) Before(org.junit.Before) Event(javax.enterprise.event.Event) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) NewProjectEvent(org.guvnor.common.services.project.events.NewProjectEvent) Repository(org.guvnor.structure.repositories.Repository) Answers(org.mockito.Answers) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) LibraryService(org.kie.workbench.common.screens.library.api.LibraryService) Mockito.doNothing(org.mockito.Mockito.doNothing) Mockito.when(org.mockito.Mockito.when) WorkspaceProjectContext(org.guvnor.common.services.project.client.context.WorkspaceProjectContext) Mockito.verify(org.mockito.Mockito.verify) RepositoryRemovedEvent(org.guvnor.structure.repositories.RepositoryRemovedEvent) List(java.util.List) Mockito.never(org.mockito.Mockito.never) Caller(org.jboss.errai.common.client.api.Caller) ProjectController(org.guvnor.common.services.project.client.security.ProjectController) AddProjectButtonPresenter(org.kie.workbench.common.screens.library.client.widgets.library.AddProjectButtonPresenter) Optional(java.util.Optional) Mockito.anyInt(org.mockito.Mockito.anyInt) Assert(org.junit.Assert) Mockito.any(org.mockito.Mockito.any) ProjectCountUpdate(org.kie.workbench.common.screens.library.api.ProjectCountUpdate) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) Mockito.eq(org.mockito.Mockito.eq) Mockito.mock(org.mockito.Mockito.mock) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) LibraryInfo(org.kie.workbench.common.screens.library.api.LibraryInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ArrayList(java.util.ArrayList) TileWidget(org.kie.workbench.common.screens.library.client.widgets.common.TileWidget) Before(org.junit.Before)

Example 97 with Mock

use of org.mockito.Mock in project kie-wb-common by kiegroup.

the class ExamplesServiceImplTest method setup.

@Before
public void setup() throws Exception {
    when(spaceConfigStorageRegistry.get(Mockito.<String>any())).thenReturn(spaceConfigStorage);
    when(spaceConfigStorageRegistry.getBatch(Mockito.<String>any())).thenReturn(new SpaceConfigStorageRegistryImpl.SpaceStorageBatchImpl(spaceConfigStorage));
    when(spaceConfigStorageRegistry.exist(Mockito.<String>any())).thenReturn(true);
    when(ou.getSpace()).thenReturn(space);
    when(space.getName()).thenReturn("ou");
    service = spy(new ExamplesServiceImpl(ioService, repositoryFactory, moduleService, ouService, projectService, metadataService, newProjectEvent, projectScreenService, validators, spaceConfigStorageRegistry, systemFS, pathUtil, repositoryService));
    FileUtils.deleteDirectory(new File(".kie-wb-playground"));
    when(this.validators.getValidators()).thenReturn(new ArrayList<>());
    doAnswer(invocationOnMock -> {
        String spaceName = (String) invocationOnMock.getArguments()[0];
        String defaultGroupId = (String) invocationOnMock.getArguments()[1];
        OrganizationalUnitImpl o = new OrganizationalUnitImpl(spaceName, defaultGroupId);
        organizationalUnits.put(spaceName, o);
        return o;
    }).when(ouService).createOrganizationalUnit(Mockito.<String>any(), Mockito.<String>any());
    doAnswer(invocationOnMock -> organizationalUnits.get(invocationOnMock.getArguments()[0])).when(ouService).getOrganizationalUnit(Mockito.<String>any());
    when(ouService.getOrganizationalUnits()).thenReturn(new HashSet<OrganizationalUnit>() {

        {
            add(new OrganizationalUnitImpl("ou1Name", "ou1GroupId"));
            add(new OrganizationalUnitImpl("ou2Name", "ou2GroupId"));
        }
    });
    when(moduleService.resolveModule(Mockito.<Path>any())).thenAnswer((Answer<KieModule>) invocationOnMock -> {
        final Path path = (Path) invocationOnMock.getArguments()[0];
        final KieModule module = new KieModule(path, path, path, path, path, path, mock(POM.class));
        return module;
    });
    when(sessionInfo.getId()).thenReturn("sessionId");
    when(sessionInfo.getIdentity()).thenReturn(user);
    when(user.getIdentifier()).thenReturn("user");
    doAnswer(invocationOnMock -> organizationalUnits.containsKey(invocationOnMock.getArguments()[0])).when(service).existSpace(any());
}
Also used : Arrays(java.util.Arrays) RepositoryInfo(org.guvnor.structure.organizationalunit.config.RepositoryInfo) RepositoryFactory(org.guvnor.structure.server.repositories.RepositoryFactory) URL(java.net.URL) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) OrganizationalUnitService(org.guvnor.structure.organizationalunit.OrganizationalUnitService) ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) POM(org.guvnor.common.services.project.model.POM) PathFactory(org.uberfire.backend.vfs.PathFactory) KieModuleService(org.kie.workbench.common.services.shared.project.KieModuleService) Map(java.util.Map) After(org.junit.After) Spy(org.mockito.Spy) Mockito.doAnswer(org.mockito.Mockito.doAnswer) WorkspaceProjectContextChangeEvent(org.guvnor.common.services.project.context.WorkspaceProjectContextChangeEvent) SessionInfo(org.uberfire.rpc.SessionInfo) Module(org.guvnor.common.services.project.model.Module) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) SpaceConfigStorage(org.guvnor.structure.organizationalunit.config.SpaceConfigStorage) ProjectScreenService(org.kie.workbench.common.screens.projecteditor.service.ProjectScreenService) Mockito.doReturn(org.mockito.Mockito.doReturn) NewProjectEvent(org.guvnor.common.services.project.events.NewProjectEvent) MetadataService(org.guvnor.common.services.shared.metadata.MetadataService) SpaceConfigStorageRegistry(org.guvnor.structure.organizationalunit.config.SpaceConfigStorageRegistry) Set(java.util.Set) KieModule(org.kie.workbench.common.services.shared.project.KieModule) List(java.util.List) ImportProjectValidators(org.kie.workbench.common.screens.examples.validation.ImportProjectValidators) Assert.assertFalse(org.junit.Assert.assertFalse) PathUtil(org.guvnor.common.services.project.backend.server.utils.PathUtil) Optional(java.util.Optional) EventSourceMock(org.uberfire.mocks.EventSourceMock) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) SpaceConfigStorageRegistryImpl(org.guvnor.structure.backend.organizationalunit.config.SpaceConfigStorageRegistryImpl) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Space(org.uberfire.spaces.Space) Mock(org.mockito.Mock) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) Mockito.spy(org.mockito.Mockito.spy) Captor(org.mockito.Captor) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Answer(org.mockito.stubbing.Answer) ExamplesMetaData(org.kie.workbench.common.screens.examples.model.ExamplesMetaData) ArgumentCaptor(org.mockito.ArgumentCaptor) Path(org.uberfire.backend.vfs.Path) Before(org.junit.Before) Event(javax.enterprise.event.Event) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Assert.assertNotNull(org.junit.Assert.assertNotNull) RepositoryService(org.guvnor.structure.repositories.RepositoryService) Assert.assertTrue(org.junit.Assert.assertTrue) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) Mockito.times(org.mockito.Mockito.times) GitRepository(org.guvnor.structure.repositories.impl.git.GitRepository) Mockito.when(org.mockito.Mockito.when) WorkspaceProjectService(org.guvnor.common.services.project.service.WorkspaceProjectService) File(java.io.File) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) Mockito.verify(org.mockito.Mockito.verify) ImportUtils.makeGitRepository(org.kie.workbench.common.screens.examples.backend.server.ImportUtils.makeGitRepository) Mockito(org.mockito.Mockito) Mockito.never(org.mockito.Mockito.never) Assert.assertNull(org.junit.Assert.assertNull) Paths(java.nio.file.Paths) User(org.jboss.errai.security.shared.api.identity.User) ImportProject(org.kie.workbench.common.screens.examples.model.ImportProject) IOService(org.uberfire.io.IOService) Collections(java.util.Collections) FileSystem(org.uberfire.java.nio.file.FileSystem) Assert.assertEquals(org.junit.Assert.assertEquals) Branch(org.guvnor.structure.repositories.Branch) Path(org.uberfire.backend.vfs.Path) SpaceConfigStorageRegistryImpl(org.guvnor.structure.backend.organizationalunit.config.SpaceConfigStorageRegistryImpl) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) ExampleOrganizationalUnit(org.kie.workbench.common.screens.examples.model.ExampleOrganizationalUnit) File(java.io.File) OrganizationalUnitImpl(org.guvnor.structure.organizationalunit.impl.OrganizationalUnitImpl) KieModule(org.kie.workbench.common.services.shared.project.KieModule) Before(org.junit.Before)

Example 98 with Mock

use of org.mockito.Mock in project kie-wb-common by kiegroup.

the class BranchManagementPresenterTest method setupWithUpdatableBranchesTest.

@Test
public void setupWithUpdatableBranchesTest() {
    final Map<String, RolePermissions> permissionsByRole = new HashMap<>();
    permissionsByRole.put("CONTRIBUTOR", new RolePermissions("CONTRIBUTOR", true, false, true, true));
    doReturn(new BranchPermissions("myBranch", permissionsByRole)).when(libraryService).loadBranchPermissions("mySpace", "myProject", "myBranch");
    doReturn(promises.resolve(Arrays.asList(new Branch("main", mock(Path.class)), new Branch("myBranch", mock(Path.class))))).when(projectController).getUpdatableBranches(any());
    presenter.setup(mock(ProjectScreenModel.class)).then(v -> {
        assertEquals("myBranch", presenter.selectedBranch);
        verify(view).init(presenter);
        verify(view, never()).showEmptyState();
        verify(view).setupBranchSelect(any(), any(), any());
        verify(libraryService).loadBranchPermissions("mySpace", "myProject", "myBranch");
        return promises.resolve();
    }).catch_(error -> {
        fail();
        return promises.resolve();
    });
}
Also used : RolePermissions(org.guvnor.structure.organizationalunit.config.RolePermissions) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) CallerMock(org.uberfire.mocks.CallerMock) Space(org.uberfire.spaces.Space) Mock(org.mockito.Mock) Promises(org.uberfire.client.promise.Promises) ArgumentMatchers.eq(org.mockito.ArgumentMatchers.eq) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) Mockito.spy(org.mockito.Mockito.spy) SettingsSectionChange(org.kie.workbench.common.screens.library.client.settings.SettingsSectionChange) ArrayList(java.util.ArrayList) LibraryPlaces(org.kie.workbench.common.screens.library.client.util.LibraryPlaces) BranchPermissions(org.guvnor.structure.organizationalunit.config.BranchPermissions) Map(java.util.Map) Module(org.guvnor.common.services.project.model.Module) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Assert.fail(org.junit.Assert.fail) SyncPromises(org.uberfire.promise.SyncPromises) Mockito.anyString(org.mockito.Mockito.anyString) Mockito.doReturn(org.mockito.Mockito.doReturn) Path(org.uberfire.backend.vfs.Path) Before(org.junit.Before) OrganizationalUnit(org.guvnor.structure.organizationalunit.OrganizationalUnit) Repository(org.guvnor.structure.repositories.Repository) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test) LibraryService(org.kie.workbench.common.screens.library.api.LibraryService) MenuItem(org.kie.workbench.common.screens.library.client.settings.util.sections.MenuItem) Contributor(org.uberfire.security.Contributor) Mockito.verify(org.mockito.Mockito.verify) List(java.util.List) Mockito.never(org.mockito.Mockito.never) Caller(org.jboss.errai.common.client.api.Caller) ProjectController(org.guvnor.common.services.project.client.security.ProjectController) EventSourceMock(org.uberfire.mocks.EventSourceMock) Collections(java.util.Collections) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Assert.assertEquals(org.junit.Assert.assertEquals) Branch(org.guvnor.structure.repositories.Branch) Mockito.mock(org.mockito.Mockito.mock) BranchPermissions(org.guvnor.structure.organizationalunit.config.BranchPermissions) RolePermissions(org.guvnor.structure.organizationalunit.config.RolePermissions) HashMap(java.util.HashMap) Branch(org.guvnor.structure.repositories.Branch) Mockito.anyString(org.mockito.Mockito.anyString) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) Test(org.junit.Test)

Example 99 with Mock

use of org.mockito.Mock in project aem-core-wcm-components by Adobe-Marketing-Cloud.

the class SearchResultServletTest method setUpQueryBuilder.

/**
 * Sets up a mock query builder.
 * If there are any results then `this.spyResolver` will be set to a non-null value.
 *
 * Note: any query executed on the query builder configured by calling this method will simply list all of the
 * child pages of the search path. No actual search, or other predicates on the query will be honoured. Therefore,
 * the results from the query builder cannot be trusted for testing purposes beyond testing the search root and
 * the handling / transformation of results.
 */
public void setUpQueryBuilder() {
    doAnswer(invocationOnQueryBuilder -> {
        PredicateGroup predicateGroup = invocationOnQueryBuilder.getArgument(0);
        Query query = Mockito.mock(Query.class);
        doAnswer(invocationOnQuery -> {
            SearchResult result = Mockito.mock(SearchResult.class);
            doAnswer(invocationOnResult -> {
                String searchPath = predicateGroup.getByName(PathPredicateEvaluator.PATH).get(PathPredicateEvaluator.PATH);
                Iterator<Resource> res = Objects.requireNonNull(this.context.resourceResolver().getResource(searchPath)).listChildren();
                List<Resource> resources = StreamSupport.stream(Spliterators.spliteratorUnknownSize(res, Spliterator.ORDERED), false).filter(r -> r.isResourceType("cq:Page")).collect(Collectors.toList());
                if (resources.size() > 0) {
                    this.spyResolver = Mockito.spy(this.context.resourceResolver());
                    doNothing().when(spyResolver).close();
                    Resource spyResource = Mockito.spy(resources.get(0));
                    doAnswer(invocationOnMock3 -> spyResolver).when(spyResource).getResourceResolver();
                    resources.set(0, spyResource);
                }
                return resources.iterator();
            }).when(result).getResources();
            return result;
        }).when(query).getResult();
        return query;
    }).when(mockQueryBuilder).createQuery(any(), any());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ResourceResolver(org.apache.sling.api.resource.ResourceResolver) Spliterators(java.util.Spliterators) Mock(org.mockito.Mock) AemContext(io.wcm.testing.mock.aem.junit5.AemContext) ArrayList(java.util.ArrayList) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule) SearchResult(com.day.cq.search.result.SearchResult) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) CoreComponentTestContext(com.adobe.cq.wcm.core.components.context.CoreComponentTestContext) ImmutableList(com.google.common.collect.ImmutableList) Map(java.util.Map) StreamSupport(java.util.stream.StreamSupport) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) LinkedList(java.util.LinkedList) QueryBuilder(com.day.cq.search.QueryBuilder) MockSlingHttpServletRequest(org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) MockRequestPathInfo(org.apache.sling.testing.mock.sling.servlet.MockRequestPathInfo) Iterator(java.util.Iterator) PathPredicateEvaluator(com.day.cq.search.eval.PathPredicateEvaluator) ImmutableMap(com.google.common.collect.ImmutableMap) ListItem(com.adobe.cq.wcm.core.components.models.ListItem) HttpServletResponse(javax.servlet.http.HttpServletResponse) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Resource(org.apache.sling.api.resource.Resource) IOException(java.io.IOException) SimpleAbstractTypeResolver(com.fasterxml.jackson.databind.module.SimpleAbstractTypeResolver) AemContextExtension(io.wcm.testing.mock.aem.junit5.AemContextExtension) Collectors(java.util.stream.Collectors) LiveRelationshipManager(com.day.cq.wcm.msm.api.LiveRelationshipManager) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) Nullable(org.jetbrains.annotations.Nullable) Mockito(org.mockito.Mockito) List(java.util.List) PredicateGroup(com.day.cq.search.PredicateGroup) Query(com.day.cq.search.Query) MockSlingHttpServletResponse(org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletResponse) NotNull(org.jetbrains.annotations.NotNull) Spliterator(java.util.Spliterator) JsonIgnoreProperties(com.fasterxml.jackson.annotation.JsonIgnoreProperties) Query(com.day.cq.search.Query) Resource(org.apache.sling.api.resource.Resource) SearchResult(com.day.cq.search.result.SearchResult) PredicateGroup(com.day.cq.search.PredicateGroup)

Example 100 with Mock

use of org.mockito.Mock in project spring-boot by spring-projects.

the class RestTemplateBuilderTests method customizerShouldBeAppliedAtTheEnd.

@Test
void customizerShouldBeAppliedAtTheEnd() {
    ResponseErrorHandler errorHandler = mock(ResponseErrorHandler.class);
    ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
    this.builder.interceptors(this.interceptor).messageConverters(this.messageConverter).rootUri("http://localhost:8080").errorHandler(errorHandler).basicAuthentication("spring", "boot").requestFactory(() -> requestFactory).customizers((restTemplate) -> {
        assertThat(restTemplate.getInterceptors()).hasSize(1);
        assertThat(restTemplate.getMessageConverters()).contains(this.messageConverter);
        assertThat(restTemplate.getUriTemplateHandler()).isInstanceOf(RootUriTemplateHandler.class);
        assertThat(restTemplate.getErrorHandler()).isEqualTo(errorHandler);
        ClientHttpRequestFactory actualRequestFactory = restTemplate.getRequestFactory();
        assertThat(actualRequestFactory).isInstanceOf(InterceptingClientHttpRequestFactory.class);
        ClientHttpRequestInitializer initializer = restTemplate.getClientHttpRequestInitializers().get(0);
        assertThat(initializer).isInstanceOf(RestTemplateBuilderClientHttpRequestInitializer.class);
    }).build();
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) MockRestResponseCreators.withSuccess(org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess) Arrays(java.util.Arrays) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) Mock(org.mockito.Mock) ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RequestConfig(org.apache.http.client.config.RequestConfig) Mockito.spy(org.mockito.Mockito.spy) Supplier(java.util.function.Supplier) MockRestServiceServer(org.springframework.test.web.client.MockRestServiceServer) ClientHttpRequest(org.springframework.http.client.ClientHttpRequest) ResourceHttpMessageConverter(org.springframework.http.converter.ResourceHttpMessageConverter) ExtendWith(org.junit.jupiter.api.extension.ExtendWith) ResponseErrorHandler(org.springframework.web.client.ResponseErrorHandler) Duration(java.time.Duration) ClientHttpRequestInitializer(org.springframework.http.client.ClientHttpRequestInitializer) UriTemplateHandler(org.springframework.web.util.UriTemplateHandler) URI(java.net.URI) RestTemplate(org.springframework.web.client.RestTemplate) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) MockitoExtension(org.mockito.junit.jupiter.MockitoExtension) SimpleClientHttpRequestFactory(org.springframework.http.client.SimpleClientHttpRequestFactory) InOrder(org.mockito.InOrder) HttpHeaders(org.springframework.http.HttpHeaders) MediaType(org.springframework.http.MediaType) InterceptingClientHttpRequestFactory(org.springframework.http.client.InterceptingClientHttpRequestFactory) HttpMethod(org.springframework.http.HttpMethod) Set(java.util.Set) OkHttp3ClientHttpRequestFactory(org.springframework.http.client.OkHttp3ClientHttpRequestFactory) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) BDDMockito.then(org.mockito.BDDMockito.then) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) Assertions.entry(org.assertj.core.api.Assertions.entry) StandardCharsets(java.nio.charset.StandardCharsets) MockRestRequestMatchers.requestTo(org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo) StringHttpMessageConverter(org.springframework.http.converter.StringHttpMessageConverter) Test(org.junit.jupiter.api.Test) ClientHttpRequestInterceptor(org.springframework.http.client.ClientHttpRequestInterceptor) OkHttpClient(okhttp3.OkHttpClient) HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) Mockito.inOrder(org.mockito.Mockito.inOrder) Assertions.assertThatIllegalArgumentException(org.assertj.core.api.Assertions.assertThatIllegalArgumentException) BufferingClientHttpRequestFactory(org.springframework.http.client.BufferingClientHttpRequestFactory) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) ClientHttpRequestInitializer(org.springframework.http.client.ClientHttpRequestInitializer) ClientHttpRequestFactory(org.springframework.http.client.ClientHttpRequestFactory) SimpleClientHttpRequestFactory(org.springframework.http.client.SimpleClientHttpRequestFactory) InterceptingClientHttpRequestFactory(org.springframework.http.client.InterceptingClientHttpRequestFactory) OkHttp3ClientHttpRequestFactory(org.springframework.http.client.OkHttp3ClientHttpRequestFactory) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) BufferingClientHttpRequestFactory(org.springframework.http.client.BufferingClientHttpRequestFactory) ResponseErrorHandler(org.springframework.web.client.ResponseErrorHandler) HttpComponentsClientHttpRequestFactory(org.springframework.http.client.HttpComponentsClientHttpRequestFactory) InterceptingClientHttpRequestFactory(org.springframework.http.client.InterceptingClientHttpRequestFactory) Test(org.junit.jupiter.api.Test)

Aggregations

Mock (org.mockito.Mock)135 Mockito.mock (org.mockito.Mockito.mock)109 Test (org.junit.Test)104 Before (org.junit.Before)96 Mockito.verify (org.mockito.Mockito.verify)89 Mockito.when (org.mockito.Mockito.when)82 List (java.util.List)81 RunWith (org.junit.runner.RunWith)76 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)65 Collections (java.util.Collections)56 ArrayList (java.util.ArrayList)55 ArgumentCaptor (org.mockito.ArgumentCaptor)52 Mockito.spy (org.mockito.Mockito.spy)48 Arrays (java.util.Arrays)44 Assert.assertEquals (org.junit.Assert.assertEquals)41 ArgumentMatchers.eq (org.mockito.ArgumentMatchers.eq)41 Mockito.doReturn (org.mockito.Mockito.doReturn)41 Map (java.util.Map)40 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)38 Mockito.never (org.mockito.Mockito.never)37