/** * Adds a new VNF software Image to the datacenter repository * * @param vimInstance : Image to add * @return datacenter: The datacenter filled with values from the core */ @ApiOperation( value = "Adding a Vim Instance", notes = "Takes a Vim Instance json in the request body") @RequestMapping( method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.CREATED) public BaseVimInstance create( @RequestBody @Valid BaseVimInstance vimInstance, @RequestHeader(value = "project-id") String projectId) throws VimException, PluginException, IOException, BadRequestException, ExecutionException, InterruptedException { return vimManagement.add(vimInstance, projectId).get(); }
@Test public void createVimInstance() throws VimException, PluginException, IOException, BadRequestException, AlreadyExistingException, ExecutionException, InterruptedException { OpenstackVimInstance datacenter = new OpenstackVimInstance(); datacenter.setId("123"); datacenter.setName("DC-1"); datacenter.setType("OpenStack"); datacenter.setUsername("datacenter_test"); datacenter.setTenant("tenant"); datacenter.setKeyPair("keypair"); datacenter.setPassword(""); when(mock.add(any(datacenter.getClass()), anyString())) .thenReturn(new AsyncResult<>(datacenter)); log.info("" + restVimInstances.create(datacenter, "pi")); BaseVimInstance datacenter2 = restVimInstances.create(datacenter, "pi"); assertEquals(datacenter, datacenter2); }