X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=restconf%2Fsal-rest-docgen%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Frest%2Fdoc%2FDocGenTestHelper.java;fp=restconf%2Fsal-rest-docgen%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Frest%2Fdoc%2FDocGenTestHelper.java;h=0000000000000000000000000000000000000000;hb=efa78a3a92d6d8162d0524467eacf2a0356396d7;hp=22317d9aecf7d298cf79595a2ddbe4992d13f54e;hpb=6b9d2cd4cea8044bfc83ce62ef93826a3430388a;p=netconf.git diff --git a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/netconf/sal/rest/doc/DocGenTestHelper.java b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/netconf/sal/rest/doc/DocGenTestHelper.java deleted file mode 100644 index 22317d9aec..0000000000 --- a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/netconf/sal/rest/doc/DocGenTestHelper.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.sal.rest.doc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.fasterxml.jackson.databind.JsonNode; -import java.net.URI; -import javax.ws.rs.core.UriBuilder; -import javax.ws.rs.core.UriInfo; -import org.mockito.ArgumentCaptor; - -public final class DocGenTestHelper { - - private DocGenTestHelper() { - // hidden on purpose - } - - public static UriInfo createMockUriInfo(final String urlPrefix) throws Exception { - final URI uri = new URI(urlPrefix); - final UriBuilder mockBuilder = mock(UriBuilder.class); - - final ArgumentCaptor subStringCapture = ArgumentCaptor.forClass(String.class); - when(mockBuilder.path(subStringCapture.capture())).thenReturn(mockBuilder); - when(mockBuilder.build()).then(invocation -> URI.create(uri + "/" + subStringCapture.getValue())); - - final UriInfo info = mock(UriInfo.class); - when(info.getRequestUriBuilder()).thenReturn(mockBuilder); - when(mockBuilder.replaceQuery(any())).thenReturn(mockBuilder); - when(info.getBaseUri()).thenReturn(uri); - - return info; - } - - /** - * Checks whether object {@code mainObject} contains in properties/items key $ref with concrete value. - */ - public static void containsReferences(final JsonNode mainObject, final String childObject, - final String expectedRef) { - final JsonNode properties = mainObject.get("properties"); - assertNotNull(properties); - - final JsonNode childNode = properties.get(childObject); - assertNotNull(childNode); - - //list case - JsonNode refWrapper = childNode.get("items"); - if (refWrapper == null) { - //container case - refWrapper = childNode; - } - assertEquals(expectedRef, refWrapper.get("$ref").asText()); - } -}