use of org.eclipse.sirius.web.persistence.entities.AccountEntity in project sirius-web by eclipse-sirius.
the class AccountRepositoryIntegrationTests method testInsertAndRetrieveAnAccount.
@Test
@Transactional
public void testInsertAndRetrieveAnAccount() {
AccountEntity account = new AccountEntity();
account.setUsername(FIRST_USERNAME);
account.setPassword(FIRST_PASSWORD);
account.setRole(USER);
AccountEntity savedAccount = this.accountRepository.save(account);
assertThat(savedAccount.getId()).isNotNull();
var optionalAccountFound = this.accountRepository.findById(savedAccount.getId());
assertThat(optionalAccountFound.isPresent()).isTrue();
optionalAccountFound.ifPresent(accountFound -> {
assertThat(accountFound.getId()).isNotNull();
assertThat(accountFound.getUsername()).isEqualTo(FIRST_USERNAME);
assertThat(accountFound.getPassword()).isEqualTo(FIRST_PASSWORD);
});
}
use of org.eclipse.sirius.web.persistence.entities.AccountEntity in project sirius-web by eclipse-sirius.
the class ProjectRepositoryIntegrationTests method testDefaultProjectVisibilityIsPublic.
@Test
@Transactional
public void testDefaultProjectVisibilityIsPublic() {
AccountEntity owner = this.createAndSaveUser(FIRST_OWNER_NAME);
ProjectEntity project = new ProjectEntity();
project.setName(FIRST_PROJECT_NAME);
project.setOwner(owner);
project.setVisibility(VisibilityEntity.PUBLIC);
var savedProject = this.projectRepository.save(project);
assertThat(savedProject.getId()).isNotNull();
var optionalProjectFound = this.projectRepository.findById(savedProject.getId());
assertThat(optionalProjectFound.isPresent()).isTrue();
optionalProjectFound.ifPresent(projectFound -> {
assertThat(projectFound.getId()).isNotNull();
assertThat(projectFound.getName()).isEqualTo(FIRST_PROJECT_NAME);
assertThat(projectFound.getVisibility()).isSameAs(VisibilityEntity.PUBLIC);
});
}
use of org.eclipse.sirius.web.persistence.entities.AccountEntity in project sirius-web by eclipse-sirius.
the class RepresentationRepositoryIntegrationTests method createAndSaveProjectEntity.
private ProjectEntity createAndSaveProjectEntity() {
AccountEntity owner = new AccountEntity();
owner.setUsername(OWNER_NAME);
owner.setPassword(OWNER_NAME);
owner.setRole(ROLE_USER);
AccountEntity savedOwner = this.accountRepository.save(owner);
ProjectEntity project = new ProjectEntity();
project.setName(FIRST_PROJECT_NAME);
project.setOwner(savedOwner);
ProjectEntity savedProject = this.projectRepository.save(project);
return savedProject;
}
use of org.eclipse.sirius.web.persistence.entities.AccountEntity in project sirius-web by eclipse-sirius.
the class RepresentationRepositoryIntegrationTests method testFindByIdAndProjectId.
@Test
@Transactional
public void testFindByIdAndProjectId() {
AccountEntity owner = new AccountEntity();
owner.setUsername(OWNER_NAME);
owner.setPassword(OWNER_NAME);
owner.setRole(ROLE_USER);
AccountEntity savedOwner = this.accountRepository.save(owner);
ProjectEntity firstProject = new ProjectEntity();
firstProject.setName(FIRST_PROJECT_NAME);
firstProject.setOwner(savedOwner);
ProjectEntity savedFirstProject = this.projectRepository.save(firstProject);
ProjectEntity secondProject = new ProjectEntity();
secondProject.setName(SECOND_PROJECT_NAME);
secondProject.setOwner(savedOwner);
ProjectEntity savedSecondProject = this.projectRepository.save(secondProject);
RepresentationEntity firstRepresentationEntity = this.createRepresentationEntity(savedFirstProject, FIRST_DIAGRAM_LABEL, FIRST_TARGET_OBJECT_ID);
this.representationRepository.save(firstRepresentationEntity);
RepresentationEntity secondRepresentationEntity = this.createRepresentationEntity(savedSecondProject, SECOND_DIAGRAM_LABEL, FIRST_TARGET_OBJECT_ID);
this.representationRepository.save(secondRepresentationEntity);
var optionalFirstRepresentationEntity = this.representationRepository.findByIdAndProjectId(firstRepresentationEntity.getId(), firstProject.getId());
var optionalNotFoundFirstRepresentationEntity = this.representationRepository.findByIdAndProjectId(firstRepresentationEntity.getId(), secondProject.getId());
var optionalSecondRepresentationEntity = this.representationRepository.findByIdAndProjectId(secondRepresentationEntity.getId(), secondProject.getId());
var optionalNotFoundSecondRepresentationEntity = this.representationRepository.findByIdAndProjectId(secondRepresentationEntity.getId(), firstProject.getId());
assertThat(optionalFirstRepresentationEntity).isPresent();
assertThat(optionalSecondRepresentationEntity).isPresent();
assertThat(optionalNotFoundFirstRepresentationEntity).isEmpty();
assertThat(optionalNotFoundSecondRepresentationEntity).isEmpty();
}
use of org.eclipse.sirius.web.persistence.entities.AccountEntity in project sirius-web by eclipse-sirius.
the class AccountRepositoryIntegrationTests method testFindByUsername.
@Test
@Transactional
public void testFindByUsername() {
AccountEntity account = new AccountEntity();
account.setUsername(SECOND_USERNAME);
account.setPassword(SECOND_PASSWORD);
account.setRole(USER);
this.accountRepository.save(account);
var optionalAccountFound = this.accountRepository.findByUsername(SECOND_USERNAME);
assertThat(optionalAccountFound.isPresent()).isTrue();
optionalAccountFound.ifPresent(accountFound -> {
assertThat(accountFound.getId()).isNotNull();
assertThat(accountFound.getUsername()).isEqualTo(SECOND_USERNAME);
assertThat(accountFound.getPassword()).isEqualTo(SECOND_PASSWORD);
});
}
Aggregations