RestModelImporter { public Client importClient(ImportableClient importable) { final Client client = mapper.fromImportable(importable); clientService.save(client); return client; } RestModelImporter(ImportModelMapper mapper, HardwareTypeService hardwareTypeService, ApplicationService applicationService, ClientService clientService, DeviceService deviceService, LocationService locationService, PrinterService printerService); Device importDevice(org.openthinclient.api.rest.model.Device importable); HardwareType importHardwareType(ImportableHardwareType importable); Printer importPrinter(org.openthinclient.api.rest.model.Printer importable); Location importLocation(ImportableLocation importable); Application importApplication(org.openthinclient.api.rest.model.Application importable); Client importClient(ImportableClient importable); Profile importProfileObject(AbstractProfileObject importable);  }
@Test public void testImportClient() throws Exception { final HardwareType hardwareType = new HardwareType(); hardwareType.setName("Some Type"); given(hardwareTypeService.findByName("Some Type")).willReturn(hardwareType); final Location location = new Location(); location.setName("location:UK"); given(locationService.findAll()).willReturn(Collections.singleton(location)); final ImportableClient importableClient = new ImportableClient(); importableClient.setMacAddress("00:80:41:ae:fd:7e"); importableClient.setHardwareType(new ProfileReference(ProfileType.HARDWARETYPE, "Some Type")); importableClient.setLocation(new ProfileReference(ProfileType.LOCATION, "location:UK")); final Client client = importer.importClient(importableClient); then(clientService).should().save(any()); assertSame(hardwareType, client.getHardwareType()); assertEquals("00:80:41:ae:fd:7e", client.getMacAddress()); assertEquals("location:UK", client.getLocation().getName()); }