@Test public void isAuthorized() { when(commandAuthorizationRepository.find(CHARGING_STATION_ID.getId(), USER_IDENTITY.getId(), COMMAND_CLASS)).thenReturn(new CommandAuthorization(new CommandAuthorizationId(CHARGING_STATION_ID.getId(), USER_IDENTITY.getId(), AcceptChargingStationCommand.class))); assertTrue(commandAuthorizationService.isAuthorized(CHARGING_STATION_ID, USER_IDENTITY, COMMAND_CLASS)); }
public boolean isAuthorized(ChargingStationId chargingStationId, UserIdentity userIdentity, Class commandClass) { boolean isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), commandClass) != null; if (!isAuthorized) { isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), AllPermissions.class) != null; } return isAuthorized; }
CommandAuthorizationService { public boolean isAuthorized(ChargingStationId chargingStationId, UserIdentity userIdentity, Class commandClass) { boolean isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), commandClass) != null; if (!isAuthorized) { isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), AllPermissions.class) != null; } return isAuthorized; } }
CommandAuthorizationService { public boolean isAuthorized(ChargingStationId chargingStationId, UserIdentity userIdentity, Class commandClass) { boolean isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), commandClass) != null; if (!isAuthorized) { isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), AllPermissions.class) != null; } return isAuthorized; }  }
CommandAuthorizationService { public boolean isAuthorized(ChargingStationId chargingStationId, UserIdentity userIdentity, Class commandClass) { boolean isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), commandClass) != null; if (!isAuthorized) { isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), AllPermissions.class) != null; } return isAuthorized; }  boolean isAuthorized(ChargingStationId chargingStationId, UserIdentity userIdentity, Class commandClass); void setCommandAuthorizationRepository(CommandAuthorizationRepository commandAuthorizationRepository); }
CommandAuthorizationService { public boolean isAuthorized(ChargingStationId chargingStationId, UserIdentity userIdentity, Class commandClass) { boolean isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), commandClass) != null; if (!isAuthorized) { isAuthorized = commandAuthorizationRepository.find(chargingStationId.getId(), userIdentity.getId(), AllPermissions.class) != null; } return isAuthorized; }  boolean isAuthorized(ChargingStationId chargingStationId, UserIdentity userIdentity, Class commandClass); void setCommandAuthorizationRepository(CommandAuthorizationRepository commandAuthorizationRepository);  }