Search in sources :

Example 1 with PluginContext

use of com.alipay.sofa.ark.spi.model.PluginContext in project sofa-ark by alipay.

the class OperationTransformerTest method testTransformUnstableState.

@Test
public void testTransformUnstableState() {
    Exception ex = null;
    try {
        List<Biz> bizList = new ArrayList<>();
        Biz biz1 = Mockito.mock(Biz.class);
        Biz biz2 = Mockito.mock(Biz.class);
        Biz biz3 = Mockito.mock(Biz.class);
        bizList.add(biz1);
        bizList.add(biz2);
        bizList.add(biz3);
        when(biz1.getBizName()).thenReturn("nameA");
        when(biz1.getBizVersion()).thenReturn("vA");
        when(biz1.getBizState()).thenReturn(BizState.ACTIVATED);
        when(biz1.getBizName()).thenReturn("nameA");
        when(biz1.getBizVersion()).thenReturn("vB");
        when(biz1.getBizState()).thenReturn(BizState.RESOLVED);
        when(biz1.getBizName()).thenReturn("nameB");
        when(biz1.getBizVersion()).thenReturn("vA");
        when(biz1.getBizState()).thenReturn(BizState.ACTIVATED);
        PluginContext pluginContext = Mockito.mock(PluginContext.class);
        ServiceReference serviceReference = Mockito.mock(ServiceReference.class);
        BizManagerService bizManagerService = Mockito.mock(BizManagerService.class);
        when(serviceReference.getService()).thenReturn(bizManagerService);
        when(pluginContext.referenceService(any(Class.class))).thenReturn(serviceReference);
        when(bizManagerService.getBizInOrder()).thenReturn(bizList);
        OperationTransformer.transformToBizOperation("nameA:vA:activated;nameA:vB:deactivated;nameB:vB:activated", pluginContext);
    } catch (Exception e) {
        ex = e;
    }
    Assert.assertNotNull(ex);
    Assert.assertTrue(ex.getMessage().contains("Exist illegal biz"));
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) PluginContext(com.alipay.sofa.ark.spi.model.PluginContext) ArrayList(java.util.ArrayList) BizManagerService(com.alipay.sofa.ark.spi.service.biz.BizManagerService) ServiceReference(com.alipay.sofa.ark.spi.registry.ServiceReference) Test(org.junit.Test)

Aggregations

Biz (com.alipay.sofa.ark.spi.model.Biz)1 PluginContext (com.alipay.sofa.ark.spi.model.PluginContext)1 ServiceReference (com.alipay.sofa.ark.spi.registry.ServiceReference)1 BizManagerService (com.alipay.sofa.ark.spi.service.biz.BizManagerService)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1