ImportExportService { public boolean importRepository(String json){ ObjectMapper mapper = new ObjectMapper(); ImportExportModel model = null; try{ model = mapper.readValue(json, ImportExportModel.class); } catch (Exception e){ log.error("Exception while reading json import", e); } if (log.isInfoEnabled()){ log.info("Retrieve " + model.getServices().size() + " services to import into repository"); log.info("Retrieve " + model.getResources().size() + " resources to import into repository"); log.info("Retrieve " + model.getResponses().size() + " responses to import into repository"); log.info("Retrieve " + model.getRequests().size() + " requests to import into repository"); } if (model != null){ serviceRepository.saveAll(model.getServices()); resourceRepository.saveAll(model.getResources()); responseRepository.saveAll(model.getResponses()); requestRepository.saveAll(model.getRequests()); return true; } return false; }  boolean importRepository(String json); String exportRepository(List<String> ids, String format);  }
@Test public void testImportRepository(){ String json = "{\"services\":[{\"name\":\"Imp1\",\"version\":\"1.2\",\"xmlNS\":null,\"type\":null,\"operations\":[],\"id\":25638445759706201468670970602}," + "{\"name\":\"Imp2\",\"version\":\"1.1\",\"xmlNS\":null,\"type\":null,\"operations\":[],\"id\":25638445759706201468670970603}], " + "\"resources\":[{\"name\":\"Resource 1\",\"content\":\"<wsdl></wsdl>\",\"type\":\"WSDL\",\"serviceId\":25638445759706201468670970602,\"id\":25638445759706201468670970605}], " + "\"requests\":[], \"responses\":[]}"; boolean result = service.importRepository(json); Service service = repository.findByNameAndVersion("Imp1", "1.2"); assertNotNull(service); assertEquals("Imp1", service.getName()); assertEquals("1.2", service.getVersion()); assertEquals("25638445759706201468670970602", service.getId().toString()); List<Resource> resources = resourceRepository.findByServiceId(service.getId()); assertEquals(1, resources.size()); assertEquals("Resource 1", resources.get(0).getName()); assertEquals("<wsdl></wsdl>", resources.get(0).getContent()); assertEquals(ResourceType.WSDL, resources.get(0).getType()); }