mirror of
https://github.com/Telecominfraproject/wlan-cloud-services.git
synced 2026-03-20 22:39:22 +00:00
Compare commits
8 Commits
WIFI-4732-
...
WIFI-5424
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83e4f3613a | ||
|
|
aa77c4a2d5 | ||
|
|
3a4561b323 | ||
|
|
7abc4c8554 | ||
|
|
34bec5009a | ||
|
|
824568a128 | ||
|
|
5211ed7e68 | ||
|
|
1bffb4f96a |
@@ -634,7 +634,7 @@ public class AllInOneStartListener implements ApplicationRunner {
|
||||
((PasspointProfile) passpointHotspotConfig.getDetails()).setPasspointVenueProfileId(passpointVenueProfileId);
|
||||
((PasspointProfile) passpointHotspotConfig.getDetails()).setOsuSsidProfileId(profileSsidOpenId);
|
||||
((PasspointProfile) passpointHotspotConfig.getDetails())
|
||||
.setAssociatedAccessSsidProfileIds(List.of(profileSsidPskId));
|
||||
.setAssociatedAccessSsidProfileIds(Set.of(profileSsidPskId));
|
||||
|
||||
return profileServiceInterface.create(passpointHotspotConfig);
|
||||
}
|
||||
|
||||
@@ -263,7 +263,8 @@ public class EquipmentDAO extends BaseJdbcDao {
|
||||
},
|
||||
keyHolder);
|
||||
}catch (DuplicateKeyException e) {
|
||||
throw new DsDuplicateEntityException(e);
|
||||
LOG.error("Duplicate equipment found", e);
|
||||
throw new DsDuplicateEntityException("Equipment with the assetId " + equipment.getInventoryId() + " already exists!");
|
||||
}
|
||||
|
||||
// keyHolder.getKey() now contains the generated key
|
||||
|
||||
@@ -88,12 +88,7 @@ public class EquipmentController {
|
||||
throw new DsDataValidationException("Equipment contains unsupported value");
|
||||
}
|
||||
|
||||
long ts = System.currentTimeMillis();
|
||||
if (equipment.getCreatedTimestamp() == 0) {
|
||||
equipment.setCreatedTimestamp(ts);
|
||||
}
|
||||
equipment.setLastModifiedTimestamp(ts);
|
||||
|
||||
updateValuesIfNeeded(equipment);
|
||||
Equipment ret = equipmentDatastore.create(equipment);
|
||||
|
||||
LOG.debug("Created Equipment {}", ret);
|
||||
@@ -104,7 +99,24 @@ public class EquipmentController {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
private void updateValuesIfNeeded(Equipment equipment) {
|
||||
// strip out whitespaces from user entered inventoryId and name strings
|
||||
if (equipment.getName() != null) {
|
||||
equipment.setName(equipment.getName().strip());
|
||||
}
|
||||
if (equipment.getInventoryId() != null) {
|
||||
equipment.setInventoryId(equipment.getInventoryId().strip());
|
||||
}
|
||||
|
||||
// Update timestamp
|
||||
long ts = System.currentTimeMillis();
|
||||
if (equipment.getCreatedTimestamp() == 0) {
|
||||
equipment.setCreatedTimestamp(ts);
|
||||
}
|
||||
equipment.setLastModifiedTimestamp(ts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves Equipment by id
|
||||
* @param equipmentId
|
||||
|
||||
@@ -71,11 +71,33 @@ public class EquipmentControllerTest {
|
||||
equipmentController.delete(ret.getId());
|
||||
|
||||
}
|
||||
|
||||
private void assertEqualEquipments(
|
||||
Equipment expected,
|
||||
Equipment actual) {
|
||||
|
||||
|
||||
@Test
|
||||
public void testEquipmentCRUD_ValidateSpaceInInputString() {
|
||||
|
||||
//Create new Equipment - success
|
||||
Equipment equipment = new Equipment();
|
||||
equipment.setName(" nameAndInventoryIdWithTrailingSpaces ");
|
||||
equipment.setInventoryId(" C4411EAA31F5 ");
|
||||
equipment.setEquipmentType(EquipmentType.AP);
|
||||
|
||||
Equipment ret = equipmentController.create(equipment);
|
||||
assertNotNull(ret);
|
||||
|
||||
ret = equipmentController.get(ret.getId());
|
||||
assertEqualEquipments(equipment, ret);
|
||||
|
||||
ret = equipmentController.getOrNull(ret.getId());
|
||||
assertEqualEquipments(equipment, ret);
|
||||
|
||||
assertNull(equipmentController.getOrNull(-1));
|
||||
|
||||
//Delete - success
|
||||
equipmentController.delete(ret.getId());
|
||||
|
||||
}
|
||||
|
||||
private void assertEqualEquipments(Equipment expected, Equipment actual) {
|
||||
assertEquals(expected.getName(), actual.getName());
|
||||
//TODO: add more fields to check here
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.telecominfraproject.wlan.location.models.events;
|
||||
|
||||
import com.telecominfraproject.wlan.core.model.json.interfaces.HasLocationId;
|
||||
import com.telecominfraproject.wlan.location.models.Location;
|
||||
import com.telecominfraproject.wlan.systemevent.models.CustomerEventWithPayload;
|
||||
|
||||
public class LocationChangedApImpactingEvent extends CustomerEventWithPayload<Location> implements HasLocationId {
|
||||
private static final long serialVersionUID = -8369849230866347412L;
|
||||
|
||||
public LocationChangedApImpactingEvent(Location location){
|
||||
super(location.getCustomerId(), location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLocationId() {
|
||||
if (getPayload() != null) {
|
||||
return getPayload().getId();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used by JSON
|
||||
*/
|
||||
public LocationChangedApImpactingEvent() {
|
||||
super(0, 0, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class LocationServiceRemoteTest extends BaseRemoteTest {
|
||||
location.setLocationType(LocationType.FLOOR);
|
||||
location.setCustomerId(getNextCustomerId());
|
||||
location.setName("testName_updated");
|
||||
location.setDetails(generateDetails(CountryCode.US));
|
||||
location.setDetails(generateDetails(CountryCode.CA));
|
||||
|
||||
Location retFromUpdate = testInterface.update(location);
|
||||
assertFieldEquals(location, retFromUpdate);
|
||||
@@ -95,6 +95,14 @@ public class LocationServiceRemoteTest extends BaseRemoteTest {
|
||||
// expected it
|
||||
}
|
||||
|
||||
//UPDATE test - fail because country code cannot be modified once created
|
||||
try {
|
||||
location.setDetails(generateDetails(CountryCode.US));
|
||||
testInterface.update(location);
|
||||
fail("failed to detect country code update");
|
||||
} catch (IllegalStateException e) {
|
||||
// expected it
|
||||
}
|
||||
|
||||
//DELETE Test
|
||||
testInterface.delete(ret.getId());
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundExcepti
|
||||
import com.telecominfraproject.wlan.location.datastore.LocationDatastore;
|
||||
import com.telecominfraproject.wlan.location.models.Location;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationAddedEvent;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationChangedApImpactingEvent;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationChangedEvent;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationRemovedEvent;
|
||||
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
|
||||
@@ -97,14 +96,15 @@ public class LocationServiceController {
|
||||
}
|
||||
|
||||
Location existingLocation = locationDatastore.get(location.getId());
|
||||
|
||||
if (location.needsToBeUpdatedOnDevice(existingLocation)) {
|
||||
throw new IllegalStateException("Cannot update location. Country code is not allow to modify once created.");
|
||||
}
|
||||
|
||||
Location ret = locationDatastore.update(location);
|
||||
|
||||
List<SystemEvent> events = new ArrayList<>();
|
||||
|
||||
if (ret.needsToBeUpdatedOnDevice(existingLocation)) {
|
||||
events.add(new LocationChangedApImpactingEvent(ret));
|
||||
}
|
||||
events.add(new LocationChangedEvent(ret));
|
||||
|
||||
publishEvents(events);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class PasspointProfile extends ProfileDetails implements PushableConfigur
|
||||
private boolean enable2pt4GHz;
|
||||
private boolean enable5GHz;
|
||||
|
||||
private List<Long> associatedAccessSsidProfileIds;
|
||||
private Set<Long> associatedAccessSsidProfileIds;
|
||||
|
||||
private Long osuSsidProfileId;
|
||||
|
||||
@@ -321,11 +321,11 @@ public class PasspointProfile extends ProfileDetails implements PushableConfigur
|
||||
this.passpointNetworkAuthenticationType = passpointNetworkAuthenticationType;
|
||||
}
|
||||
|
||||
public List<Long> getAssociatedAccessSsidProfileIds() {
|
||||
public Set<Long> getAssociatedAccessSsidProfileIds() {
|
||||
return associatedAccessSsidProfileIds;
|
||||
}
|
||||
|
||||
public void setAssociatedAccessSsidProfileIds(List<Long> associatedAccessSsidProfileIds) {
|
||||
public void setAssociatedAccessSsidProfileIds(Set<Long> associatedAccessSsidProfileIds) {
|
||||
this.associatedAccessSsidProfileIds = associatedAccessSsidProfileIds;
|
||||
}
|
||||
|
||||
|
||||
@@ -327,17 +327,16 @@ public class RfElementConfiguration extends BaseJsonModel {
|
||||
this.minAutoCellSize = minAutoCellSize;
|
||||
}
|
||||
|
||||
//Always return default value
|
||||
public Integer getMaxAutoCellSize() {
|
||||
if (maxAutoCellSize == null) {
|
||||
if (MAX_CELL_SIZE_MAP.containsKey(this.radioType)) {
|
||||
return MAX_CELL_SIZE_MAP.get(this.radioType);
|
||||
} else {
|
||||
return MAX_CELL_SIZE_MAP.get(RadioType.is2dot4GHz);
|
||||
}
|
||||
if (MAX_CELL_SIZE_MAP.containsKey(this.radioType)) {
|
||||
return MAX_CELL_SIZE_MAP.get(this.radioType);
|
||||
} else {
|
||||
return MAX_CELL_SIZE_MAP.get(RadioType.is2dot4GHz);
|
||||
}
|
||||
return maxAutoCellSize;
|
||||
}
|
||||
|
||||
// not allow user to configure
|
||||
public void setMaxAutoCellSize(Integer maxAutoCellSize) {
|
||||
this.maxAutoCellSize = maxAutoCellSize;
|
||||
}
|
||||
|
||||
@@ -93,4 +93,16 @@ public class RfConfigurationTests {
|
||||
assertEquals(Integer.valueOf(23), list2.get(2));
|
||||
assertEquals(Integer.valueOf(45), list2.get(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxAutoCellSize() {
|
||||
RfElementConfiguration rfConfig = RfElementConfiguration.createWithDefaults(RadioType.is5GHz);
|
||||
assertNotNull(rfConfig.getMaxAutoCellSize());
|
||||
|
||||
assertEquals(RfElementConfiguration.DEFAULT_MAX_CELL_SIZE_DB, rfConfig.getMaxAutoCellSize().intValue());
|
||||
|
||||
rfConfig.setMaxAutoCellSize(-93);
|
||||
//getMaxAutoCellSize always return default MaxAutoCellSize
|
||||
assertEquals(RfElementConfiguration.DEFAULT_MAX_CELL_SIZE_DB, rfConfig.getMaxAutoCellSize().intValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ import com.telecominfraproject.wlan.equipmentgateway.models.CEGWConfigChangeNoti
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWNewChannelRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCellSizeAttributesRequest;
|
||||
import com.telecominfraproject.wlan.equipmentgateway.service.EquipmentGatewayServiceInterface;
|
||||
import com.telecominfraproject.wlan.location.models.events.LocationChangedApImpactingEvent;
|
||||
import com.telecominfraproject.wlan.profile.ProfileServiceInterface;
|
||||
import com.telecominfraproject.wlan.profile.models.Profile;
|
||||
import com.telecominfraproject.wlan.profile.models.events.ProfileAddedEvent;
|
||||
@@ -92,7 +91,7 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|
||||
|| ser.getDetails() instanceof EquipmentChannelsChangedEvent || ser.getDetails() instanceof EquipmentCellSizeAttributesChangedEvent
|
||||
|| ser.getDetails() instanceof EquipmentRemovedEvent || ser.getDetails() instanceof ProfileAddedEvent
|
||||
|| ser.getDetails() instanceof ProfileChangedEvent || ser.getDetails() instanceof ProfileRemovedEvent
|
||||
|| ser.getDetails() instanceof LocationChangedApImpactingEvent || ser.getDetails() instanceof EquipmentCustomerChangedEvent);
|
||||
|| ser.getDetails() instanceof EquipmentCustomerChangedEvent);
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
@@ -133,9 +132,6 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|
||||
case "ProfileRemovedEvent":
|
||||
process((ProfileRemovedEvent) se);
|
||||
break;
|
||||
case "LocationChangedApImpactingEvent":
|
||||
process((LocationChangedApImpactingEvent) se);
|
||||
break;
|
||||
case "EquipmentCustomerChangedEvent":
|
||||
process((EquipmentCustomerChangedEvent) se);
|
||||
default:
|
||||
@@ -222,36 +218,6 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|
||||
LOG.debug("Finished processing profile {}", profile.getId());
|
||||
}
|
||||
|
||||
private void process(LocationChangedApImpactingEvent model) {
|
||||
LOG.debug("Processing LocationChangedApImpactingEvent {}", model.getPayload().getId());
|
||||
|
||||
Set<Long> locationIds = new HashSet<>(Arrays.asList(model.getPayload().getId()));
|
||||
|
||||
// go through all equipmentIds that reside in the specified location and trigger change config notification on
|
||||
// them
|
||||
PaginationContext<PairLongLong> context = new PaginationContext<>(100);
|
||||
|
||||
while (!context.isLastPage()) {
|
||||
PaginationResponse<PairLongLong> page = equipmentServiceInterface.getEquipmentIdsByLocationIds(locationIds, context);
|
||||
context = page.getContext();
|
||||
|
||||
Set<Long> equipmentIds = new HashSet<>();
|
||||
page.getItems().forEach(p -> equipmentIds.add(p.getValue2()));
|
||||
|
||||
// retrieve full equipment objects to get the inventory id
|
||||
List<Equipment> equipmentForPage = equipmentServiceInterface.get(equipmentIds);
|
||||
|
||||
List<CEGWBaseCommand> commands = new ArrayList<>(equipmentForPage.size());
|
||||
equipmentForPage.forEach(eq -> commands.add(new CEGWConfigChangeNotification(eq.getInventoryId(), eq.getId())));
|
||||
|
||||
equipmentGatewayInterface.sendCommands(commands);
|
||||
LOG.debug("Page {} - sent {} commands to equipment gateway", context.getLastReturnedPageNumber(), commands.size());
|
||||
}
|
||||
|
||||
LOG.debug("Finished processing LocationChangedApImpactingEvent {}", model.getPayload().getId());
|
||||
|
||||
}
|
||||
|
||||
private void process(EquipmentCustomerChangedEvent model) {
|
||||
LOG.info("Processing EquipmentCustomerChangedEvent {}", model.getPayload().getId());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user