import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.onap.portal.controller.WidgetsCatalogController;
+import org.onap.portal.dao.fn.FnLanguageDao;
import org.onap.portal.domain.db.ep.EpMicroserviceParameter;
import org.onap.portal.domain.db.ep.EpWidgetCatalog;
import org.onap.portal.domain.db.ep.EpWidgetCatalogParameter;
import org.onap.portal.domain.db.fn.FnLanguage;
import org.onap.portal.domain.db.fn.FnUser;
import org.onap.portal.service.fn.FnLanguageService;
+import org.onap.portal.service.fn.FnUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
@TestPropertySource(locations = "classpath:test.properties")
class EpWidgetCatalogParameterServiceTest {
- private UsernamePasswordAuthenticationToken principal = new UsernamePasswordAuthenticationToken("demo",
+ private final UsernamePasswordAuthenticationToken principal = new UsernamePasswordAuthenticationToken("demo",
"demo123");
- private EpWidgetCatalogParameterService epWidgetCatalogParameterService;
- private WidgetsCatalogController widgetsCatalogController;
- private FnLanguageService fnLanguageService;
- private EpMicroserviceParameterService epMicroserviceParameterService;
- private EpWidgetCatalogService epWidgetCatalogService;
+ private final EpWidgetCatalogParameterService epWidgetCatalogParameterService;
+ private final WidgetsCatalogController widgetsCatalogController;
+ private final FnUserService fnUserService;
+ private final EpMicroserviceParameterService epMicroserviceParameterService;
+ private final EpWidgetCatalogService epWidgetCatalogService;
+ private final FnLanguageDao fnLanguageDao;
@Autowired
public EpWidgetCatalogParameterServiceTest(
- EpWidgetCatalogParameterService epWidgetCatalogParameterService,
- WidgetsCatalogController widgetsCatalogController,
- FnLanguageService fnLanguageService,
- EpMicroserviceParameterService epMicroserviceParameterService,
- EpWidgetCatalogService epWidgetCatalogService) {
+ EpWidgetCatalogParameterService epWidgetCatalogParameterService,
+ WidgetsCatalogController widgetsCatalogController,
+ FnUserService fnUserService,
+ EpMicroserviceParameterService epMicroserviceParameterService,
+ EpWidgetCatalogService epWidgetCatalogService, FnLanguageDao fnLanguageDao) {
this.epWidgetCatalogParameterService = epWidgetCatalogParameterService;
this.widgetsCatalogController = widgetsCatalogController;
- this.fnLanguageService = fnLanguageService;
+ this.fnUserService = fnUserService;
this.epMicroserviceParameterService = epMicroserviceParameterService;
this.epWidgetCatalogService = epWidgetCatalogService;
+ this.fnLanguageDao = fnLanguageDao;
}
@Test
epWidgetCatalogService.save(widget);
EpMicroserviceParameter parameter = new EpMicroserviceParameter();
epMicroserviceParameterService.save(parameter);
- FnLanguage language = FnLanguage.builder().languageAlias("TS").languageName("TEST").build();
- fnLanguageService.save(principal, language);
FnUser user = buildFnUser();
- language.setFnUsers(new HashSet<>(Collections.singleton(user)));
- user.setLanguageId(language);
+ fnUserService.saveFnUser(user);
EpWidgetCatalogParameter data = EpWidgetCatalogParameter.builder()
.widgetId(widget).userId(user).paramId(parameter).userValue("TestData").build();
//When
epWidgetCatalogService.save(widget);
EpMicroserviceParameter parameter = new EpMicroserviceParameter();
epMicroserviceParameterService.save(parameter);
- FnLanguage language = FnLanguage.builder().languageAlias("TS").languageName("TEST").build();
- fnLanguageService.save(principal, language);
FnUser user = buildFnUser();
- language.setFnUsers(new HashSet<>(Collections.singleton(user)));
- user.setLanguageId(language);
+ fnUserService.saveFnUser(user);
EpWidgetCatalogParameter data = EpWidgetCatalogParameter.builder()
.widgetId(widget).userId(user).paramId(parameter).userValue("TestData").build();
//When
epWidgetCatalogParameterService.saveUserParameter(data);
Long id = data.getId();
assertEquals(1, epWidgetCatalogParameterService.getUserParameterById(parameter.getId()).size());
- EpWidgetCatalogParameter actual = epWidgetCatalogParameterService.getUserParamById(widget.getWidgetId(), user.getUserId(), parameter.getId());
+ EpWidgetCatalogParameter actual = epWidgetCatalogParameterService.getUserParamById(widget.getWidgetId(), user.getId(), parameter.getId());
//Then
assertEquals(id, actual.getId());
assertEquals(data.getUserValue(), actual.getUserValue());
}
private FnUser buildFnUser() {
+ FnLanguage language = fnLanguageDao.getByLanguageAlias("EN");
return FnUser.builder()
.lastLoginDate(LocalDateTime.now())
.activeYn(true)
.isInternalYn(true)
.isSystemUser(true)
.guest(false)
+ .languageId(language)
.build();
}
}
\ No newline at end of file