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"));
}
Aggregations