• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2007 Mockito contributors
3  * This program is made available under the terms of the MIT License.
4  */
5 
6 package org.mockitousage;
7 
8 import org.junit.Test;
9 import org.mockito.Mock;
10 import org.mockitoutil.TestBase;
11 
12 public class PlaygroundTest extends TestBase {
13     static class Foo {
14 
doSomeThing()15         int doSomeThing() {
16             return 0;
17         }
18 
getStuff()19         protected String getStuff() {
20             return "foo";
21         }
22     }
23 
24     class Boo {
withLong(long y)25         final public Object withLong(long y) {
26                          return "";
27         }
28 
foo()29         public Object foo() {
30                    return "";
31         }
32     }
33 
34     Foo mock;
35     @Mock IMethods mockTwo;
36 
37     @Test
spyInAction()38     public void spyInAction() {
39 
40     }
41 
42     @Test
partialMockInAction()43     public void partialMockInAction() {
44 //        mock = mock(Foo.class, withSettings()
45 //            .defaultBehavior(CALLS_REAL_METHODS);
46 
47 //        mock = mock(Foo.class, withSettings()
48 //            .defaultMockAnswer(CALLS_REAL_METHODS);
49 
50 //        mock = mock(Foo.class, withSettings()
51 //            .defaultAnswer(CALLS_REAL_METHODS);
52 
53 //        mock = mock(Foo.class, CALLS_REAL_METHODS);
54 
55 //        mock = mock(Foo.class, withSettings()
56 //            .defaultBehavior(CALLS_REAL_METHODS)
57 //            .createUsingDefaultConstructor();
58 //
59 //        mock = mock(Foo.class, withSettings()
60 //            .defaultBehavior(CALLS_REAL_METHODS)
61 //            .createPassingArguments("some arg", 1);
62 //
63 //        spy = spy(Foo.class, "some arg", 1);
64 //
65 //            .withName("foo")
66 //            .withDefaultBehavior(RETURNS_SMART_NULLS)
67 //            .withInterfaces(Bar.class);
68 //
69 //        mock = mock(Foo.class)
70 //            .name("foo")
71 //            .defaultBehavior(RETURNS_SMART_NULLS)
72 //            .interfaces(Bar.class);
73 //
74 //        mock = mock(Foo.class)
75 //            .named("foo")
76 //            .byDefault(RETURNS_SMART_NULLS)
77 //            .alsoImplements(Bar.class, Bar2.class);
78 //
79 //        mock = mock(Foo.class)
80 //            hasName("foo");
81 
82 //        when(mock.getStuff()).thenReturn("aha!");
83 //        when(mock.doSomeThing()).thenCallRealMethod();
84 //
85 
86 //        mock.doSomeThing();
87     }
88 
89 //    interface Colored {
90 //
91 //    }
92 //
93 //    interface Bar {
94 //        <T extends Foo & Colored> T getColoredPoint();
95 //    }
96 //
97 //    @Test
98 //    public void testname() throws Exception {
99 //        when(mock.get()).then(returnArgument());
100 //
101 //        Bar mock = mock(Bar.class);
102 //        when(mock.getColoredPoint()).thenReturn(new Foo());
103 //    }
104 }
105