@@ -0,0 +1,3123 @@
+package org.ow2.chameleon.fuchsia.core.component.manager.test;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0Aimport org.mockito.MockitoAnnotations;%0Aimport org.osgi.framework.*;%0Aimport org.ow2.chameleon.fuchsia.core.component.manager.DeclarationBinder;%0Aimport org.ow2.chameleon.fuchsia.core.component.manager.LinkerManagement;%0Aimport org.ow2.chameleon.fuchsia.core.declaration.Declaration;%0Aimport org.ow2.chameleon.fuchsia.core.declaration.ImportDeclaration;%0Aimport org.ow2.chameleon.fuchsia.core.declaration.ImportDeclarationBuilder;%0Aimport org.ow2.chameleon.fuchsia.core.exceptions.BinderException;%0Aimport org.ow2.chameleon.fuchsia.core.exceptions.InvalidFilterException;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.assertj.core.api.Assertions.fail;%0Aimport static org.mockito.Mockito.*;%0Aimport static org.ow2.chameleon.fuchsia.core.component.manager.DeclarationBinder.TARGET_FILTER_PROPERTY;%0A%0Apublic class LinkerManagementTest %7B%0A%0A    @Mock%0A    BundleContext bundleContext;%0A%0A    @Before%0A    public void setUp() %7B%0A        MockitoAnnotations.initMocks(this); //initialize the object with mocks annotations%0A    %7D%0A%0A    @After%0A    public void tearDown() %7B%0A%0A    %7D%0A%0A    @Test%0A    public void testInstantiation() %7B%0A        Filter filterD = null, filterDB = null;%0A        try %7B%0A            filterD = FrameworkUtil.createFilter(%22(id=dec1)%22);%0A            filterDB = FrameworkUtil.createFilter(%22(instance.name=myDB)%22);%0A        %7D catch (InvalidSyntaxException e) %7B%0A            fail(%22%22, e);%0A        %7D%0A        assertThat(filterD).isNotNull();%0A        assertThat(filterDB).isNotNull();%0A        LinkerManagement%3CDeclaration, DeclarationBinder%3CDeclaration%3E%3E lm = new LinkerManagement%3CDeclaration, DeclarationBinder%3CDeclaration%3E%3E(bundleContext, filterD, filterDB);%0A%0A        ImportDeclaration dec = ImportDeclarationBuilder.empty().key(%22id%22).value(%22dec1%22).key(%22field%22).value(%22imyourtarget%22).build();%0A        ServiceReference decSRef = mock(ServiceReference.class);%0A        when(bundleContext.getService(decSRef)).thenReturn(dec);%0A        lm.declarationsManager.add(decSRef);%0A%0A%0A        ServiceReference bSRef = mock(ServiceReference.class);%0A        when(bSRef.getPropertyKeys()).thenReturn(new String%5B%5D%7B%22instance.name%22, TARGET_FILTER_PROPERTY%7D);%0A        when(bSRef.getProperty(%22instance.name%22)).thenReturn(%22myDB%22);%0A        when(bSRef.getProperty(TARGET_FILTER_PROPERTY)).thenReturn(%22(field=imyourtarget)%22);%0A        DeclarationBinder db = mock(DeclarationBinder.class);%0A%0A        when(bundleContext.getService(bSRef)).thenReturn(db);%0A        try %7B%0A            lm.bindersManager.add(bSRef);%0A        %7D catch (InvalidFilterException e) %7B%0A            fail(%22%22, e);%0A        %7D%0A        assertThat(lm.canBeLinked(dec, bSRef)).isTrue();%0A        lm.link(dec, bSRef);%0A        try %7B%0A            verify(db).addDeclaration(dec);%0A        %7D catch (BinderException e) %7B%0A            fail(%22%22, e);%0A        %7D%0A%0A        lm.unlink(dec, bSRef);%0A        try %7B%0A            verify(db).removeDeclaration(dec);%0A        %7D catch (BinderException e) %7B%0A            fail(%22%22, e);%0A        %7D%0A    %7D%0A%7D%0A

Add test for LinkerManagement