Example usage for org.springframework.boot.cli.command.init ProjectGenerationRequest ProjectGenerationRequest

List of usage examples for org.springframework.boot.cli.command.init ProjectGenerationRequest ProjectGenerationRequest

Introduction

In this page you can find the example usage for org.springframework.boot.cli.command.init ProjectGenerationRequest ProjectGenerationRequest.

Prototype

ProjectGenerationRequest

Source Link

Usage

From source file:org.springframework.boot.cli.command.init.InitializrServiceTests.java

@Test
public void generateSimpleProject() throws Exception {
    ProjectGenerationRequest request = new ProjectGenerationRequest();
    MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest("application/xml",
            "foo.zip");
    ProjectGenerationResponse entity = generateProject(request, mockHttpRequest);
    assertProjectEntity(entity, mockHttpRequest.contentType, mockHttpRequest.fileName);
}

From source file:org.springframework.boot.cli.command.init.InitializrServiceTests.java

@Test
public void generateProjectCustomTargetFilename() throws Exception {
    ProjectGenerationRequest request = new ProjectGenerationRequest();
    request.setOutput("bar.zip");
    MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest("application/xml",
            null);/*from   w w w. ja v a2s  . co m*/
    ProjectGenerationResponse entity = generateProject(request, mockHttpRequest);
    assertProjectEntity(entity, mockHttpRequest.contentType, null);
}

From source file:org.springframework.boot.cli.command.init.InitializrServiceTests.java

@Test
public void generateProjectNoDefaultFileName() throws Exception {
    ProjectGenerationRequest request = new ProjectGenerationRequest();
    MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest("application/xml",
            null);/*from www .  ja  va2 s  .  c  o m*/
    ProjectGenerationResponse entity = generateProject(request, mockHttpRequest);
    assertProjectEntity(entity, mockHttpRequest.contentType, null);
}

From source file:org.springframework.boot.cli.command.init.InitializrServiceTests.java

@Test
public void generateProjectBadRequest() throws Exception {
    String jsonMessage = "Unknown dependency foo:bar";
    mockProjectGenerationError(400, jsonMessage);
    ProjectGenerationRequest request = new ProjectGenerationRequest();
    request.getDependencies().add("foo:bar");
    this.thrown.expect(ReportableException.class);
    this.thrown.expectMessage(jsonMessage);
    this.invoker.generate(request);
}

From source file:org.springframework.boot.cli.command.init.InitializrServiceTests.java

@Test
public void generateProjectBadRequestNoExtraMessage() throws Exception {
    mockProjectGenerationError(400, null);
    ProjectGenerationRequest request = new ProjectGenerationRequest();
    this.thrown.expect(ReportableException.class);
    this.thrown.expectMessage("unexpected 400 error");
    this.invoker.generate(request);
}

From source file:org.springframework.boot.cli.command.init.InitializrServiceTests.java

@Test
public void generateProjectNoContent() throws Exception {
    mockSuccessfulMetadataGet(false);/*w ww  . j  ava2s .c o  m*/
    CloseableHttpResponse response = mock(CloseableHttpResponse.class);
    mockStatus(response, 500);
    given(this.http.execute(isA(HttpGet.class))).willReturn(response);
    ProjectGenerationRequest request = new ProjectGenerationRequest();
    this.thrown.expect(ReportableException.class);
    this.thrown.expectMessage("No content received from server");
    this.invoker.generate(request);
}

From source file:org.springframework.boot.cli.command.init.InitializrServiceTests.java

@Test
public void loadMetadataBadRequest() throws Exception {
    String jsonMessage = "whatever error on the server";
    mockMetadataGetError(500, jsonMessage);
    ProjectGenerationRequest request = new ProjectGenerationRequest();
    this.thrown.expect(ReportableException.class);
    this.thrown.expectMessage(jsonMessage);
    this.invoker.generate(request);
}

From source file:org.springframework.boot.cli.command.init.InitializrServiceTests.java

@Test
public void loadMetadataInvalidJson() throws Exception {
    CloseableHttpResponse response = mock(CloseableHttpResponse.class);
    mockHttpEntity(response, "Foo-Bar-Not-JSON".getBytes(), "application/json");
    mockStatus(response, 200);// w  w  w .  j a  v a  2 s. c o  m
    given(this.http.execute(isA(HttpGet.class))).willReturn(response);
    ProjectGenerationRequest request = new ProjectGenerationRequest();
    this.thrown.expect(ReportableException.class);
    this.thrown.expectMessage("Invalid content received from server");
    this.invoker.generate(request);
}

From source file:org.springframework.boot.cli.command.init.InitializrServiceTests.java

@Test
public void loadMetadataNoContent() throws Exception {
    CloseableHttpResponse response = mock(CloseableHttpResponse.class);
    mockStatus(response, 500);//w  ww  .j a va2  s . co  m
    given(this.http.execute(isA(HttpGet.class))).willReturn(response);
    ProjectGenerationRequest request = new ProjectGenerationRequest();
    this.thrown.expect(ReportableException.class);
    this.thrown.expectMessage("No content received from server");
    this.invoker.generate(request);
}