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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user