Package com.calclab.suco.tests.ioc.decorator

Source Code of com.calclab.suco.tests.ioc.decorator.DecoratorTests

package com.calclab.suco.tests.ioc.decorator;

import static org.junit.Assert.assertSame;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import org.junit.Test;

import com.calclab.suco.client.ioc.Decorator;
import com.calclab.suco.client.ioc.Provider;
import com.calclab.suco.client.ioc.decorator.Chain;
import com.calclab.suco.client.ioc.decorator.Singleton;
import com.calclab.suco.tests.ioc.TestHelper;

public class DecoratorTests {

    @SuppressWarnings("unchecked")
    @Test
    public void testChain() {
  final Decorator d1 = mock(Decorator.class);
  final Decorator d2 = mock(Decorator.class);
  final Chain chain = new Chain(d1, d2);
  chain.decorate(null, null);
  verify(d1).decorate((Class) anyObject(), (Provider) anyObject());
    }

    @Test
    public void testSingleton() {
  final Provider<Object> scoped = Singleton.instance.decorate(Object.class, TestHelper.provider());
  assertSame(scoped.get(), scoped.get());
    }
}
TOP

Related Classes of com.calclab.suco.tests.ioc.decorator.DecoratorTests

TOP
Copyright © 2018 www.massapi.com. 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.