Skip to content

Commit

Permalink
Merge pull request #1447 from Bolo89/add-webflux-button-front
Browse files Browse the repository at this point in the history
Add webflux / add button in front
  • Loading branch information
pascalgrimaud authored Apr 23, 2022
2 parents a372b8e + ad5679b commit 98a8b40
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 1 deletion.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
'!src/main/webapp/app/router/index.ts',
'!**/*.d.ts',
],
coverageReporters: ['html', 'json-summary', 'text-summary', 'lcov', 'clover'],
coverageReporters: ['html', 'json-summary', 'text', 'text-summary', 'lcov', 'clover'],
coverageDirectory: '<rootDir>/target/test-results/',
coverageThreshold: {
global: {
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/app/springboot/domain/SpringBootService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface SpringBootService {
addSpringBoot(project: Project): Promise<void>;

addSpringBootMvcTomcat(project: Project): Promise<void>;
addSpringBootWebfluxNetty(project: Project): Promise<void>;
addJWT(project: Project): Promise<void>;
addBasicAuthJWT(project: Project): Promise<void>;
addOauth2(project: Project): Promise<void>;
Expand Down
9 changes: 9 additions & 0 deletions src/main/webapp/app/springboot/primary/Generator.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ export default defineComponent({
}
};

const addSpringBootWebfluxNetty = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
.addSpringBootWebfluxNetty(toProject(project.value))
.catch(error => logger.error('Adding SpringBoot Webflux with Netty to project failed', error));
}
};

const addSpringBootSecurityJWT = async (): Promise<void> => {
if (project.value.folder !== '') {
await springBootService
Expand Down Expand Up @@ -158,6 +166,7 @@ export default defineComponent({
addJavaBase,
addSpringBoot,
addSpringBootMvcTomcat,
addSpringBootWebfluxNetty,
addSpringBootSecurityJWT,
addSpringBootSecurityJWTBasicAuth,
addAngular,
Expand Down
8 changes: 8 additions & 0 deletions src/main/webapp/app/springboot/primary/Generator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,14 @@
>
Spring MVC Tomcat
</button>
<button
id="springbootwebfluxnetty"
class="btn btn-outline-primary"
:data-selector="selectorPrefix + '.add-spring-boot-webflux-netty-button'"
@click.prevent="addSpringBootWebfluxNetty"
>
Spring Webflux Netty
</button>
<br />
<br />
<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export default class SpringBootRepository implements SpringBootService {
await this.axiosHttp.post('api/servers/spring-boot/web-servers/tomcat', restProject);
}

async addSpringBootWebfluxNetty(project: Project): Promise<void> {
const restProject: RestProject = toRestProject(project);
await this.axiosHttp.post('api/servers/spring-boot/reactive-servers/netty', restProject);
}

async addSpringBootBannerIppon(project: Project): Promise<void> {
const restProject: RestProject = toRestProject(project);
await this.axiosHttp.post('api/servers/spring-boot/banners/ippon', restProject);
Expand Down
1 change: 1 addition & 0 deletions src/test/javascript/cypress/integration/Generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe('Generator', () => {
cy.get(generatorSelector('option-springboot')).check();
cy.get(generatorSelector('add-spring-boot-button')).contains('Spring Boot');
cy.get(generatorSelector('add-spring-boot-mvc-tomcat-button')).contains('Spring MVC Tomcat');
cy.get(generatorSelector('add-spring-boot-webflux-netty-button')).contains('Spring Webflux Netty');
cy.get(generatorSelector('add-spring-boot-jwt-button')).contains('Security JWT');
cy.get(generatorSelector('add-spring-boot-jwt-basic-auth-button')).contains('Security JWT Basic Auth');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import sinon, { SinonStub } from 'sinon';
export interface SpringBootServiceFixture extends SpringBootService {
addSpringBoot: SinonStub;
addSpringBootMvcTomcat: SinonStub;
addSpringBootWebfluxNetty: SinonStub;
addEhcacheWithJavaConf: SinonStub;
addEhcacheWithXML: SinonStub;
addSimpleCache: SinonStub;
Expand Down Expand Up @@ -37,6 +38,7 @@ export interface SpringBootServiceFixture extends SpringBootService {
export const stubSpringBootService = (): SpringBootServiceFixture => ({
addSpringBoot: sinon.stub(),
addSpringBootMvcTomcat: sinon.stub(),
addSpringBootWebfluxNetty: sinon.stub(),
addEhcacheWithJavaConf: sinon.stub(),
addEhcacheWithXML: sinon.stub(),
addSimpleCache: sinon.stub(),
Expand Down
55 changes: 55 additions & 0 deletions src/test/javascript/spec/springboot/primary/Generator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,61 @@ describe('Generator', () => {
expect(message).toBe('Adding SpringBoot MVC with Tomcat to project failed');
});

it('should not add SpringBoot Webflux with Netty when project path is not filled', async () => {
const springBootService = stubSpringBootService();
springBootService.addSpringBootWebfluxNetty.resolves({});
await wrap({ springBootService });
await selectSection('springboot');

const button = wrapper.find('#springbootwebfluxnetty');
await button.trigger('click');

expect(springBootService.addSpringBootWebfluxNetty.called).toBe(false);
});

it('should add SpringBoot Webflux with Netty when project path is filled', async () => {
const springBootService = stubSpringBootService();
springBootService.addSpringBootWebfluxNetty.resolves({});
await wrap({ springBootService });
const projectToUpdate: ProjectToUpdate = createProjectToUpdate({
folder: 'project/path',
baseName: 'beer',
projectName: 'Beer Project',
packageName: 'tech.jhipster.beer',
serverPort: '8080',
});
await fillFullForm(projectToUpdate);
await selectSection('springboot');

const button = wrapper.find('#springbootwebfluxnetty');
await button.trigger('click');

const args = springBootService.addSpringBootWebfluxNetty.getCall(0).args[0];
expect(args).toEqual({
baseName: 'beer',
folder: 'project/path',
projectName: 'Beer Project',
packageName: 'tech.jhipster.beer',
serverPort: 8080,
});
});

it('should handle error on adding SpringBoot Webflux with Netty failure', async () => {
const logger = stubLogger();
const springBootService = stubSpringBootService();
springBootService.addSpringBootWebfluxNetty.rejects({});
await wrap({ springBootService, logger });
const projectToUpdate: ProjectToUpdate = createProjectToUpdate();
await fillFullForm(projectToUpdate);
await selectSection('springboot');

const initButton = wrapper.find('#springbootwebfluxnetty');
await initButton.trigger('click');

const [message] = logger.error.getCall(0).args;
expect(message).toBe('Adding SpringBoot Webflux with Netty to project failed');
});

it('should not add SpringBoot Security JWT when project path is not filled', async () => {
const springBootService = stubSpringBootService();
springBootService.addJWT.resolves({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ describe('SpringBootRepository', () => {
expect(payload).toEqual<RestProject>(expectedRestProject);
});

it('should add SpringBoot Webflux with Netty', () => {
const axiosHttpStub = stubAxiosHttp();
axiosHttpStub.post.resolves();
const springBootRepository = new SpringBootRepository(axiosHttpStub);
const project: Project = createProject({ folder: 'folder/path' });

springBootRepository.addSpringBootWebfluxNetty(project);

const expectedRestProject: RestProject = toRestProject(project);
const [uri, payload] = axiosHttpStub.post.getCall(0).args;
expect(uri).toBe('api/servers/spring-boot/reactive-servers/netty');
expect(payload).toEqual<RestProject>(expectedRestProject);
});

it('should add Ippon Banner', () => {
const axiosHttpStub = stubAxiosHttp();
axiosHttpStub.post.resolves();
Expand Down

0 comments on commit 98a8b40

Please sign in to comment.