• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wistefan / tmforum-api / #49

29 Sep 2023 06:20AM UTC coverage: 67.488% (-4.3%) from 71.815%
#49

push

web-flow
Notifications (#23)

* Squashed commits

* Added cache invalidation for entity deletion

* Updated error message

618 of 618 new or added lines in 86 files covered. (100.0%)

2794 of 4140 relevant lines covered (67.49%)

0.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/common/src/main/java/org/fiware/tmforum/common/notification/command/StateChangeEventCommand.java
1
package org.fiware.tmforum.common.notification.command;
2

3
import lombok.RequiredArgsConstructor;
4

5
import java.lang.reflect.InvocationTargetException;
6

7
@RequiredArgsConstructor
×
8
public class StateChangeEventCommand<T> implements Command {
9
    private final T newState;
10
    private final T oldState;
11

12
    @Override
13
    public boolean execute(String query) {
14
        return hasEntityStateChanged(oldState, newState);
×
15
    }
16

17
    private boolean hasEntityStateChanged(T oldState, T newState) {
18
        Object oldStateFieldValue = getEntityState(oldState);
×
19
        Object newStateFieldValue = getEntityState(newState);
×
20

21
        return oldStateFieldValue == null && newStateFieldValue != null ||
×
22
                oldStateFieldValue != null && newStateFieldValue == null ||
23
                oldStateFieldValue != null && !oldStateFieldValue.equals(newStateFieldValue) ||
×
24
                newStateFieldValue != null && !newStateFieldValue.equals(oldStateFieldValue);
×
25
    }
26

27
    private Object getEntityState(T entity) {
28
        Object stateFieldValue;
29
        try {
30
            stateFieldValue = entity.getClass().getMethod("getEntityState").invoke(entity);
×
31
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
×
32
            stateFieldValue = null;
×
33
        }
×
34
        return stateFieldValue;
×
35
    }
36
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc