Search in sources :

Example 1 with DiscoveryManager

use of org.apache.servicecomb.registry.DiscoveryManager in project java-chassis by ServiceComb.

the class TestConsumers method deleteWhenCreateMicroserviceVersion.

@Test
public void deleteWhenCreateMicroserviceVersion() {
    new MockUp<DiscoveryManager>() {

        @Mock
        public Microservice getMicroservice(String microserviceId) {
            return null;
        }
    };
    try (LogCollector collector = new LogCollector()) {
        appManager.getOrCreateMicroserviceVersionRule(appId, serviceName, versionRule);
        Assert.assertEquals(0, microserviceManager.getVersionsByName().size());
        Assert.assertThat(collector.getEvents().stream().filter(e -> e.getThrowableInformation() != null).map(e -> e.getThrowableInformation().getThrowable().getMessage()).toArray(), Matchers.hasItemInArray("failed to query by microserviceId '002' from ServiceCenter."));
    }
}
Also used : LogCollector(org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector) Arrays(java.util.Arrays) LogCollector(org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector) MockUp(mockit.MockUp) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) MicroserviceKey(org.apache.servicecomb.registry.api.MicroserviceKey) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) DiscoveryManager(org.apache.servicecomb.registry.DiscoveryManager) MicroserviceInstanceChangedEvent(org.apache.servicecomb.registry.api.event.MicroserviceInstanceChangedEvent) MicroserviceVersion(org.apache.servicecomb.registry.consumer.MicroserviceVersion) After(org.junit.After) MicroserviceVersions(org.apache.servicecomb.registry.consumer.MicroserviceVersions) Mock(mockit.Mock) RegistrationManager(org.apache.servicecomb.registry.RegistrationManager) Microservice(org.apache.servicecomb.registry.api.registry.Microservice) MicroserviceVersionRule(org.apache.servicecomb.registry.consumer.MicroserviceVersionRule) Assert(org.junit.Assert) Before(org.junit.Before) MockUp(mockit.MockUp) Test(org.junit.Test)

Example 2 with DiscoveryManager

use of org.apache.servicecomb.registry.DiscoveryManager in project incubator-servicecomb-java-chassis by apache.

the class TestConsumers method deleteWhenCreateMicroserviceVersion.

@Test
public void deleteWhenCreateMicroserviceVersion() {
    new MockUp<DiscoveryManager>() {

        @Mock
        public Microservice getMicroservice(String microserviceId) {
            return null;
        }
    };
    try (LogCollector collector = new LogCollector()) {
        appManager.getOrCreateMicroserviceVersionRule(appId, serviceName, versionRule);
        Assert.assertEquals(0, microserviceManager.getVersionsByName().size());
        Assert.assertThat(collector.getEvents().stream().filter(e -> e.getThrowableInformation() != null).map(e -> e.getThrowableInformation().getThrowable().getMessage()).toArray(), Matchers.hasItemInArray("failed to query by microserviceId '002' from ServiceCenter."));
    }
}
Also used : LogCollector(org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector) Arrays(java.util.Arrays) LogCollector(org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector) MockUp(mockit.MockUp) MicroserviceInstance(org.apache.servicecomb.registry.api.registry.MicroserviceInstance) MicroserviceKey(org.apache.servicecomb.registry.api.MicroserviceKey) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) DiscoveryManager(org.apache.servicecomb.registry.DiscoveryManager) MicroserviceInstanceChangedEvent(org.apache.servicecomb.registry.api.event.MicroserviceInstanceChangedEvent) MicroserviceVersion(org.apache.servicecomb.registry.consumer.MicroserviceVersion) After(org.junit.After) MicroserviceVersions(org.apache.servicecomb.registry.consumer.MicroserviceVersions) Mock(mockit.Mock) RegistrationManager(org.apache.servicecomb.registry.RegistrationManager) Microservice(org.apache.servicecomb.registry.api.registry.Microservice) MicroserviceVersionRule(org.apache.servicecomb.registry.consumer.MicroserviceVersionRule) Assert(org.junit.Assert) Before(org.junit.Before) MockUp(mockit.MockUp) Test(org.junit.Test)

Aggregations

Arrays (java.util.Arrays)2 Mock (mockit.Mock)2 MockUp (mockit.MockUp)2 LogCollector (org.apache.servicecomb.foundation.test.scaffolding.log.LogCollector)2 DiscoveryManager (org.apache.servicecomb.registry.DiscoveryManager)2 RegistrationManager (org.apache.servicecomb.registry.RegistrationManager)2 MicroserviceKey (org.apache.servicecomb.registry.api.MicroserviceKey)2 MicroserviceInstanceChangedEvent (org.apache.servicecomb.registry.api.event.MicroserviceInstanceChangedEvent)2 Microservice (org.apache.servicecomb.registry.api.registry.Microservice)2 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)2 MicroserviceVersion (org.apache.servicecomb.registry.consumer.MicroserviceVersion)2 MicroserviceVersionRule (org.apache.servicecomb.registry.consumer.MicroserviceVersionRule)2 MicroserviceVersions (org.apache.servicecomb.registry.consumer.MicroserviceVersions)2 Matchers (org.hamcrest.Matchers)2 After (org.junit.After)2 Assert (org.junit.Assert)2 Before (org.junit.Before)2 Test (org.junit.Test)2