fix mock test by mocking action and target
Signed-off-by: Michael Hirsch <michael.hirsch@bosch-si.com>
This commit is contained in:
@@ -50,6 +50,7 @@ import org.eclipse.hawkbit.repository.model.Action;
|
|||||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||||
|
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||||
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -429,14 +430,18 @@ public class AmqpMessageHandlerServiceTest {
|
|||||||
initalizeSecurityTokenGenerator();
|
initalizeSecurityTokenGenerator();
|
||||||
|
|
||||||
// Mock
|
// Mock
|
||||||
final JpaAction action = new JpaAction();
|
final JpaAction actionMock = mock(JpaAction.class);
|
||||||
action.setId(targetId);
|
final JpaTarget targetMock = mock(JpaTarget.class);
|
||||||
action.setStatus(status);
|
final TargetInfo targetInfoMock = mock(TargetInfo.class);
|
||||||
action.setTenant("DEFAULT");
|
when(actionMock.getId()).thenReturn(targetId);
|
||||||
final JpaTarget target = new JpaTarget("target1");
|
when(actionMock.getStatus()).thenReturn(status);
|
||||||
action.setTarget(target);
|
when(actionMock.getTenant()).thenReturn("DEFAULT");
|
||||||
|
when(actionMock.getTarget()).thenReturn(targetMock);
|
||||||
return action;
|
when(targetMock.getControllerId()).thenReturn("target1");
|
||||||
|
when(targetMock.getSecurityToken()).thenReturn("securityToken");
|
||||||
|
when(targetMock.getTargetInfo()).thenReturn(targetInfoMock);
|
||||||
|
when(targetInfoMock.getAddress()).thenReturn(null);
|
||||||
|
return actionMock;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initalizeSecurityTokenGenerator() throws IllegalAccessException {
|
private void initalizeSecurityTokenGenerator() throws IllegalAccessException {
|
||||||
|
|||||||
Reference in New Issue
Block a user