- assertThatThrownBy(() -> {
- new PdpProvider().updatePdpStatistics(pfDao, null, "TYPE", null, null);
- }).hasMessage(GROUP_IS_NULL);
+ @Test
+ public void cudPolicyStatus_Update() throws PfModelException {
+ PdpProvider prov = new PdpProvider();
+
+ PdpPolicyStatus idw = statusBuilder.pdpGroup(GROUP_A).pdpId("wId").build();
+ PdpPolicyStatus idx = statusBuilder.pdpGroup(GROUP_A).pdpId("xId").build();
+ PdpPolicyStatus idy = statusBuilder.pdpGroup(GROUP_A).pdpId("yId").build();
+ PdpPolicyStatus idz = statusBuilder.pdpGroup(GROUP_A).pdpId("zId").build();
+ prov.cudPolicyStatus(pfDao, List.of(idw, idx, idy, idz), null, null);
+
+ assertThat(prov.getGroupPolicyStatus(pfDao, GROUP_A)).hasSize(4);
+
+ /*
+ * Now update some records.
+ */
+ idx.setState(State.FAILURE);
+ idz.setState(State.WAITING);
+ prov.cudPolicyStatus(pfDao, null, List.of(idx, idz), null);
+ List<PdpPolicyStatus> records = prov.getGroupPolicyStatus(pfDao, GROUP_A);
+ assertThat(records).hasSize(4);
+
+ Collections.sort(records, (rec1, rec2) -> rec1.getPdpId().compareTo(rec2.getPdpId()));
+ assertThat(records.get(0)).isEqualTo(idw);
+ assertThat(records.get(1)).isEqualTo(idx);
+ assertThat(records.get(2)).isEqualTo(idy);
+ assertThat(records.get(3)).isEqualTo(idz);
+ }