diff options
author | Fiete Ostkamp <Fiete.Ostkamp@telekom.de> | 2023-08-03 13:20:28 +0000 |
---|---|---|
committer | Fiete Ostkamp <fiete.ostkamp@telekom.de> | 2023-08-04 11:32:22 +0000 |
commit | 31f3d128576a7d2a4be206b6f8ba705e4939b98a (patch) | |
tree | 00a046d528934f0ce12edb63cb4a579719ca663c /aai-core/src/test | |
parent | 0acfcc99f3560eb78d8c912408e09df68cffde7f (diff) |
Make URIParser code more readable
Issue-ID: AAI-3655
Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de>
Change-Id: I26350e7279287c711f38194dbc1e8d302cf9a26d
Diffstat (limited to 'aai-core/src/test')
-rw-r--r-- | aai-core/src/test/java/org/onap/aai/parsers/uri/URIParserTest.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIParserTest.java b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIParserTest.java index 111772d2..74914cce 100644 --- a/aai-core/src/test/java/org/onap/aai/parsers/uri/URIParserTest.java +++ b/aai-core/src/test/java/org/onap/aai/parsers/uri/URIParserTest.java @@ -22,23 +22,42 @@ package org.onap.aai.parsers.uri; import static org.hamcrest.Matchers.hasProperty; import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.inOrder; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.io.UnsupportedEncodingException; import java.net.URI; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; import javax.annotation.PostConstruct; +import javax.ws.rs.core.MultivaluedHashMap; import javax.ws.rs.core.UriBuilder; import javax.xml.bind.JAXBException; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.mockito.ArgumentCaptor; +import org.mockito.InOrder; import org.onap.aai.AAISetup; +import org.onap.aai.edges.enums.EdgeType; import org.onap.aai.exceptions.AAIException; +import org.onap.aai.introspection.Introspector; import org.onap.aai.introspection.Loader; import org.onap.aai.introspection.ModelType; +import org.onap.aai.introspection.exceptions.AAIUnknownObjectException; import org.onap.aai.setup.SchemaVersion; + public class URIParserTest extends AAISetup { private Loader loader; @@ -112,4 +131,26 @@ public class URIParserTest extends AAISetup { new URIToDBKey(loader, uri); } + + @Test + public void verifyParsableInvokation() throws UnsupportedEncodingException, AAIException { + ArgumentCaptor<Introspector> cloudInfrastructureArgument = ArgumentCaptor.forClass(Introspector.class); + ArgumentCaptor<Introspector> containersArgument = ArgumentCaptor.forClass(Introspector.class); + ArgumentCaptor<Introspector> objectArgument = ArgumentCaptor.forClass(Introspector.class); + URI uri = UriBuilder.fromPath("cloud-infrastructure/complexes/complex/key1/ctag-pools/ctag-pool/key2/key3") + .build(); + Parsable parsable = mock(Parsable.class); + + URIParser uriParser = new URIParser(loader, uri); + uriParser.parse(parsable); + + verify(parsable).processNamespace(cloudInfrastructureArgument.capture()); + verify(parsable, times(2)).processContainer(containersArgument.capture(),eq(EdgeType.TREE),eq(new MultivaluedHashMap<>()),eq(false)); + verify(parsable, times(2)).processObject(objectArgument.capture(),eq(EdgeType.TREE),eq(new MultivaluedHashMap<>())); + assertEquals("cloud-infrastructure", cloudInfrastructureArgument.getValue().getName()); + assertEquals("complexes", containersArgument.getAllValues().get(0).getName()); + assertEquals("ctag-pools", containersArgument.getAllValues().get(1).getName()); + assertEquals("complex", objectArgument.getAllValues().get(0).getName()); + assertEquals("ctag-pool", objectArgument.getAllValues().get(1).getName()); + } } |