@Test public void createSupportZipFileTest() throws IOException { final NamespacedOpenShiftClient client = mock(NamespacedOpenShiftClient.class); final MixedOperation<Pod, PodList, DoneablePod, PodResource<Pod, DoneablePod>> pods = mock(mixedOperationType()); when(pods.list()).thenReturn(new PodList()); when(client.pods()).thenReturn(pods); final MixedOperation<BuildConfig, BuildConfigList, DoneableBuildConfig, BuildConfigResource<BuildConfig, DoneableBuildConfig, Void, Build>> bcs = mock( mixedOperationType()); when(bcs.list()).thenReturn(new BuildConfigList()); when(client.buildConfigs()).thenReturn(bcs); final MixedOperation<DeploymentConfig, DeploymentConfigList, DoneableDeploymentConfig, DeployableScalableResource<DeploymentConfig, DoneableDeploymentConfig>> dcs = mock( mixedOperationType()); when(dcs.list()).thenReturn(new DeploymentConfigList()); when(client.deploymentConfigs()).thenReturn(dcs); final MixedOperation<ConfigMap, ConfigMapList, DoneableConfigMap, Resource<ConfigMap, DoneableConfigMap>> cm = mock(mixedOperationType()); when(cm.list()).thenReturn(new ConfigMapList()); when(client.configMaps()).thenReturn(cm); final MixedOperation<ImageStreamTag, ImageStreamTagList, DoneableImageStreamTag, Resource<ImageStreamTag, DoneableImageStreamTag>> ist = mock( mixedOperationType()); final ImageStreamTagList istl = new ImageStreamTagList(); final List<ImageStreamTag> istList = new ArrayList<>(); final ImageStreamTag imageStreamTag = new ImageStreamTag(); imageStreamTag.setKind("ImageStreamTag"); final ObjectMeta objectMeta = new ObjectMeta(); objectMeta.setName("ImageStreamTag1"); imageStreamTag.setMetadata(objectMeta); istList.add(imageStreamTag); istl.setItems(istList); when(ist.list()).thenReturn(istl); when(client.imageStreamTags()).thenReturn(ist); final IntegrationHandler integrationHandler = mock(IntegrationHandler.class); when(integrationHandler.list(anyInt(), anyInt())).thenReturn(new EmptyListResult<IntegrationOverview>()); final IntegrationSupportHandler integrationSupportHandler = mock(IntegrationSupportHandler.class); final Logger log = mock(Logger.class); final SupportUtil supportUtil = new SupportUtil(client, integrationHandler, integrationSupportHandler, log); final Map<String, Boolean> configurationMap = new HashMap<>(ImmutableMap.of("int1", true, "int2", true)); final File output = supportUtil.createSupportZipFile(configurationMap, 1, 20); try (final ZipFile zip = new ZipFile(output)) { final ZipEntry imageStreamTag1 = zip.getEntry("descriptors/ImageStreamTag/ImageStreamTag1.YAML"); assertThat(imageStreamTag1).isNotNull(); AssertionsForClassTypes.assertThat(zip.getInputStream(imageStreamTag1)).hasContent(SupportUtil.YAML.dump(imageStreamTag)); } verify(log).info("Created Support file: {}", output); verifyZeroInteractions(log); }
public File createSupportZipFile(Map<String, Boolean> configurationMap, int page, int perPage) { File zipFile = null; try { zipFile = File.createTempFile("syndesis.", ".zip"); } catch (IOException e) { log.error("Error creating Support zip file", e); throw new WebApplicationException(e, 500); } try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(zipFile))) { addPlatformPodsLogs(os); addResourceDescriptors(os); addIntegrationsFiles(configurationMap, page, perPage, os); log.info("Created Support file: {}", zipFile); } catch (IOException e) { log.error("Error producing Support zip file", e); if (zipFile != null && !zipFile.delete()) { zipFile.deleteOnExit(); } throw new WebApplicationException(e, 500); } return zipFile; }
SupportUtil { public File createSupportZipFile(Map<String, Boolean> configurationMap, int page, int perPage) { File zipFile = null; try { zipFile = File.createTempFile("syndesis.", ".zip"); } catch (IOException e) { log.error("Error creating Support zip file", e); throw new WebApplicationException(e, 500); } try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(zipFile))) { addPlatformPodsLogs(os); addResourceDescriptors(os); addIntegrationsFiles(configurationMap, page, perPage, os); log.info("Created Support file: {}", zipFile); } catch (IOException e) { log.error("Error producing Support zip file", e); if (zipFile != null && !zipFile.delete()) { zipFile.deleteOnExit(); } throw new WebApplicationException(e, 500); } return zipFile; } }
SupportUtil { public File createSupportZipFile(Map<String, Boolean> configurationMap, int page, int perPage) { File zipFile = null; try { zipFile = File.createTempFile("syndesis.", ".zip"); } catch (IOException e) { log.error("Error creating Support zip file", e); throw new WebApplicationException(e, 500); } try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(zipFile))) { addPlatformPodsLogs(os); addResourceDescriptors(os); addIntegrationsFiles(configurationMap, page, perPage, os); log.info("Created Support file: {}", zipFile); } catch (IOException e) { log.error("Error producing Support zip file", e); if (zipFile != null && !zipFile.delete()) { zipFile.deleteOnExit(); } throw new WebApplicationException(e, 500); } return zipFile; } SupportUtil(NamespacedOpenShiftClient client, IntegrationHandler integrationHandler,
                IntegrationSupportHandler integrationSupportHandler, Logger log); @Autowired  SupportUtil(NamespacedOpenShiftClient client, IntegrationHandler integrationHandler,
                       IntegrationSupportHandler integrationSupportHandler); }
SupportUtil { public File createSupportZipFile(Map<String, Boolean> configurationMap, int page, int perPage) { File zipFile = null; try { zipFile = File.createTempFile("syndesis.", ".zip"); } catch (IOException e) { log.error("Error creating Support zip file", e); throw new WebApplicationException(e, 500); } try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(zipFile))) { addPlatformPodsLogs(os); addResourceDescriptors(os); addIntegrationsFiles(configurationMap, page, perPage, os); log.info("Created Support file: {}", zipFile); } catch (IOException e) { log.error("Error producing Support zip file", e); if (zipFile != null && !zipFile.delete()) { zipFile.deleteOnExit(); } throw new WebApplicationException(e, 500); } return zipFile; } SupportUtil(NamespacedOpenShiftClient client, IntegrationHandler integrationHandler,
                IntegrationSupportHandler integrationSupportHandler, Logger log); @Autowired  SupportUtil(NamespacedOpenShiftClient client, IntegrationHandler integrationHandler,
                       IntegrationSupportHandler integrationSupportHandler); File createSupportZipFile(Map<String, Boolean> configurationMap, int page, int perPage); Collection<String> getIntegrationPods(); Optional<Reader> getLogs(String label, String component); Optional<Reader> getIntegrationLogs(String integrationName); Optional<Reader> getComponentLogs(String componentName); static void dumpAsYaml(HasMetadata obj, OutputStream outputStream); }
SupportUtil { public File createSupportZipFile(Map<String, Boolean> configurationMap, int page, int perPage) { File zipFile = null; try { zipFile = File.createTempFile("syndesis.", ".zip"); } catch (IOException e) { log.error("Error creating Support zip file", e); throw new WebApplicationException(e, 500); } try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(zipFile))) { addPlatformPodsLogs(os); addResourceDescriptors(os); addIntegrationsFiles(configurationMap, page, perPage, os); log.info("Created Support file: {}", zipFile); } catch (IOException e) { log.error("Error producing Support zip file", e); if (zipFile != null && !zipFile.delete()) { zipFile.deleteOnExit(); } throw new WebApplicationException(e, 500); } return zipFile; } SupportUtil(NamespacedOpenShiftClient client, IntegrationHandler integrationHandler,
                IntegrationSupportHandler integrationSupportHandler, Logger log); @Autowired  SupportUtil(NamespacedOpenShiftClient client, IntegrationHandler integrationHandler,
                       IntegrationSupportHandler integrationSupportHandler); File createSupportZipFile(Map<String, Boolean> configurationMap, int page, int perPage); Collection<String> getIntegrationPods(); Optional<Reader> getLogs(String label, String component); Optional<Reader> getIntegrationLogs(String integrationName); Optional<Reader> getComponentLogs(String componentName); static void dumpAsYaml(HasMetadata obj, OutputStream outputStream); public Logger log; static final String COMPONENT_LABEL; }