use of com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage in project cloud-pipeline by epam.
the class RoleDaoTest method shouldUpdateStorage.
@Test
public void shouldUpdateStorage() {
Role testRole = roleDao.createRole(TEST_ROLE);
S3bucketDataStorage s3bucketDataStorage = ObjectCreatorUtils.createS3Bucket(null, TEST_STORAGE_PATH, TEST_STORAGE_PATH, TEST_USER1);
dataStorageDao.createDataStorage(s3bucketDataStorage);
testRole.setUserDefault(true);
testRole.setDefaultStorageId(s3bucketDataStorage.getId());
testRole.setName(TEST_ROLE_UPDATED);
roleDao.updateRole(testRole);
Optional<Role> loaded = roleDao.loadRole(testRole.getId());
assertThat(loaded.isPresent(), equalTo(true));
Role role = loaded.get();
assertThat(role.getName(), equalTo(TEST_ROLE_UPDATED));
assertThat(role.getDefaultStorageId(), equalTo(s3bucketDataStorage.getId()));
assertThat(role.isUserDefault(), equalTo(true));
}
use of com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage in project cloud-pipeline by epam.
the class UserDaoTest method shouldReturnUserByStorageId.
@Test
public void shouldReturnUserByStorageId() {
S3bucketDataStorage s3bucketDataStorage = ObjectCreatorUtils.createS3Bucket(null, "test", "test", TEST_USER1);
dataStorageDao.createDataStorage(s3bucketDataStorage);
PipelineUser user = new PipelineUser();
user.setUserName(TEST_USER1);
user.setDefaultStorageId(s3bucketDataStorage.getId());
userDao.createUser(user, Arrays.asList(DefaultRoles.ROLE_ADMIN.getId(), DefaultRoles.ROLE_USER.getId()));
Assert.assertThat(userDao.loadUsersByStorageId(s3bucketDataStorage.getId()), hasSize(1));
}
use of com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage in project cloud-pipeline by epam.
the class ObjectCreatorUtils method clone.
public static S3bucketDataStorage clone(S3bucketDataStorage s3Bucket) {
S3bucketDataStorage storage = new S3bucketDataStorage(s3Bucket.getId(), s3Bucket.getName(), s3Bucket.getPath(), s3Bucket.getStoragePolicy(), s3Bucket.getMountPoint());
storage.setParentFolderId(s3Bucket.getParentFolderId());
storage.setParent(s3Bucket.getParent());
storage.setMountOptions(s3Bucket.getMountOptions());
storage.setOwner(s3Bucket.getOwner());
storage.setDescription(s3Bucket.getDescription());
storage.setRegionId(s3Bucket.getRegionId());
storage.setAllowedCidrs(new ArrayList<>(s3Bucket.getAllowedCidrs()));
return storage;
}
use of com.epam.pipeline.entity.datastorage.aws.S3bucketDataStorage in project cloud-pipeline by epam.
the class DataStorageEventServiceTest method shouldAddS3Event.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldAddS3Event() {
doNothing().when(entityManager).setManagers(anyListOf(SecuredEntityManager.class));
when(issueManager.loadIssuesForEntity(any())).thenReturn(Arrays.asList(Issue.builder().id(1L).build(), Issue.builder().id(2L).build()));
when(dataStorageManager.load(1L)).thenReturn(new S3bucketDataStorage(1L, "", ""));
doNothing().when(eventDao).insertUpdateEvent(anyString(), anyLong());
dataStorageEventService.updateEventsWithChildrenAndIssues(1L);
verify(eventDao).insertUpdateEvent("S3", 1L);
verify(eventDao).insertUpdateEvent(ISSUE, 1L);
verify(eventDao).insertUpdateEvent(ISSUE, 2L);
verifyNoMoreInteractions(eventDao);
}
Aggregations