Skip to content

Commit

Permalink
Improve naming to be mor specific
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Käser committed Mar 21, 2024
1 parent aa4d904 commit 016bb2f
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 62 deletions.
5 changes: 2 additions & 3 deletions backend/src/main/java/ch/puzzle/okr/OkrApplication.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package ch.puzzle.okr;

import ch.puzzle.okr.service.clientconfig.ClientConfigProperties;
import ch.puzzle.okr.service.clientcustomization.ClientCustomizationProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableScheduling
@EnableConfigurationProperties(ClientConfigProperties.class)
@EnableConfigurationProperties(ClientCustomizationProperties.class)
public class OkrApplication {
public static void main(String[] args) {
SpringApplication.run(OkrApplication.class, args);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ch.puzzle.okr.controller;

import ch.puzzle.okr.dto.ClientConfigDto;
import ch.puzzle.okr.service.clientconfig.ClientConfigService;
import ch.puzzle.okr.service.clientcustomization.ClientConfigService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package ch.puzzle.okr.service.clientconfig;
package ch.puzzle.okr.service.clientcustomization;

import ch.puzzle.okr.dto.ClientConfigDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class ClientConfigService {

Expand All @@ -19,16 +15,16 @@ public class ClientConfigService {

@Value("${spring.security.oauth2.resourceserver.opaquetoken.client-id}")
private String clientId;
private final ClientConfigProperties clientConfigProperties;
private final ClientCustomizationProperties clientCustomizationProperties;

public ClientConfigService(ClientConfigProperties clientConfigProperties) {
this.clientConfigProperties = clientConfigProperties;
public ClientConfigService(ClientCustomizationProperties clientCustomizationProperties) {
this.clientCustomizationProperties = clientCustomizationProperties;
}

public ClientConfigDto getConfigBasedOnActiveEnv() {
return new ClientConfigDto(activeProfile, issuer, clientId, this.clientConfigProperties.getFavicon(),
this.clientConfigProperties.getLogo(), this.clientConfigProperties.getTitle(),
this.clientConfigProperties.getCustomStyles());
return new ClientConfigDto(activeProfile, issuer, clientId, this.clientCustomizationProperties.getFavicon(),
this.clientCustomizationProperties.getLogo(), this.clientCustomizationProperties.getTitle(),
this.clientCustomizationProperties.getCustomStyles());
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package ch.puzzle.okr.service.clientconfig;
package ch.puzzle.okr.service.clientcustomization;

import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashMap;

@ConfigurationProperties("okr.clientconfig")
public class ClientConfigProperties {
@ConfigurationProperties("okr.clientcustomization")
public class ClientCustomizationProperties {
private String favicon;
private String logo;
private String title;
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/application-staging.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ logging.level.org.springframework=debug
spring.security.oauth2.resourceserver.opaquetoken.client-id=pitc_okr_staging

okr.user.champion.usernames=peggimann
okr.clientconfig.customstyles.okr-topbar-background-color=#ab31ad
okr.clientcustomization.customstyles.okr-topbar-background-color=#ab31ad
6 changes: 3 additions & 3 deletions backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ okr.jwt.user.firstname=given_name
okr.jwt.user.lastname=family_name
okr.jwt.user.email=email

okr.clientconfig.favicon=assets/favicon.png
okr.clientconfig.logo=assets/images/okr-logo.svg
okr.clientconfig.title=Puzzle OKR
okr.clientcustomization.favicon=assets/favicon.png
okr.clientcustomization.logo=assets/images/okr-logo.svg
okr.clientcustomization.title=Puzzle OKR
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package ch.puzzle.okr.controller;

import ch.puzzle.okr.service.clientconfig.ClientConfigService;
import ch.puzzle.okr.service.clientcustomization.ClientConfigService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ch.puzzle.okr.service;

import ch.puzzle.okr.dto.ClientConfigDto;
import ch.puzzle.okr.service.clientconfig.ClientConfigService;
import ch.puzzle.okr.service.clientcustomization.ClientConfigService;
import ch.puzzle.okr.test.SpringIntegrationTest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
38 changes: 0 additions & 38 deletions frontend/src/app/shared/services/chustomization.service.spec.ts

This file was deleted.

41 changes: 41 additions & 0 deletions frontend/src/app/shared/services/customization.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { TestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { CustomizationService } from './customization.service';
import { DOCUMENT } from '@angular/common';
import { ConfigService } from '../../config.service';
import { Observable, of } from 'rxjs';

describe('CustomizationService', () => {
let service: CustomizationService;

const body = {
title: 'title',
favicon: 'favicon',
logo: 'logo',
customStyles: { cssVar1: 'foo' },
};

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [
{ provide: DOCUMENT, useValue: undefined },
{
provide: ConfigService,
useValue: {
config$: of(body),
},
},
],
});
service = TestBed.inject(CustomizationService);
});

it('should be created', () => {
const currentConfig = service.getCurrentConfig();
expect(currentConfig?.title).toBe(body.title);
expect(currentConfig?.logo).toBe(body.logo);
expect(currentConfig?.favicon).toBe(body.favicon);
expect(currentConfig?.customStyles['cssVar1']).toBe(body.customStyles['cssVar1']);
});
});

0 comments on commit 016bb2f

Please sign in to comment.