Search in sources :

Example 1 with ReturnsArgumentAt

use of org.mockito.internal.stubbing.answers.ReturnsArgumentAt in project AuthMeReloaded by AuthMe.

the class HelpProviderTest method setDefaultHelpMessages.

private static void setDefaultHelpMessages(HelpMessagesService helpMessagesService) {
    given(helpMessagesService.buildLocalizedDescription(any(CommandDescription.class))).willAnswer(new ReturnsArgumentAt(0));
    for (HelpMessage key : HelpMessage.values()) {
        String text = key.name().replace("_", " ").toLowerCase();
        given(helpMessagesService.getMessage(key)).willReturn(text.substring(0, 1).toUpperCase() + text.substring(1));
    }
    for (DefaultPermission permission : DefaultPermission.values()) {
        String text = permission.name().replace("_", " ").toLowerCase();
        given(helpMessagesService.getMessage(permission)).willReturn(text.substring(0, 1).toUpperCase() + text.substring(1));
    }
    for (HelpSection section : HelpSection.values()) {
        String text = section.name().replace("_", " ").toLowerCase();
        given(helpMessagesService.getMessage(section)).willReturn(text.substring(0, 1).toUpperCase() + text.substring(1));
    }
}
Also used : CommandDescription(fr.xephi.authme.command.CommandDescription) Matchers.containsString(org.hamcrest.Matchers.containsString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DefaultPermission(fr.xephi.authme.permission.DefaultPermission) ReturnsArgumentAt(org.mockito.internal.stubbing.answers.ReturnsArgumentAt)

Example 2 with ReturnsArgumentAt

use of org.mockito.internal.stubbing.answers.ReturnsArgumentAt in project hazelcast by hazelcast.

the class PredicateTestUtils method createPassthroughVisitor.

static Visitor createPassthroughVisitor() {
    Visitor visitor = mock(Visitor.class);
    when(visitor.visit((AndPredicate) anyObject(), (Indexes) anyObject())).thenAnswer(new ReturnsArgumentAt(0));
    when(visitor.visit((OrPredicate) anyObject(), (Indexes) anyObject())).thenAnswer(new ReturnsArgumentAt(0));
    when(visitor.visit((NotPredicate) anyObject(), (Indexes) anyObject())).thenAnswer(new ReturnsArgumentAt(0));
    return visitor;
}
Also used : ReturnsArgumentAt(org.mockito.internal.stubbing.answers.ReturnsArgumentAt)

Example 3 with ReturnsArgumentAt

use of org.mockito.internal.stubbing.answers.ReturnsArgumentAt in project frames by tinkerpop.

the class FramedGraphFactoryTest method testFactory.

@Test
public void testFactory() {
    Mockito.when(mockModule.configure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class))).then(new ReturnsArgumentAt(0));
    FramedGraphFactory graphFactory = new FramedGraphFactory(mockModule);
    FramedGraph<Graph> framed = graphFactory.create(base);
    Assert.assertEquals(base, framed.getBaseGraph());
    Mockito.verify(mockModule, Mockito.times(1)).configure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class));
    TransactionalGraph baseTransactional = Mockito.mock(TransactionalGraph.class);
    FramedTransactionalGraph<TransactionalGraph> framedTransactional = graphFactory.create(baseTransactional);
    Assert.assertEquals(baseTransactional, framedTransactional.getBaseGraph());
    Mockito.verify(mockModule, Mockito.times(2)).configure(Mockito.any(TransactionalGraph.class), Mockito.any(FramedGraphConfiguration.class));
}
Also used : Graph(com.tinkerpop.blueprints.Graph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) ReturnsArgumentAt(org.mockito.internal.stubbing.answers.ReturnsArgumentAt) Test(org.junit.Test)

Example 4 with ReturnsArgumentAt

use of org.mockito.internal.stubbing.answers.ReturnsArgumentAt in project frames by tinkerpop.

the class FramedGraphFactoryTest method testSubclassing.

@Test
public void testSubclassing() {
    MyFramedGraphFactory myFramedGraphFactory = new MyFramedGraphFactory(mockModule);
    Mockito.when(mockModule.configure(Mockito.any(Graph.class), Mockito.any(FramedGraphConfiguration.class))).then(new ReturnsArgumentAt(0));
    MyFramedGraph<Graph> create = myFramedGraphFactory.create(base);
    Assert.assertEquals(base, create.getBaseGraph());
}
Also used : Graph(com.tinkerpop.blueprints.Graph) TransactionalGraph(com.tinkerpop.blueprints.TransactionalGraph) ReturnsArgumentAt(org.mockito.internal.stubbing.answers.ReturnsArgumentAt) Test(org.junit.Test)

Aggregations

ReturnsArgumentAt (org.mockito.internal.stubbing.answers.ReturnsArgumentAt)4 Graph (com.tinkerpop.blueprints.Graph)2 TransactionalGraph (com.tinkerpop.blueprints.TransactionalGraph)2 Test (org.junit.Test)2 CommandDescription (fr.xephi.authme.command.CommandDescription)1 DefaultPermission (fr.xephi.authme.permission.DefaultPermission)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1