From 66832dd6124181b8cb1dd0820cf39cc7d967d6da Mon Sep 17 00:00:00 2001 From: mnhock Date: Sun, 30 Jul 2023 14:30:46 +0200 Subject: [PATCH] Add tags view to overviews Closes gb-27 --- naikan-client/src/app/app-routing.module.ts | 4 + .../src/app/layout/app.menu.component.ts | 13 +-- .../src/app/overview/overview.component.html | 8 ++ .../app/overview/tag/tag-routing.module.ts | 14 +++ .../src/app/overview/tag/tag.component.html | 92 +++++++++++++++++++ .../src/app/overview/tag/tag.component.ts | 68 ++++++++++++++ .../src/app/overview/tag/tag.service.ts | 24 +++++ .../overview/tag/OverviewTagRepository.java | 15 +++ .../overview/tag/OverviewTagService.java | 14 +++ .../support/OverviewTagMongoRepository.java | 63 +++++++++++++ .../support/OverviewTagServiceHandler.java | 33 +++++++ .../support/OverviewTagMongoRepositoryIT.java | 59 ++++++++++++ .../contact/OverviewContactController.java | 3 +- .../OverviewDeveloperController.java | 3 +- .../OverviewEnvironmentController.java | 6 +- .../OverviewIntegrationController.java | 6 +- .../overview/tag/OverviewTagController.java | 40 ++++++++ .../overview/team/OverviewTeamController.java | 3 +- .../OverviewTechnologyController.java | 3 +- .../overview/tag/OverviewTagControllerIT.java | 53 +++++++++++ 20 files changed, 498 insertions(+), 26 deletions(-) create mode 100644 naikan-client/src/app/overview/tag/tag-routing.module.ts create mode 100644 naikan-client/src/app/overview/tag/tag.component.html create mode 100644 naikan-client/src/app/overview/tag/tag.component.ts create mode 100644 naikan-client/src/app/overview/tag/tag.service.ts create mode 100644 naikan-core/src/main/java/com/enofex/naikan/overview/tag/OverviewTagRepository.java create mode 100644 naikan-core/src/main/java/com/enofex/naikan/overview/tag/OverviewTagService.java create mode 100644 naikan-core/src/main/java/com/enofex/naikan/overview/tag/support/OverviewTagMongoRepository.java create mode 100644 naikan-core/src/main/java/com/enofex/naikan/overview/tag/support/OverviewTagServiceHandler.java create mode 100644 naikan-core/src/test/java/com/enofex/naikan/overview/tag/support/OverviewTagMongoRepositoryIT.java create mode 100644 naikan-web/src/main/java/com/enofex/naikan/overview/tag/OverviewTagController.java create mode 100644 naikan-web/src/test/java/com/enofex/naikan/overview/tag/OverviewTagControllerIT.java diff --git a/naikan-client/src/app/app-routing.module.ts b/naikan-client/src/app/app-routing.module.ts index 0d4745a7..efda6e10 100644 --- a/naikan-client/src/app/app-routing.module.ts +++ b/naikan-client/src/app/app-routing.module.ts @@ -46,6 +46,10 @@ export const APP_ROUTES: Routes = [ path: 'overview/deployments', loadChildren: () => import('./overview/deployment/deployment-routing.module').then(m => m.DeploymentRoutingModule) }, + { + path: 'overview/tags', + loadChildren: () => import('./overview/tag/tag-routing.module').then(m => m.TagRoutingModule) + }, { path: 'administration', loadChildren: () => import('./administration/administration.routing.module').then(m => m.AdministrationRoutingModule) diff --git a/naikan-client/src/app/layout/app.menu.component.ts b/naikan-client/src/app/layout/app.menu.component.ts index 2000d719..3632751d 100644 --- a/naikan-client/src/app/layout/app.menu.component.ts +++ b/naikan-client/src/app/layout/app.menu.component.ts @@ -23,21 +23,14 @@ export class AppMenuComponent implements OnInit { { label: 'Overviews', items: [ - { - label: 'Environments', - icon: 'pi pi-fw pi-box', - routerLink: ['/overview/environments'] - }, + {label: 'Environments', icon: 'pi pi-fw pi-box', routerLink: ['/overview/environments']}, {label: 'Teams', icon: 'pi pi-fw pi-users', routerLink: ['/overview/teams']}, {label: 'Developers', icon: 'pi pi-fw pi-user', routerLink: ['/overview/developers']}, {label: 'Contacts', icon: 'pi pi-fw pi-envelope', routerLink: ['/overview/contacts']}, {label: 'Integrations', icon: 'pi pi-fw pi-link', routerLink: ['/overview/integrations']}, {label: 'Technologies', icon: 'pi pi-fw pi-code', routerLink: ['/overview/technologies']}, - { - label: 'Deployments', - icon: 'pi pi-fw pi-cloud-upload', - routerLink: ['/overview/deployments'] - } + {label: 'Deployments', icon: 'pi pi-fw pi-cloud-upload', routerLink: ['/overview/deployments']}, + {label: 'Tags', icon: 'pi pi-fw pi-tags', routerLink: ['/overview/tags']}, ] } ]; diff --git a/naikan-client/src/app/overview/overview.component.html b/naikan-client/src/app/overview/overview.component.html index 4ad06807..7ccad709 100644 --- a/naikan-client/src/app/overview/overview.component.html +++ b/naikan-client/src/app/overview/overview.component.html @@ -62,5 +62,13 @@
Deployments
See all deployments of your projects on all environments. +
+ + + +
Tags
+ See all tags of your projects. +
\ No newline at end of file diff --git a/naikan-client/src/app/overview/tag/tag-routing.module.ts b/naikan-client/src/app/overview/tag/tag-routing.module.ts new file mode 100644 index 00000000..0d60fe45 --- /dev/null +++ b/naikan-client/src/app/overview/tag/tag-routing.module.ts @@ -0,0 +1,14 @@ +import {NgModule} from '@angular/core'; +import {RouterModule} from '@angular/router'; +import {TagComponent} from './tag.component'; +import {AuthGuard} from "../../shared"; + +@NgModule({ + imports: [RouterModule.forChild([{ + path: '', component: TagComponent, + canActivate: [AuthGuard] + }])], + exports: [RouterModule] +}) +export class TagRoutingModule { +} diff --git a/naikan-client/src/app/overview/tag/tag.component.html b/naikan-client/src/app/overview/tag/tag.component.html new file mode 100644 index 00000000..acdb39c7 --- /dev/null +++ b/naikan-client/src/app/overview/tag/tag.component.html @@ -0,0 +1,92 @@ + + +
+
{{page?.totalElements}} Tags + + + + +
+ +
+ +
+ + + + +
+
+ +
+
+ +
+
+
+ + + + + + + Name + + + + + Projects + + + + + + + + + + + + {{ overviewGroup.group.name }} + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/naikan-client/src/app/overview/tag/tag.component.ts b/naikan-client/src/app/overview/tag/tag.component.ts new file mode 100644 index 00000000..b584c32a --- /dev/null +++ b/naikan-client/src/app/overview/tag/tag.component.ts @@ -0,0 +1,68 @@ +import {Component} from '@angular/core'; +import {TagService} from './tag.service'; +import {Breadcrumb, Charts, Search, Url} from '../../shared'; +import {SharedModule} from 'primeng/api'; +import {LayoutService} from '../../layout/app.layout.service'; +import {AbstractOverviewComponent} from "../abstract-overview.component"; +import {OverviewProjectTable} from '../overview-project-table'; +import {TagModule} from 'primeng/tag'; +import {TooltipModule} from 'primeng/tooltip'; +import {ButtonModule} from 'primeng/button'; +import {TableLazyLoadEvent, TableModule} from 'primeng/table'; +import {ChartModule} from 'primeng/chart'; +import {DatePipe, NgIf} from '@angular/common'; +import {OverviewGroup} from "../overview"; + +@Component({ + templateUrl: './tag.component.html', + standalone: true, + imports: [ + Breadcrumb, + NgIf, + ChartModule, + TableModule, + SharedModule, + Search, + ButtonModule, + TooltipModule, + Url, + TagModule, + OverviewProjectTable, + ], + providers: [TagService, DatePipe] +}) +export class TagComponent extends AbstractOverviewComponent { + + constructor(private readonly tagService: TagService, layoutService: LayoutService) { + super(layoutService); + } + + loadOverviews(event?: TableLazyLoadEvent): void { + this.tagService.getOverviews(event) + .subscribe(data => this.page = data); + } + + override initChart(): void { + this.tagService.getTopGroups(this.topN) + .subscribe(data => { + if (data) { + const documentStyle = Charts.documentStyle(); + this.topN = data.names?.length; + + this.chartData = { + labels: data.names, + datasets: [ + { + label: "Projects", + data: data.counts, + backgroundColor: documentStyle, + borderColor: documentStyle + } + ] + }; + + Object.assign(this.chartOptions.plugins.title, {'text': `Top ${this.topN} Tags`}); + } + }); + } +} diff --git a/naikan-client/src/app/overview/tag/tag.service.ts b/naikan-client/src/app/overview/tag/tag.service.ts new file mode 100644 index 00000000..2e5272bd --- /dev/null +++ b/naikan-client/src/app/overview/tag/tag.service.ts @@ -0,0 +1,24 @@ +import {HttpClient} from '@angular/common/http'; +import {Injectable} from '@angular/core'; +import {Observable} from 'rxjs'; +import {Page, Pageables} from '../../shared'; +import {OverviewTopGroups} from '../overview-top-groups'; +import {OverviewGroup} from "../overview"; +import {TableLazyLoadEvent} from "primeng/table"; + +const endpoint = 'overview/tags'; + +@Injectable() +export class TagService { + + constructor(private readonly http: HttpClient) { + } + + getOverviews(event?: TableLazyLoadEvent): Observable> { + return this.http.get>(`/${endpoint}`, {params: Pageables.toPageRequestHttpParams(event)}); + } + + getTopGroups(topN: number): Observable { + return this.http.get(`/${endpoint}/top/${topN}`); + } +} diff --git a/naikan-core/src/main/java/com/enofex/naikan/overview/tag/OverviewTagRepository.java b/naikan-core/src/main/java/com/enofex/naikan/overview/tag/OverviewTagRepository.java new file mode 100644 index 00000000..fc09e04b --- /dev/null +++ b/naikan-core/src/main/java/com/enofex/naikan/overview/tag/OverviewTagRepository.java @@ -0,0 +1,15 @@ +package com.enofex.naikan.overview.tag; + +import com.enofex.naikan.Filterable; +import com.enofex.naikan.overview.OverviewGroup; +import com.enofex.naikan.overview.OverviewTopGroups; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface OverviewTagRepository { + + Page findAll(Filterable filterable, Pageable pageable); + + OverviewTopGroups findTopTags(long topN); + +} diff --git a/naikan-core/src/main/java/com/enofex/naikan/overview/tag/OverviewTagService.java b/naikan-core/src/main/java/com/enofex/naikan/overview/tag/OverviewTagService.java new file mode 100644 index 00000000..2f562cc5 --- /dev/null +++ b/naikan-core/src/main/java/com/enofex/naikan/overview/tag/OverviewTagService.java @@ -0,0 +1,14 @@ +package com.enofex.naikan.overview.tag; + +import com.enofex.naikan.Filterable; +import com.enofex.naikan.overview.OverviewGroup; +import com.enofex.naikan.overview.OverviewTopGroups; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface OverviewTagService { + + Page findAll(Filterable filterable, Pageable pageable); + + OverviewTopGroups findTopTags(long topN); +} diff --git a/naikan-core/src/main/java/com/enofex/naikan/overview/tag/support/OverviewTagMongoRepository.java b/naikan-core/src/main/java/com/enofex/naikan/overview/tag/support/OverviewTagMongoRepository.java new file mode 100644 index 00000000..bb93f468 --- /dev/null +++ b/naikan-core/src/main/java/com/enofex/naikan/overview/tag/support/OverviewTagMongoRepository.java @@ -0,0 +1,63 @@ +package com.enofex.naikan.overview.tag.support; + +import static org.springframework.data.mongodb.core.aggregation.Aggregation.group; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.limit; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.project; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.sort; +import static org.springframework.data.mongodb.core.aggregation.Aggregation.unwind; + +import com.enofex.naikan.Filterable; +import com.enofex.naikan.FilterableCriteriaBuilder; +import com.enofex.naikan.overview.OverviewGroup; +import com.enofex.naikan.overview.OverviewRepository; +import com.enofex.naikan.overview.OverviewTopGroups; +import com.enofex.naikan.overview.tag.OverviewTagRepository; +import java.util.List; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.data.mongodb.core.aggregation.Aggregation; +import org.springframework.data.mongodb.core.aggregation.AggregationOperation; +import org.springframework.stereotype.Repository; + +@Repository +class OverviewTagMongoRepository extends OverviewRepository implements + OverviewTagRepository { + + OverviewTagMongoRepository(MongoTemplate template) { + super(template); + } + + @Override + public Page findAll(Filterable filterable, Pageable pageable) { + FilterableCriteriaBuilder builder = new FilterableCriteriaBuilder(filterable); + List operations = defaultOverviewGroupOperations( + "tags", + List.of("tags"), + builder.toSearch(List.of("group")), + builder.toFilters()); + + return findAll(OverviewGroup.class, operations, pageable); + } + + @Override + public OverviewTopGroups findTopTags(long topN) { + Aggregation aggregation = Aggregation.newAggregation( + unwind("tags"), + group("tags").count().as("count"), + sort(Direction.DESC, "count").and(Direction.ASC, "_id"), + limit(topN), + group() + .push("_id").as("names") + .push("count").as("counts"), + project().andExclude("_id") + .and("names").as("names") + .and("counts").as("counts") + ); + + return template() + .aggregate(aggregation, collectionName(), OverviewTopGroups.class) + .getUniqueMappedResult(); + } +} diff --git a/naikan-core/src/main/java/com/enofex/naikan/overview/tag/support/OverviewTagServiceHandler.java b/naikan-core/src/main/java/com/enofex/naikan/overview/tag/support/OverviewTagServiceHandler.java new file mode 100644 index 00000000..8746b2e3 --- /dev/null +++ b/naikan-core/src/main/java/com/enofex/naikan/overview/tag/support/OverviewTagServiceHandler.java @@ -0,0 +1,33 @@ +package com.enofex.naikan.overview.tag.support; + +import com.enofex.naikan.Filterable; +import com.enofex.naikan.overview.OverviewGroup; +import com.enofex.naikan.overview.OverviewTopGroups; +import com.enofex.naikan.overview.tag.OverviewTagRepository; +import com.enofex.naikan.overview.tag.OverviewTagService; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +class OverviewTagServiceHandler implements OverviewTagService { + + private final OverviewTagRepository overviewTagRepository; + + OverviewTagServiceHandler(OverviewTagRepository overviewTagRepository) { + this.overviewTagRepository = overviewTagRepository; + } + + @Override + public Page findAll(Filterable filterable, Pageable pageable) { + return this.overviewTagRepository.findAll(filterable, pageable); + } + + @Override + public OverviewTopGroups findTopTags(long topN) { + return this.overviewTagRepository.findTopTags(topN); + } + +} diff --git a/naikan-core/src/test/java/com/enofex/naikan/overview/tag/support/OverviewTagMongoRepositoryIT.java b/naikan-core/src/test/java/com/enofex/naikan/overview/tag/support/OverviewTagMongoRepositoryIT.java new file mode 100644 index 00000000..eb11acc3 --- /dev/null +++ b/naikan-core/src/test/java/com/enofex/naikan/overview/tag/support/OverviewTagMongoRepositoryIT.java @@ -0,0 +1,59 @@ +package com.enofex.naikan.overview.tag.support; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.enofex.naikan.Filterable; +import com.enofex.naikan.model.deserializer.DeserializerFactory; +import com.enofex.naikan.overview.OverviewGroup; +import com.enofex.naikan.overview.OverviewTopGroups; + +import com.enofex.naikan.overview.tag.OverviewTagRepository; +import com.enofex.naikan.test.IntegrationTest; +import com.enofex.naikan.test.model.Boms; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.mongodb.core.MongoTemplate; + +@IntegrationTest +class OverviewTagMongoRepositoryIT { + + @Autowired + private MongoTemplate template; + + private OverviewTagRepository repository; + + @BeforeEach + void setUp() { + this.repository = new OverviewTagMongoRepository(this.template); + this.template.save(DeserializerFactory.newJsonDeserializer().of(Boms.validBom0asInputStream()), + "projects"); + } + + @Test + void shouldFindAll() { + Page page = this.repository.findAll( + Filterable.emptySearch(), Pageable.ofSize(20)); + + assertEquals(2, page.getContent().size()); + } + + @Test + void shouldFindAllOverviewsWithSearch() { + Page page = this.repository.findAll( + Filterable.of("intern"), Pageable.ofSize(20)); + + assertEquals(1, page.getContent().size()); + } + + + @Test + void shouldFindTopTags() { + OverviewTopGroups groups = this.repository.findTopTags(5); + + assertEquals(2, groups.counts().size()); + assertEquals(2, groups.names().size()); + } +} \ No newline at end of file diff --git a/naikan-web/src/main/java/com/enofex/naikan/overview/contact/OverviewContactController.java b/naikan-web/src/main/java/com/enofex/naikan/overview/contact/OverviewContactController.java index c36059c3..edd0d230 100644 --- a/naikan-web/src/main/java/com/enofex/naikan/overview/contact/OverviewContactController.java +++ b/naikan-web/src/main/java/com/enofex/naikan/overview/contact/OverviewContactController.java @@ -26,8 +26,7 @@ class OverviewContactController { } @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll(Filterable filterable, - Pageable pageable) { + public ResponseEntity> findAll(Filterable filterable, Pageable pageable) { return ResponseEntity.ok(this.overviewContactService.findAll(filterable, pageable)); } } diff --git a/naikan-web/src/main/java/com/enofex/naikan/overview/developer/OverviewDeveloperController.java b/naikan-web/src/main/java/com/enofex/naikan/overview/developer/OverviewDeveloperController.java index ad4fdb0a..5d8d9906 100644 --- a/naikan-web/src/main/java/com/enofex/naikan/overview/developer/OverviewDeveloperController.java +++ b/naikan-web/src/main/java/com/enofex/naikan/overview/developer/OverviewDeveloperController.java @@ -26,8 +26,7 @@ class OverviewDeveloperController { } @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll(Filterable filterable, - Pageable pageable) { + public ResponseEntity> findAll(Filterable filterable, Pageable pageable) { return ResponseEntity.ok(this.overviewDeveloperService.findAll(filterable, pageable)); } } diff --git a/naikan-web/src/main/java/com/enofex/naikan/overview/environment/OverviewEnvironmentController.java b/naikan-web/src/main/java/com/enofex/naikan/overview/environment/OverviewEnvironmentController.java index b0fc7721..bdd1f10b 100644 --- a/naikan-web/src/main/java/com/enofex/naikan/overview/environment/OverviewEnvironmentController.java +++ b/naikan-web/src/main/java/com/enofex/naikan/overview/environment/OverviewEnvironmentController.java @@ -28,10 +28,8 @@ class OverviewEnvironmentController { } @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll(Filterable filterable, - Pageable pageable) { - return ResponseEntity.ok( - this.overviewEnvironmentService.findAll(filterable, pageable)); + public ResponseEntity> findAll(Filterable filterable, Pageable pageable) { + return ResponseEntity.ok(this.overviewEnvironmentService.findAll(filterable, pageable)); } @GetMapping(path = "/top/{topN}", produces = MediaType.APPLICATION_JSON_VALUE) diff --git a/naikan-web/src/main/java/com/enofex/naikan/overview/integration/OverviewIntegrationController.java b/naikan-web/src/main/java/com/enofex/naikan/overview/integration/OverviewIntegrationController.java index 9708472e..74c026e9 100644 --- a/naikan-web/src/main/java/com/enofex/naikan/overview/integration/OverviewIntegrationController.java +++ b/naikan-web/src/main/java/com/enofex/naikan/overview/integration/OverviewIntegrationController.java @@ -26,9 +26,7 @@ class OverviewIntegrationController { } @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll(Filterable filterable, - Pageable pageable) { - return ResponseEntity.ok( - this.overviewIntegrationService.findAll(filterable, pageable)); + public ResponseEntity> findAll(Filterable filterable, Pageable pageable) { + return ResponseEntity.ok(this.overviewIntegrationService.findAll(filterable, pageable)); } } diff --git a/naikan-web/src/main/java/com/enofex/naikan/overview/tag/OverviewTagController.java b/naikan-web/src/main/java/com/enofex/naikan/overview/tag/OverviewTagController.java new file mode 100644 index 00000000..2b5b86bf --- /dev/null +++ b/naikan-web/src/main/java/com/enofex/naikan/overview/tag/OverviewTagController.java @@ -0,0 +1,40 @@ +package com.enofex.naikan.overview.tag; + + +import static com.enofex.naikan.overview.tag.OverviewTagController.REQUEST_PATH; + +import com.enofex.naikan.Filterable; +import com.enofex.naikan.overview.OverviewGroup; +import com.enofex.naikan.overview.OverviewRequest; +import com.enofex.naikan.overview.OverviewTopGroups; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(REQUEST_PATH) +class OverviewTagController { + + static final String REQUEST_PATH = OverviewRequest.PATH + "/tags"; + + private final OverviewTagService overviewTagService; + + OverviewTagController(OverviewTagService overviewTagService) { + this.overviewTagService = overviewTagService; + } + + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> findAll(Filterable filterable, Pageable pageable) { + return ResponseEntity.ok(this.overviewTagService.findAll(filterable, pageable)); + } + + @GetMapping(path = "/top/{topN}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findTopTags(@PathVariable long topN) { + return ResponseEntity.ok(this.overviewTagService.findTopTags(topN)); + } +} diff --git a/naikan-web/src/main/java/com/enofex/naikan/overview/team/OverviewTeamController.java b/naikan-web/src/main/java/com/enofex/naikan/overview/team/OverviewTeamController.java index 1da40d4e..b4a95607 100644 --- a/naikan-web/src/main/java/com/enofex/naikan/overview/team/OverviewTeamController.java +++ b/naikan-web/src/main/java/com/enofex/naikan/overview/team/OverviewTeamController.java @@ -28,8 +28,7 @@ class OverviewTeamController { } @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll(Filterable filterable, - Pageable pageable) { + public ResponseEntity> findAll(Filterable filterable, Pageable pageable) { return ResponseEntity.ok(this.overviewTeamService.findAll(filterable, pageable)); } diff --git a/naikan-web/src/main/java/com/enofex/naikan/overview/technology/OverviewTechnologyController.java b/naikan-web/src/main/java/com/enofex/naikan/overview/technology/OverviewTechnologyController.java index 64edb958..275b21a4 100644 --- a/naikan-web/src/main/java/com/enofex/naikan/overview/technology/OverviewTechnologyController.java +++ b/naikan-web/src/main/java/com/enofex/naikan/overview/technology/OverviewTechnologyController.java @@ -27,8 +27,7 @@ class OverviewTechnologyController { } @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> findAll(Filterable filterable, - Pageable pageable) { + public ResponseEntity> findAll(Filterable filterable, Pageable pageable) { return ResponseEntity.ok(this.overviewTechnologyService.findAll(filterable, pageable)); } diff --git a/naikan-web/src/test/java/com/enofex/naikan/overview/tag/OverviewTagControllerIT.java b/naikan-web/src/test/java/com/enofex/naikan/overview/tag/OverviewTagControllerIT.java new file mode 100644 index 00000000..c087ac18 --- /dev/null +++ b/naikan-web/src/test/java/com/enofex/naikan/overview/tag/OverviewTagControllerIT.java @@ -0,0 +1,53 @@ +package com.enofex.naikan.overview.tag; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.handler; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.enofex.naikan.model.deserializer.DeserializerFactory; +import com.enofex.naikan.test.IntegrationTest; +import com.enofex.naikan.test.model.Boms; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.mongodb.core.MongoTemplate; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.MockMvc; + +@IntegrationTest +class OverviewTagControllerIT { + + @Autowired + private MockMvc mvc; + @Autowired + private MongoTemplate template; + + @BeforeEach + void setUp() { + this.template.save(DeserializerFactory.newJsonDeserializer().of(Boms.validBom0asInputStream()), + "projects"); + } + + @Test + void shouldFindAll() throws Exception { + this.mvc.perform( + get("/api/overview/tags")) + .andExpect(handler().methodName("findAll")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$.content.length()").value(2)); + } + + @Test + void shouldFindOverviewTopTags() throws Exception { + this.mvc.perform( + get("/api/overview/tags/top/5")) + .andExpect(handler().methodName("findTopTags")) + .andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$.length()").value(2)); + } + +} \ No newline at end of file