Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI config / Fix checks on creation. #13

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ public void testRun() {
userTmp.setUsername(greatestProfileUser.getUsername().toLowerCase());

migration.run(_applicationContext);
assertNull(_userRepo.findById(user1.getId()).get());
assertNull(_userRepo.findById(user2.getId()).get());
assertNull(_userRepo.findById(user3.getId()).get());
assertFalse(_userRepo.findById(user1.getId()).isPresent());
assertFalse(_userRepo.findById(user2.getId()).isPresent());
assertFalse(_userRepo.findById(user3.getId()).isPresent());
User mergedUser = _userRepo.findById(greatestProfileUser.getId()).get();
assertNotNull(mergedUser);
assertEquals(userTmp.getUsername(), mergedUser.getUsername());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public void testDeleteAllSpec() throws Exception {
assertEquals(1, _repo.count());

assertNotNull(_repo.findById(md.getId()).get());
assertNull(_repo.findById(md2.getId()).get());
assertNull(_repo.findById(md3.getId()).get());
assertFalse(_repo.findById(md2.getId()).isPresent());
assertFalse(_repo.findById(md3.getId()).isPresent());

assertEquals(md.getId(), _repo.findAll().get(0).getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public void testDeleteAllById() {
assertEquals(1, found.size());
assertEquals(history2.getId(), found.get(0).getId());

assertNull(_repo.findById(history1.getId()).get());
assertFalse(_repo.findById(history1.getId()).isPresent());
}

private HarvestHistory newHarvestHistory() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void testFindByIdString() throws Exception {

assertSameContents(metadata, _repo.findById(metadata.getId()).get());

assertNull(_repo.findById(213213215).get());
assertFalse(_repo.findById(213213215).isPresent());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -88,8 +89,8 @@ public void testDeleteAllById_MetadataId() throws Exception {
assertEquals(3, _repo.count());
_repo.deleteAllById_MetadataId(status1.getId().getMetadataId());
assertEquals(1, _repo.count());
assertNull(_repo.findById(status1.getId()).get());
assertNull(_repo.findById(status2.getId()).get());
assertFalse(_repo.findById(status1.getId()).isPresent());
assertFalse(_repo.findById(status2.getId()).isPresent());

final List<MetadataStatus> all = _repo.findAll();
assertEquals(1, all.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.*;

/**
* Test the MetadataValidationRepository class User: Jesse Date: 9/4/13 Time: 4:01 PM
Expand Down Expand Up @@ -93,7 +92,7 @@ public void testDeleteAllById_MetadataId() throws Exception {
final List<MetadataValidation> all = _metadataValidationRepository.findAll();
assertEquals(1, all.size());
assertEquals(val3.getId(), all.get(0).getId());
assertNull(_metadataValidationRepository.findById(val1.getId()).get());
assertFalse(_metadataValidationRepository.findById(val1.getId()).isPresent());
}

private MetadataValidation newValidation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void testDeleteByMetadataId() {
assertFalse(opAllowedFound.contains(_opAllowed3));
assertFalse(opAllowedFound.contains(_opAllowed4));

assertNull(_opAllowRepo.findById(_opAllowed1.getId()).get());
assertFalse(_opAllowRepo.findById(_opAllowed1.getId()).isPresent());
}


Expand All @@ -151,7 +151,7 @@ public void testDeleteByGroupId() {
assertTrue(opAllowedFound.contains(_opAllowed3));
assertTrue(opAllowedFound.contains(_opAllowed4));

assertNull(_opAllowRepo.findById(_opAllowed1.getId()).get());
assertFalse(_opAllowRepo.findById(_opAllowed1.getId()).isPresent());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public void testFindOne() {
Translations info2 = newTranslations();
info2 = _repo.save(info2);

assertEquals(info2, _repo.findById(info2.getId()));
assertEquals(info1, _repo.findById(info1.getId()));
assertEquals(info2, _repo.findById(info2.getId()).get());
assertEquals(info1, _repo.findById(info1.getId()).get());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void testDeleteAllWithUserIdsIn() {
assertTrue(_repo.existsById(ug3.getId()));
assertTrue(_repo.existsById(ug4.getId()));

assertNull(_repo.findById(ug1.getId()).get());
assertFalse(_repo.findById(ug1.getId()).isPresent());
}

private UserGroup newUserGroup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import javax.servlet.http.HttpSession;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

@RequestMapping(value = {
Expand Down Expand Up @@ -121,8 +122,8 @@ public ResponseEntity<String> putUiConfiguration(
));
}

UiSetting one = uiSettingsRepository.findById(uiConfiguration.getId()).get();
if (one != null) {
Optional<UiSetting> one = uiSettingsRepository.findById(uiConfiguration.getId());
if (one.isPresent()) {
throw new IllegalArgumentException(String.format(
"A UI configuration with id '%d' already exist", uiConfiguration.getId()
));
Expand Down Expand Up @@ -157,14 +158,14 @@ public UiSetting getUiConfiguration(
@PathVariable
String uiIdentifier
) throws Exception {
UiSetting uiConfiguration = uiSettingsRepository.findById(uiIdentifier).get();
if (uiConfiguration == null) {
Optional<UiSetting> uiConfiguration = uiSettingsRepository.findById(uiIdentifier);
if (!uiConfiguration.isPresent()) {
throw new ResourceNotFoundException(String.format(
"UI configuration with id '%s' does not exist.",
uiIdentifier
));
}
return uiConfiguration;
return uiConfiguration.get();
}


Expand Down