io.fabric8.openshift.api.model.ProjectBuilder Java Examples
The following examples show how to use
io.fabric8.openshift.api.model.ProjectBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectEnricher.java From jkube with Eclipse Public License 2.0 | 6 votes |
private Project convertToProject(Namespace namespace) { ProjectBuilder builder = new ProjectBuilder(); builder.withMetadata(namespace.getMetadata()); if (namespace.getSpec() != null) { NamespaceSpec namespaceSpec = namespace.getSpec(); ProjectSpec projectSpec = new ProjectSpec(); if (namespaceSpec.getFinalizers() != null) { projectSpec.setFinalizers(namespaceSpec.getFinalizers()); } builder.withSpec(projectSpec); } if (namespace.getStatus() != null) { ProjectStatus status = new ProjectStatusBuilder() .withPhase(namespace.getStatus().getPhase()).build(); builder.withStatus(status); } return builder.build(); }
Example #2
Source File: OpenshiftAPIServiceTest.java From openshift-elasticsearch-plugin with Apache License 2.0 | 6 votes |
private void givenProjects(String... projects) throws Exception { ProjectListBuilder builder = new ProjectListBuilder(false); for (String project : projects) { builder.addToItems(new ProjectBuilder(false) .withNewMetadata() .withUid(project) .withName(project) .endMetadata() .build()); } apiServer.expect() .withPath("/apis/project.openshift.io/v1/projects") .andReturn(200, builder.build()) .always(); }
Example #3
Source File: OpenShiftProjectFactoryTest.java From che with Eclipse Public License 2.0 | 6 votes |
private Project createProject(String name, String displayName, String description, String phase) { Map<String, String> annotations = new HashMap<>(); if (displayName != null) { annotations.put(PROJECT_DISPLAY_NAME_ANNOTATION, displayName); } if (description != null) { annotations.put(PROJECT_DESCRIPTION_ANNOTATION, description); } return new ProjectBuilder() .withNewMetadata() .withName(name) .withAnnotations(annotations) .endMetadata() .withNewStatus() .withNewPhase(phase) .endStatus() .build(); }
Example #4
Source File: ProjectTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testGet() { server.expect().withPath("/apis/project.openshift.io/v1/projects/project1").andReturn(200, new ProjectBuilder() .withNewMetadata().withName("project1").endMetadata() .build()).once(); server.expect().withPath("/apis/project.openshift.io/v1/projects/project2").andReturn(200, new ProjectBuilder() .withNewMetadata().withName("project2").endMetadata() .build()).once(); OpenShiftClient client = server.getOpenshiftClient(); Project project = client.projects().withName("project1").get(); assertNotNull(project); assertEquals("project1", project.getMetadata().getName()); project = client.projects().withName("project2").get(); assertNotNull(project); assertEquals("project2", project.getMetadata().getName()); project = client.projects().withName("project3").get(); assertNull(project); }
Example #5
Source File: ProjectTest.java From kubernetes-client with Apache License 2.0 | 6 votes |
@Test public void testDelete() { server.expect().withPath("/apis/project.openshift.io/v1/projects/project1").andReturn(200, new ProjectBuilder().build()).once(); server.expect().withPath("/apis/project.openshift.io/v1/projects/project2").andReturn( 200, new ProjectBuilder().build()).once(); OpenShiftClient client = server.getOpenshiftClient(); Boolean deleted = client.projects().withName("project1").delete(); assertNotNull(deleted); deleted = client.projects().withName("project2").delete(); assertTrue(deleted); deleted = client.projects().withName("project3").delete(); assertFalse(deleted); }
Example #6
Source File: ElasticsearchIntegrationTest.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
protected void givenUserIsAdminForProjects(String... projects) throws Exception { String user = (String) testContext.get(USERNAME); ProjectListBuilder builder = new ProjectListBuilder(false); for (String project : projects) { builder.addToItems(new ProjectBuilder(false).withNewMetadata().withUid("uuid").withName(project).endMetadata().build()); } apiServer.expect() .withPath("/apis/project.openshift.io/v1/projects") .andReturn(200, builder.build()) .withHeader("Authorization", "Bearer " + user + "-token") .always(); }
Example #7
Source File: ElasticsearchIntegrationTest.java From openshift-elasticsearch-plugin with Apache License 2.0 | 5 votes |
protected void givenUserIsAdminForProject(String name, String uuid) throws Exception { String user = (String) testContext.get(USERNAME); ProjectListBuilder builder = new ProjectListBuilder(false); builder.addToItems(new ProjectBuilder(false).withNewMetadata().withUid(uuid).withName(name).endMetadata().build()); apiServer.expect() .withPath("/apis/project.openshift.io/v1/projects") .andReturn(200, builder.build()) .withHeader("Authorization", "Bearer " + user + "-token") .always(); }
Example #8
Source File: OpenShiftProjectTest.java From che with Eclipse Public License 2.0 | 5 votes |
private Resource prepareProjectResource(String projectName) { Resource projectResource = mock(Resource.class); NonNamespaceOperation projectOperation = mock(NonNamespaceOperation.class); doReturn(projectResource).when(projectOperation).withName(projectName); doReturn(projectOperation).when(openShiftClient).projects(); when(projectResource.get()) .thenReturn( new ProjectBuilder().withNewMetadata().withName(projectName).endMetadata().build()); openShiftClient.projects().withName(projectName).get(); return projectResource; }
Example #9
Source File: ProjectHandler.java From jkube with Eclipse Public License 2.0 | 4 votes |
public Project getProject(String namespace) { return new ProjectBuilder().withMetadata(createProjectMetaData(namespace)).withNewStatus().withPhase("Active").endStatus().build(); }
Example #10
Source File: OpenShiftProjectFactoryTest.java From che with Eclipse Public License 2.0 | 4 votes |
@Test public void shouldReturnDefaultProjectWhenItExistsAndUserDefinedIsNotAllowed() throws Exception { prepareNamespaceToBeFoundByName( "che-default", new ProjectBuilder() .withNewMetadata() .withName("che-default") .withAnnotations( ImmutableMap.of( PROJECT_DISPLAY_NAME_ANNOTATION, "Default Che Project", PROJECT_DESCRIPTION_ANNOTATION, "some description")) .endMetadata() .withNewStatus() .withPhase("Active") .endStatus() .build()); projectFactory = new OpenShiftProjectFactory( "predefined", "", "", "che-default", false, clientFactory, configFactory, stopWorkspaceRoleProvisioner, userManager, pool, NO_OAUTH_IDENTITY_PROVIDER); List<KubernetesNamespaceMeta> availableNamespaces = projectFactory.list(); assertEquals(availableNamespaces.size(), 1); KubernetesNamespaceMeta defaultNamespace = availableNamespaces.get(0); assertEquals(defaultNamespace.getName(), "che-default"); assertEquals(defaultNamespace.getAttributes().get(DEFAULT_ATTRIBUTE), "true"); assertEquals( defaultNamespace.getAttributes().get(PROJECT_DISPLAY_NAME_ATTRIBUTE), "Default Che Project"); assertEquals( defaultNamespace.getAttributes().get(PROJECT_DESCRIPTION_ATTRIBUTE), "some description"); assertEquals(defaultNamespace.getAttributes().get(PHASE_ATTRIBUTE), "Active"); }