hawkBit repository uses Optional on single entity find/get requests (#435)

* Repo returns optionals.
* Improved exception handling for collection usage in repo queries.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2017-02-16 10:09:14 +01:00
committed by GitHub
parent d21af83804
commit 804522f966
232 changed files with 2104 additions and 2377 deletions

View File

@@ -137,7 +137,7 @@ public class EventType {
*/
public static EventType from(final Class<?> clazz) {
final Optional<Integer> foundEventType = TYPES.entrySet().stream()
.filter(entry -> entry.getValue().equals(clazz)).map(entry -> entry.getKey()).findFirst();
.filter(entry -> entry.getValue().equals(clazz)).map(entry -> entry.getKey()).findAny();
if (!foundEventType.isPresent()) {
return null;
}

View File

@@ -8,15 +8,15 @@
*/
package org.eclipse.hawkbit.event;
import static org.fest.assertions.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import org.assertj.core.api.Assertions;
import org.eclipse.hawkbit.repository.event.remote.entity.RemoteEntityEvent;
import org.eclipse.hawkbit.repository.event.remote.entity.TargetCreatedEvent;
import org.eclipse.hawkbit.repository.model.Target;
import org.fest.assertions.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;