Package samples.simplemix

Examples of samples.simplemix.SimpleMix


public class SimpleMixTest {

    @PrepareForTest( { SimpleMixUtilities.class, SimpleMixCollaborator.class, SimpleMix.class })
    @Test
    public void staticPartialFinalMocking() throws Exception {
        SimpleMix tested = spy(new SimpleMix());

        when(tested, "getValue").thenReturn(0);
        SimpleMixCollaborator simpleMixCollaboratorMock = mock(SimpleMixCollaborator.class);
        mockStatic(SimpleMixUtilities.class);
        SimpleMixConstruction simpleMixConstructionMock = mock(SimpleMixConstruction.class);

        Whitebox.setInternalState(tested, simpleMixCollaboratorMock);

        when(SimpleMixUtilities.getRandomInteger()).thenReturn(10);
        when(simpleMixCollaboratorMock.getRandomInteger()).thenReturn(6);
        whenNew(SimpleMixConstruction.class).withNoArguments().thenReturn(simpleMixConstructionMock);
        when(simpleMixConstructionMock.getMyValue()).thenReturn(1);

        assertEquals(4, tested.calculate());

        verifyStatic();
        SimpleMixUtilities.getRandomInteger();
        verifyNew(SimpleMixConstruction.class).withNoArguments();
        verifyPrivate(tested).invoke(method(SimpleMix.class, "getValue"));
View Full Code Here


    }

    @PrepareForTest( { SimpleMix.class })
    @Test
    public void finalSystemClassMocking() throws Exception {
        SimpleMix tested = new SimpleMix();
        mockStatic(System.class);

        when(System.currentTimeMillis()).thenReturn(2000L);

        assertEquals(2, Whitebox.invokeMethod(tested, "getValue"));
View Full Code Here

    public final SimpleReturnExample simpleReturnExample() {
        return new SimpleReturnExample();
    }

    public final SimpleMix simpleMix() {
        return new SimpleMix();
    }
View Full Code Here

TOP

Related Classes of samples.simplemix.SimpleMix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.