Search in sources :

Example 1 with LIST_CLIENTS

use of ee.ria.xroad.common.metadata.MetadataRequests.LIST_CLIENTS in project X-Road by nordic-institute.

the class MetadataClientRequestProcessorTest method shouldProcessListClients.

@Test
public void shouldProcessListClients() throws Exception {
    final List<MemberInfo> expectedMembers = Arrays.asList(createMember("producer", null), createMember("producer", "subsystem"), createMember("anothermemeber", null), createMember("anothermemeber", "somesub"), createMember("thirdmember", null));
    GlobalConf.reload(new TestSuiteGlobalConf() {

        @Override
        public List<MemberInfo> getMembers(String... instanceIdentifier) {
            String[] instances = instanceIdentifier;
            assertThat("Wrong Xroad instance in query", instances, arrayContaining(EXPECTED_XR_INSTANCE));
            return expectedMembers;
        }
    });
    MetadataClientRequestProcessor processorToTest = new MetadataClientRequestProcessor(LIST_CLIENTS, mockRequest, mockResponse);
    processorToTest.process();
    assertContentTypeIsIn(xmlUtf8ContentTypes());
    List<MemberInfo> members = unmarshaller.unmarshal(mockServletOutputStream.getResponseSource(), ClientListType.class).getValue().getMember().stream().map(clientType -> new MemberInfo(clientType.getId(), clientType.getName())).collect(Collectors.toList());
    assertThat("Wrong amount of clients", members.size(), is(expectedMembers.size()));
    assertThat("Wrong members", members, containsInAnyOrder(expectedMembers.toArray()));
}
Also used : Matchers.arrayContaining(org.hamcrest.Matchers.arrayContaining) Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) MetaserviceTestUtil.xmlUtf8ContentTypes(ee.ria.xroad.proxy.util.MetaserviceTestUtil.xmlUtf8ContentTypes) CentralServiceId(ee.ria.xroad.common.identifier.CentralServiceId) Enumeration(java.util.Enumeration) CentralServiceId.create(ee.ria.xroad.common.identifier.CentralServiceId.create) ObjectFactory(ee.ria.xroad.common.metadata.ObjectFactory) MetaserviceTestUtil(ee.ria.xroad.proxy.util.MetaserviceTestUtil) GlobalConf(ee.ria.xroad.common.conf.globalconf.GlobalConf) Assert.assertThat(org.junit.Assert.assertThat) HttpServletRequest(javax.servlet.http.HttpServletRequest) ArgumentCaptor(org.mockito.ArgumentCaptor) Is.is(org.hamcrest.core.Is.is) ExpectedException(org.junit.rules.ExpectedException) Matchers.isIn(org.hamcrest.Matchers.isIn) JAXBContext(javax.xml.bind.JAXBContext) Before(org.junit.Before) Unmarshaller(javax.xml.bind.Unmarshaller) HttpServletResponse(javax.servlet.http.HttpServletResponse) LIST_CENTRAL_SERVICES(ee.ria.xroad.common.metadata.MetadataRequests.LIST_CENTRAL_SERVICES) ClientListType(ee.ria.xroad.common.metadata.ClientListType) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) IOException(java.io.IOException) Mockito.when(org.mockito.Mockito.when) JAXBException(javax.xml.bind.JAXBException) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) KeyConf(ee.ria.xroad.proxy.conf.KeyConf) List(java.util.List) Rule(org.junit.Rule) MemberInfo(ee.ria.xroad.common.conf.globalconf.MemberInfo) CentralServiceListType(ee.ria.xroad.common.metadata.CentralServiceListType) TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Assert.assertFalse(org.junit.Assert.assertFalse) LIST_CLIENTS(ee.ria.xroad.common.metadata.MetadataRequests.LIST_CLIENTS) ClientId(ee.ria.xroad.common.identifier.ClientId) TestSuiteKeyConf(ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) TestSuiteGlobalConf(ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf) MemberInfo(ee.ria.xroad.common.conf.globalconf.MemberInfo) ClientListType(ee.ria.xroad.common.metadata.ClientListType) List(java.util.List) Test(org.junit.Test)

Aggregations

GlobalConf (ee.ria.xroad.common.conf.globalconf.GlobalConf)1 MemberInfo (ee.ria.xroad.common.conf.globalconf.MemberInfo)1 CentralServiceId (ee.ria.xroad.common.identifier.CentralServiceId)1 CentralServiceId.create (ee.ria.xroad.common.identifier.CentralServiceId.create)1 ClientId (ee.ria.xroad.common.identifier.ClientId)1 CentralServiceListType (ee.ria.xroad.common.metadata.CentralServiceListType)1 ClientListType (ee.ria.xroad.common.metadata.ClientListType)1 LIST_CENTRAL_SERVICES (ee.ria.xroad.common.metadata.MetadataRequests.LIST_CENTRAL_SERVICES)1 LIST_CLIENTS (ee.ria.xroad.common.metadata.MetadataRequests.LIST_CLIENTS)1 ObjectFactory (ee.ria.xroad.common.metadata.ObjectFactory)1 KeyConf (ee.ria.xroad.proxy.conf.KeyConf)1 TestSuiteGlobalConf (ee.ria.xroad.proxy.testsuite.TestSuiteGlobalConf)1 TestSuiteKeyConf (ee.ria.xroad.proxy.testsuite.TestSuiteKeyConf)1 MetaserviceTestUtil (ee.ria.xroad.proxy.util.MetaserviceTestUtil)1 MetaserviceTestUtil.xmlUtf8ContentTypes (ee.ria.xroad.proxy.util.MetaserviceTestUtil.xmlUtf8ContentTypes)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 Enumeration (java.util.Enumeration)1 List (java.util.List)1