Skip to content

Commit

Permalink
🎨 Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vignaudo committed Jul 16, 2024
1 parent 10a6a51 commit 8856a32
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
*/
package com.ubiqube.etsi.mano.service.vim;

import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;

import org.junit.jupiter.api.Test;

@SuppressWarnings("static-method")
class DefaultQuotasTest {

@Test
void test() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, SecurityException, IllegalArgumentException, InstantiationException, IntrospectionException {
void test() {
TestBean.testClass(DefaultQuotas.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,11 @@ public static void testClass(final Class clazz) {
final PropertyDescriptor[] props = beanInfo.getPropertyDescriptors();
testObject(obj, props);
} catch (final InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException | IntrospectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

private static void testObject(final Object obj, final PropertyDescriptor[] props) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, SecurityException, IllegalArgumentException {
private static void testObject(final Object obj, final PropertyDescriptor[] props) throws IllegalAccessException, InvocationTargetException, SecurityException, IllegalArgumentException {
for (final PropertyDescriptor propertyDescriptor : props) {
final Method mr = propertyDescriptor.getReadMethod();
if (null != mr) {
Expand All @@ -51,7 +50,7 @@ private static void testObject(final Object obj, final PropertyDescriptor[] prop
if ((null != mw) && (null != mr)) {
final Class<?> ret = mr.getReturnType();
if (Modifier.isAbstract(ret.getModifiers())) {
// continue;
// continue
}
mw.invoke(obj, createType(ret));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ void testDeletePortTuple(final WireMockRuntimeInfo wmRuntimeInfo) {
final SystemConnections vimConn = createConn();
vimConn.setExtra(Map.of());
vimConn.getInterfaceInfo().setSdnEndpoint(wmRuntimeInfo.getHttpBaseUrl());
final Classifier clas = new Classifier();
srv.deletePortTuple(vimConn, "");
assertTrue(true);
}
Expand All @@ -111,7 +110,6 @@ void testDeleteServiceTemplate(final WireMockRuntimeInfo wmRuntimeInfo) {
final ContrailApi srv = new ContrailApi();
final SystemConnections vimConn = createConn();
vimConn.getInterfaceInfo().setSdnEndpoint(wmRuntimeInfo.getHttpBaseUrl());
final Classifier clas = new Classifier();
srv.deleteServiceTemplate(vimConn, "");
assertTrue(true);
}
Expand All @@ -122,7 +120,6 @@ void testDeleteServiceInstance(final WireMockRuntimeInfo wmRuntimeInfo) {
final SystemConnections vimConn = createConn();
vimConn.setExtra(Map.of());
vimConn.getInterfaceInfo().setSdnEndpoint(wmRuntimeInfo.getHttpBaseUrl());
final Classifier clas = new Classifier();
srv.deleteServiceInstance(vimConn, "");
assertTrue(true);
}
Expand All @@ -133,7 +130,6 @@ void testDeleteNetworkPolicy(final WireMockRuntimeInfo wmRuntimeInfo) {
final SystemConnections vimConn = createConn();
vimConn.setExtra(Map.of());
vimConn.getInterfaceInfo().setSdnEndpoint(wmRuntimeInfo.getHttpBaseUrl());
final Classifier clas = new Classifier();
srv.deleteNetworkPolicy(vimConn, "");
assertTrue(true);
}
Expand All @@ -143,7 +139,6 @@ void testRollbackWmi(final WireMockRuntimeInfo wmRuntimeInfo) {
final ContrailApi srv = new ContrailApi();
final SystemConnections vimConn = createConn();
vimConn.getInterfaceInfo().setSdnEndpoint(wmRuntimeInfo.getHttpBaseUrl());
final Classifier clas = new Classifier();
srv.rollbackVmi(vimConn, "");
assertTrue(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public ContrailTest() {
vimConnectionInformation = new SystemConnections<>();
vimConnectionInformation.setAccessInfo(new KeystoneAuthV3());
vimConnectionInformation.setInterfaceInfo(new InterfaceInfo());
// vimConnectionInformation.getInterfaceInfo().put("endpoint",
// "http://192.168.1.36:8082");
vimConnectionInformation.getInterfaceInfo().setSdnEndpoint("https://10.242.228.221:8082");
vimConnectionInformation.getInterfaceInfo().setEndpoint("https://10.242.228.250:5000/v3");
vimConnectionInformation.setAccessInfo(KeystoneAuthV3.builder()
Expand Down Expand Up @@ -154,8 +152,6 @@ void createIpamTest() throws IOException {
subnets.add(ipt);
executeCreate(root);
LOG.info("Done crating ipam.");

// conn.update(root);
}

void deleteIpam() throws IOException {
Expand All @@ -169,8 +165,6 @@ void createVirtualNetworkTest() throws IOException {
final VirtualNetwork root = new VirtualNetwork();
root.setDisplayName("ovi display name");
root.setName("ovi-vl");
// final NetworkIpam ipam = (NetworkIpam) conn.findById(NetworkIpam.class,
// "8e2e057c-204f-499c-9782-0367e0bc0aa1");
final NetworkIpam ipam = new NetworkIpam();
ipam.setName("ovi-ipam-name");
final List<IpamSubnetType> subnets = new ArrayList<>();
Expand All @@ -184,7 +178,6 @@ void createVirtualNetworkTest() throws IOException {
}

void createVirtualMachineInterfaceTest() throws IOException {
final ApiConnector conn = getConnection();
final VirtualMachineInterface root = new VirtualMachineInterface();
root.setName("vmi-ovi");
root.setDisplayName("VirtMacInt-OVI");
Expand Down Expand Up @@ -239,7 +232,6 @@ void deletePortTuple() {
final PortTuple pt = new PortTuple();
final Project prj = new Project();
prj.setName("admin");
// pt.setParent(prj);
pt.setUuid("edf523f2-8237-4fa3-9bdd-0ad43a8d6d08");
cf.delete(vimConnectionInformation, pt);
}
Expand Down Expand Up @@ -289,7 +281,7 @@ void testApiServiceInstance() {
}

@Test
void testName() throws Exception {
void testName() {
assertTrue(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class LinkTest {

@Test
void testName() throws Exception {
void testName() {
final List<PairsVl> ports = Arrays.asList(new PairsVl("A", "B"),
new PairsVl("C", "D"),
new PairsVl("E", "F"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ void dummyTest() {
assertTrue(true);
}

void testName() throws Exception {
void testName() {
final HelmV3WrapperClient cli = new HelmV3WrapperClient();
final File file = new File("/home/olivier/Downloads/helm/wordpress-0.1.tgz");
final Servers server = createServers();
final K8sServers k8s = createK8s();
cli.deploy(server, k8s, file, "deployement-name");
}

void testUninstall() throws Exception {
void testUninstall() {
final HelmV3WrapperClient cli = new HelmV3WrapperClient();
final Servers server = createServers();
final K8sServers k8s = createK8s();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ public T edit(final Visitor... visitors) {

@Override
public <V> T edit(final Class<V> visitorType, final Visitor<V> visitor) {
// TODO Auto-generated method stub
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void allocateResources(final VimConnectionInformation vimConnectionInform

@Override
public void freeResources(final VimConnectionInformation vimConnectionInformation, final String grantInformation) {
// TODO Auto-generated method stub
// XXX Auto-generated method stub

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void testCreateSecurityRule(final WireMockRuntimeInfo wri) {
.withBody(OsHelper.getFile(wri, "/security-group-rules-create.json"))));
final SecurityGroup sg = new SecurityGroup();
sg.setDirection("ingress");
// sg.setEtherType("");
// sg.setEtherType("")
sg.setPortRangeMin(80);
sg.setPortRangeMax(80);
sg.setProtocol("TCP");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static org.mockito.Mockito.when;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -63,8 +62,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ubiqube.etsi.mano.dao.mano.common.NicType;
import com.ubiqube.etsi.mano.dao.mano.vim.ContainerFormatType;
Expand Down Expand Up @@ -98,7 +95,7 @@ public class OpenStackTest {

private final UUID id;

public OpenStackTest() throws JsonParseException, JsonMappingException, FileNotFoundException, IOException {
public OpenStackTest() throws IOException {
final ObjectMapper desMapper = new ObjectMapper();
vimConnectionInformation = desMapper.readValue(new FileInputStream("src/test/resources/vim-connection/openstack.json"), OpenStakVimConnection.class);
id = UUID.randomUUID();
Expand Down Expand Up @@ -250,7 +247,7 @@ public void uploadSoftwareImageTest() {
assertNotNull(lid);
}

void testFlavorGet() throws Exception {
void testFlavorGet() {
final OpenStackVim vim = createOsVim();
when(vimJpa.findById(id)).thenReturn(Optional.ofNullable(vimConnectionInformation));

Expand All @@ -262,7 +259,7 @@ void testFlavorGet() throws Exception {
assertNotNull(lid);
}

void testCompute() throws Exception {
void testCompute() {
final OpenStackVim vim = createOsVim();
when(vimJpa.findById(id)).thenReturn(Optional.ofNullable(vimConnectionInformation));

Expand Down Expand Up @@ -513,19 +510,20 @@ void testGnochhiCreate() {
assertNotNull(os);
}

void testGnocchiDelete() throws Exception {
void testGnocchiDelete() {
final OSClientV3 os = getWallabyConnection();
os.telemetry().gnocchi().metrics().delete("7856e791-c918-4f72-814c-b3f18127190b");
assertNotNull(os);
}

void testServerGroup() throws Exception {
void testServerGroup() {
final OSClientV3 os = getWallabyConnection();
final org.openstack4j.model.compute.ServerGroup res = os.compute().serverGroups().create(UUID.randomUUID().toString(), "affinity");
assertNotNull(res);
assertNotNull(os);
}

void testSecurityGroup() throws Exception {
void testSecurityGroup() {
final SecurityGroup sg = new SecurityGroup();
sg.setDirection("ingress");
sg.setEtherType("ipv4");
Expand All @@ -542,7 +540,7 @@ void testSecurityGroup() throws Exception {
.protocol(sg.getProtocol())
.securityGroupId(sg.getToscaName())
.build();
// final SecurityGroupRule res = os.networking().securityrule().create(group);
assertNotNull(group);
final org.openstack4j.model.network.SecurityGroup securityGroup = Builders.securityGroup()
.name("security")
.build();
Expand Down Expand Up @@ -623,11 +621,13 @@ void testNetworkList() {
void testCreatePort() {
final OpenStackVim vim = createOsVim();
final com.ubiqube.etsi.mano.service.vim.Port port = vim.network(vciInari).createPort("testname", "0dc0e07c-0eae-4c55-9b28-13bb909a9d94", "0f33bd64-5c7c-46f8-8f71-563ec7fc4689", null, NicType.NORMAL);
assertNotNull(port);
}

@Test
void testUserInfo() {
final OpenStackVim vim = createOsVim();
vim.authenticate(vciInari);
assertNotNull(vim);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package com.ubiqube.etsi.mano.service.vim;

import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
Expand Down Expand Up @@ -55,6 +57,7 @@ public static VimConnectionInformation createServer(final WireMockRuntimeInfo wm
.build())
.authType(List.of(AuthType.BASIC))
.build();
assertNotNull(auth);
final VimConnectionInformation vci = new VimConnectionInformation();
vci.setId(UUID.randomUUID());
vci.setVimId(vci.getId().toString());
Expand Down

0 comments on commit 8856a32

Please sign in to comment.