@Test public void getWorkspaceRequestBody() { final String requestBody = createWorkspaceBody(invalidCreateWorkspaceInputs, DELIMITER); assertEquals(EXPECTED_WORKSPACE_REQUEST_BODY, requestBody); }
@NotNull public static String createWorkspaceBody(TerraformWorkspaceInputs createWorkspaceInputs, String delimiter) { String requestBody = EMPTY; final List<String> triggerPrefixesList = new ArrayList<>(); ObjectMapper createWorkspaceMapper = new ObjectMapper(); CreateWorkspaceRequestBody createBody = new CreateWorkspaceRequestBody(); CreateWorkspaceRequestBody.CreateWorkspaceData createWorkspaceData = createBody.new CreateWorkspaceData(); CreateWorkspaceRequestBody.Attributes attributes = createBody.new Attributes(); attributes.setName(createWorkspaceInputs.getWorkspaceName()); attributes.setTerraform_version(createWorkspaceInputs.getCommonInputs().getTerraformVersion()); attributes.setDescription(createWorkspaceInputs.getWorkspaceDescription()); attributes.setAutoApply(Boolean.parseBoolean(createWorkspaceInputs.getAutoApply())); attributes.setFileTriggersEnabled(Boolean.parseBoolean(createWorkspaceInputs.getFileTriggersEnabled())); attributes.setWorkingDirectory(createWorkspaceInputs.getWorkingDirectory()); attributes.setQueueAllRuns(Boolean.parseBoolean(createWorkspaceInputs.getQueueAllRuns())); attributes.setSpeculativeEnabled(Boolean.parseBoolean(createWorkspaceInputs.getSpeculativeEnabled())); String[] triggerPrefixes = createWorkspaceInputs.getTriggerPrefixes().split(delimiter); Collections.addAll(triggerPrefixesList, triggerPrefixes); attributes.setTriggerPrefixes(triggerPrefixesList); CreateWorkspaceRequestBody.VCSRepo vcsRepo = createBody.new VCSRepo(); vcsRepo.setIdentifier(createWorkspaceInputs.getVcsRepoId()); vcsRepo.setOauthTokenId(createWorkspaceInputs.getOauthTokenId()); vcsRepo.setBranch(createWorkspaceInputs.getVcsBranch()); vcsRepo.setIngressSubmodules(Boolean.parseBoolean(createWorkspaceInputs.getIngressSubmodules())); attributes.setVcsRepo(vcsRepo); createWorkspaceData.setAttributes(attributes); createWorkspaceData.setType(WORKSPACE_TYPE); createBody.setData(createWorkspaceData); try { requestBody = createWorkspaceMapper.writeValueAsString(createBody); } catch (JsonProcessingException e) { e.printStackTrace(); } return requestBody; }
WorkspaceImpl { @NotNull public static String createWorkspaceBody(TerraformWorkspaceInputs createWorkspaceInputs, String delimiter) { String requestBody = EMPTY; final List<String> triggerPrefixesList = new ArrayList<>(); ObjectMapper createWorkspaceMapper = new ObjectMapper(); CreateWorkspaceRequestBody createBody = new CreateWorkspaceRequestBody(); CreateWorkspaceRequestBody.CreateWorkspaceData createWorkspaceData = createBody.new CreateWorkspaceData(); CreateWorkspaceRequestBody.Attributes attributes = createBody.new Attributes(); attributes.setName(createWorkspaceInputs.getWorkspaceName()); attributes.setTerraform_version(createWorkspaceInputs.getCommonInputs().getTerraformVersion()); attributes.setDescription(createWorkspaceInputs.getWorkspaceDescription()); attributes.setAutoApply(Boolean.parseBoolean(createWorkspaceInputs.getAutoApply())); attributes.setFileTriggersEnabled(Boolean.parseBoolean(createWorkspaceInputs.getFileTriggersEnabled())); attributes.setWorkingDirectory(createWorkspaceInputs.getWorkingDirectory()); attributes.setQueueAllRuns(Boolean.parseBoolean(createWorkspaceInputs.getQueueAllRuns())); attributes.setSpeculativeEnabled(Boolean.parseBoolean(createWorkspaceInputs.getSpeculativeEnabled())); String[] triggerPrefixes = createWorkspaceInputs.getTriggerPrefixes().split(delimiter); Collections.addAll(triggerPrefixesList, triggerPrefixes); attributes.setTriggerPrefixes(triggerPrefixesList); CreateWorkspaceRequestBody.VCSRepo vcsRepo = createBody.new VCSRepo(); vcsRepo.setIdentifier(createWorkspaceInputs.getVcsRepoId()); vcsRepo.setOauthTokenId(createWorkspaceInputs.getOauthTokenId()); vcsRepo.setBranch(createWorkspaceInputs.getVcsBranch()); vcsRepo.setIngressSubmodules(Boolean.parseBoolean(createWorkspaceInputs.getIngressSubmodules())); attributes.setVcsRepo(vcsRepo); createWorkspaceData.setAttributes(attributes); createWorkspaceData.setType(WORKSPACE_TYPE); createBody.setData(createWorkspaceData); try { requestBody = createWorkspaceMapper.writeValueAsString(createBody); } catch (JsonProcessingException e) { e.printStackTrace(); } return requestBody; } }
WorkspaceImpl { @NotNull public static String createWorkspaceBody(TerraformWorkspaceInputs createWorkspaceInputs, String delimiter) { String requestBody = EMPTY; final List<String> triggerPrefixesList = new ArrayList<>(); ObjectMapper createWorkspaceMapper = new ObjectMapper(); CreateWorkspaceRequestBody createBody = new CreateWorkspaceRequestBody(); CreateWorkspaceRequestBody.CreateWorkspaceData createWorkspaceData = createBody.new CreateWorkspaceData(); CreateWorkspaceRequestBody.Attributes attributes = createBody.new Attributes(); attributes.setName(createWorkspaceInputs.getWorkspaceName()); attributes.setTerraform_version(createWorkspaceInputs.getCommonInputs().getTerraformVersion()); attributes.setDescription(createWorkspaceInputs.getWorkspaceDescription()); attributes.setAutoApply(Boolean.parseBoolean(createWorkspaceInputs.getAutoApply())); attributes.setFileTriggersEnabled(Boolean.parseBoolean(createWorkspaceInputs.getFileTriggersEnabled())); attributes.setWorkingDirectory(createWorkspaceInputs.getWorkingDirectory()); attributes.setQueueAllRuns(Boolean.parseBoolean(createWorkspaceInputs.getQueueAllRuns())); attributes.setSpeculativeEnabled(Boolean.parseBoolean(createWorkspaceInputs.getSpeculativeEnabled())); String[] triggerPrefixes = createWorkspaceInputs.getTriggerPrefixes().split(delimiter); Collections.addAll(triggerPrefixesList, triggerPrefixes); attributes.setTriggerPrefixes(triggerPrefixesList); CreateWorkspaceRequestBody.VCSRepo vcsRepo = createBody.new VCSRepo(); vcsRepo.setIdentifier(createWorkspaceInputs.getVcsRepoId()); vcsRepo.setOauthTokenId(createWorkspaceInputs.getOauthTokenId()); vcsRepo.setBranch(createWorkspaceInputs.getVcsBranch()); vcsRepo.setIngressSubmodules(Boolean.parseBoolean(createWorkspaceInputs.getIngressSubmodules())); attributes.setVcsRepo(vcsRepo); createWorkspaceData.setAttributes(attributes); createWorkspaceData.setType(WORKSPACE_TYPE); createBody.setData(createWorkspaceData); try { requestBody = createWorkspaceMapper.writeValueAsString(createBody); } catch (JsonProcessingException e) { e.printStackTrace(); } return requestBody; }  }
WorkspaceImpl { @NotNull public static String createWorkspaceBody(TerraformWorkspaceInputs createWorkspaceInputs, String delimiter) { String requestBody = EMPTY; final List<String> triggerPrefixesList = new ArrayList<>(); ObjectMapper createWorkspaceMapper = new ObjectMapper(); CreateWorkspaceRequestBody createBody = new CreateWorkspaceRequestBody(); CreateWorkspaceRequestBody.CreateWorkspaceData createWorkspaceData = createBody.new CreateWorkspaceData(); CreateWorkspaceRequestBody.Attributes attributes = createBody.new Attributes(); attributes.setName(createWorkspaceInputs.getWorkspaceName()); attributes.setTerraform_version(createWorkspaceInputs.getCommonInputs().getTerraformVersion()); attributes.setDescription(createWorkspaceInputs.getWorkspaceDescription()); attributes.setAutoApply(Boolean.parseBoolean(createWorkspaceInputs.getAutoApply())); attributes.setFileTriggersEnabled(Boolean.parseBoolean(createWorkspaceInputs.getFileTriggersEnabled())); attributes.setWorkingDirectory(createWorkspaceInputs.getWorkingDirectory()); attributes.setQueueAllRuns(Boolean.parseBoolean(createWorkspaceInputs.getQueueAllRuns())); attributes.setSpeculativeEnabled(Boolean.parseBoolean(createWorkspaceInputs.getSpeculativeEnabled())); String[] triggerPrefixes = createWorkspaceInputs.getTriggerPrefixes().split(delimiter); Collections.addAll(triggerPrefixesList, triggerPrefixes); attributes.setTriggerPrefixes(triggerPrefixesList); CreateWorkspaceRequestBody.VCSRepo vcsRepo = createBody.new VCSRepo(); vcsRepo.setIdentifier(createWorkspaceInputs.getVcsRepoId()); vcsRepo.setOauthTokenId(createWorkspaceInputs.getOauthTokenId()); vcsRepo.setBranch(createWorkspaceInputs.getVcsBranch()); vcsRepo.setIngressSubmodules(Boolean.parseBoolean(createWorkspaceInputs.getIngressSubmodules())); attributes.setVcsRepo(vcsRepo); createWorkspaceData.setAttributes(attributes); createWorkspaceData.setType(WORKSPACE_TYPE); createBody.setData(createWorkspaceData); try { requestBody = createWorkspaceMapper.writeValueAsString(createBody); } catch (JsonProcessingException e) { e.printStackTrace(); } return requestBody; }  @NotNull static Map<String, String> createWorkspace(@NotNull final TerraformWorkspaceInputs createWorkspaceInputs); @NotNull static Map<String, String> deleteWorkspace(@NotNull final TerraformWorkspaceInputs deleteWorkspaceInputs); @NotNull static Map<String, String> listWorkspaces(@NotNull final TerraformCommonInputs listWorkspacesInputs); @NotNull static Map<String, String> getWorkspaceDetails(@NotNull final TerraformWorkspaceInputs
                                                                  getWorkspaceDetailsInputs); @NotNull static String getWorkspacePath(@NotNull final String organizationName); @NotNull static String getWorkspaceDetailsPath(@NotNull final String organizationName,
                                                 @NotNull final String workspaceName); @NotNull static String createWorkspaceBody(TerraformWorkspaceInputs createWorkspaceInputs, String delimiter); }
WorkspaceImpl { @NotNull public static String createWorkspaceBody(TerraformWorkspaceInputs createWorkspaceInputs, String delimiter) { String requestBody = EMPTY; final List<String> triggerPrefixesList = new ArrayList<>(); ObjectMapper createWorkspaceMapper = new ObjectMapper(); CreateWorkspaceRequestBody createBody = new CreateWorkspaceRequestBody(); CreateWorkspaceRequestBody.CreateWorkspaceData createWorkspaceData = createBody.new CreateWorkspaceData(); CreateWorkspaceRequestBody.Attributes attributes = createBody.new Attributes(); attributes.setName(createWorkspaceInputs.getWorkspaceName()); attributes.setTerraform_version(createWorkspaceInputs.getCommonInputs().getTerraformVersion()); attributes.setDescription(createWorkspaceInputs.getWorkspaceDescription()); attributes.setAutoApply(Boolean.parseBoolean(createWorkspaceInputs.getAutoApply())); attributes.setFileTriggersEnabled(Boolean.parseBoolean(createWorkspaceInputs.getFileTriggersEnabled())); attributes.setWorkingDirectory(createWorkspaceInputs.getWorkingDirectory()); attributes.setQueueAllRuns(Boolean.parseBoolean(createWorkspaceInputs.getQueueAllRuns())); attributes.setSpeculativeEnabled(Boolean.parseBoolean(createWorkspaceInputs.getSpeculativeEnabled())); String[] triggerPrefixes = createWorkspaceInputs.getTriggerPrefixes().split(delimiter); Collections.addAll(triggerPrefixesList, triggerPrefixes); attributes.setTriggerPrefixes(triggerPrefixesList); CreateWorkspaceRequestBody.VCSRepo vcsRepo = createBody.new VCSRepo(); vcsRepo.setIdentifier(createWorkspaceInputs.getVcsRepoId()); vcsRepo.setOauthTokenId(createWorkspaceInputs.getOauthTokenId()); vcsRepo.setBranch(createWorkspaceInputs.getVcsBranch()); vcsRepo.setIngressSubmodules(Boolean.parseBoolean(createWorkspaceInputs.getIngressSubmodules())); attributes.setVcsRepo(vcsRepo); createWorkspaceData.setAttributes(attributes); createWorkspaceData.setType(WORKSPACE_TYPE); createBody.setData(createWorkspaceData); try { requestBody = createWorkspaceMapper.writeValueAsString(createBody); } catch (JsonProcessingException e) { e.printStackTrace(); } return requestBody; }  @NotNull static Map<String, String> createWorkspace(@NotNull final TerraformWorkspaceInputs createWorkspaceInputs); @NotNull static Map<String, String> deleteWorkspace(@NotNull final TerraformWorkspaceInputs deleteWorkspaceInputs); @NotNull static Map<String, String> listWorkspaces(@NotNull final TerraformCommonInputs listWorkspacesInputs); @NotNull static Map<String, String> getWorkspaceDetails(@NotNull final TerraformWorkspaceInputs
                                                                  getWorkspaceDetailsInputs); @NotNull static String getWorkspacePath(@NotNull final String organizationName); @NotNull static String getWorkspaceDetailsPath(@NotNull final String organizationName,
                                                 @NotNull final String workspaceName); @NotNull static String createWorkspaceBody(TerraformWorkspaceInputs createWorkspaceInputs, String delimiter);  }