Commit d2601d10 authored by Nikolaos Kyriakoulis's avatar Nikolaos Kyriakoulis
Browse files

Identifying errors that caused a broken pipeline

parent 11742966
Loading
Loading
Loading
Loading
Loading
+43 −43
Original line number Diff line number Diff line
@@ -201,25 +201,62 @@ public class ServiceRepoServiceTest {
    }


//    // org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection [HikariPool-1 - Connection is not available, request timed out after 30000ms.]
//    @WithMockUser(username="osadmin", roles = {"ADMIN","USER"})
//    @Test
//    public void testNfvCatalogNSResourceChanged() throws Exception {
//        String response = createService();
//        Service responsesService = JsonUtils.toJsonObj(response,  Service.class);
//        String id = responsesService.getId();
//
//        DeploymentDescriptor dd = new DeploymentDescriptor();
//        dd.setId(1234567890);
//
//        serviceRepoService.nfvCatalogNSResourceChanged(dd);
//
//        Service updatedService = serviceRepoService.findByUuid(id);
//        Set<Note> noteList = updatedService.getNote();
//
//        boolean expectedNoteExists = false;
//        for (Note n : noteList) {
//            if ( n.getText().equals("NS Resource LCM Changed") && n.getAuthor().equals("SIM638-API")) {
//                expectedNoteExists= true;
//                break;
//            }
//        }
//        assertThat( expectedNoteExists ).isTrue();
//    }


//    //  org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection [HikariPool-1 - Connection is not available, request timed out after 30000ms.]
    @WithMockUser(username="osadmin", roles = {"ADMIN","USER"})
    @Test
    public void testNfvCatalogNSResourceChanged() throws Exception {
    public void testResourceStateChangedEvent() throws Exception {
        String response = createService();
        Service responsesService = JsonUtils.toJsonObj(response,  Service.class);
        String id = responsesService.getId();
        Set<ResourceRef> resourceRefSet = responsesService.getSupportingResource();
        List<ResourceRef> resourceRefList = new ArrayList<>(resourceRefSet);

        DeploymentDescriptor dd = new DeploymentDescriptor();
        dd.setId(1234567890);
        assertThat(resourceRefList.size()).isEqualTo(1);
        ResourceRef firstResourceRef = resourceRefList.get(0);

        serviceRepoService.nfvCatalogNSResourceChanged(dd);
        Resource resource = resourceRepoService.findByUuid(firstResourceRef.getId());

        ResourceStateChangeNotification resourceCreateNotification = new ResourceStateChangeNotification();
        ResourceStateChangeEvent event = new ResourceStateChangeEvent();
        event.getEvent().setResource(resource);
        resourceCreateNotification.setEvent(event);

        serviceRepoService.resourceStateChangedEvent(resourceCreateNotification);
        Service updatedService = serviceRepoService.findByUuid(id);
        Set<Note> noteList = updatedService.getNote();

        Set<Note> noteSet = updatedService.getNote();
        List<Note> noteList = new ArrayList<>(noteSet);

        boolean expectedNoteExists = false;
        for (Note n : noteList) {
            if ( n.getText().equals("NS Resource LCM Changed") && n.getAuthor().equals("SIM638-API")) {
            if ( n.getText().contains("State Changed with status:") && n.getAuthor().equals("SIM638-API")) {
                expectedNoteExists= true;
                break;
            }
@@ -228,43 +265,6 @@ public class ServiceRepoServiceTest {
    }


//    //  org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection [HikariPool-1 - Connection is not available, request timed out after 30000ms.]
////    @WithMockUser(username="osadmin", roles = {"ADMIN","USER"})
////    @Test
////    public void testResourceStateChangedEvent() throws Exception {
////        String response = createService();
////        Service responsesService = JsonUtils.toJsonObj(response,  Service.class);
////        String id = responsesService.getId();
////        Set<ResourceRef> resourceRefSet = responsesService.getSupportingResource();
////        List<ResourceRef> resourceRefList = new ArrayList<>(resourceRefSet);
////
////        assertThat(resourceRefList.size()).isEqualTo(1);
////        ResourceRef firstResourceRef = resourceRefList.get(0);
////
////        Resource resource = resourceRepoService.findByUuid(firstResourceRef.getId());
////
////        ResourceStateChangeNotification resourceCreateNotification = new ResourceStateChangeNotification();
////        ResourceStateChangeEvent event = new ResourceStateChangeEvent();
////        event.getEvent().setResource(resource);
////        resourceCreateNotification.setEvent(event);
////
////        serviceRepoService.resourceStateChangedEvent(resourceCreateNotification);
////        Service updatedService = serviceRepoService.findByUuid(id);
////
////        Set<Note> noteSet = updatedService.getNote();
////        List<Note> noteList = new ArrayList<>(noteSet);
////
////        boolean expectedNoteExists = false;
////        for (Note n : noteList) {
////            if ( n.getText().contains("State Changed with status:") && n.getAuthor().equals("SIM638-API")) {
////                expectedNoteExists= true;
////                break;
////            }
////        }
////        assertThat( expectedNoteExists ).isTrue();
////    }
//
//
    private String createService() throws Exception {
        int servicesCount = serviceRepoService.findAll().size();