@Test public void testGenerateAzureStackEvent() throws Exception { // GIVEN Template template = ServiceTestUtils.createTemplate( ServiceTestUtils.DUMMY_OWNER, ServiceTestUtils.DUMMY_ACCOUNT, CloudPlatform.GCP); Stack stack = ServiceTestUtils.createStack("John", "Acme", template, null); given(stackRepository.findById(1L)).willReturn(stack); CloudbreakEvent stackEvent = new CloudbreakEvent(); given(eventRepository.save(Mockito.any(CloudbreakEvent.class))).willReturn(stackEvent); InstanceGroup instanceGroup = new InstanceGroup(); instanceGroup.setGroupName("master"); instanceGroup.setTemplate(template); CloudbreakEventData eventData = new CloudbreakEventData(1L, "STACK_CREATED", "Stack created"); // WHEN eventService.createStackEvent(eventData); // THEN BDDMockito.verify(eventRepository).save(captor.capture()); CloudbreakEvent event = captor.getValue(); Assert.assertNotNull(event); Assert.assertEquals("The user name is not the expected", "John", event.getOwner()); Assert.assertEquals( "The cloudprovider is not the expected", CloudPlatform.GCP.name(), event.getCloud()); }
@Test public void testShouldClusterDataBePopulated() { // GIVEN Template template = ServiceTestUtils.createTemplate( ServiceTestUtils.DUMMY_OWNER, ServiceTestUtils.DUMMY_ACCOUNT, CloudPlatform.GCP); Blueprint blueprint = ServiceTestUtils.createBlueprint( ServiceTestUtils.DUMMY_OWNER, ServiceTestUtils.DUMMY_ACCOUNT); Cluster cluster = ServiceTestUtils.createCluster("John", "Acme", blueprint); Stack stack = ServiceTestUtils.createStack("John", "Acme", template, cluster); given(stackRepository.findById(1L)).willReturn(stack); CloudbreakEvent stackEvent = new CloudbreakEvent(); given(eventRepository.save(Mockito.any(CloudbreakEvent.class))).willReturn(stackEvent); InstanceGroup instanceGroup = new InstanceGroup(); instanceGroup.setGroupName("master"); instanceGroup.setTemplate(template); CloudbreakEventData eventData = new CloudbreakEventData(1L, "STACK_CREATED", "Stack created"); // WHEN eventService.createStackEvent(eventData); // THEN BDDMockito.verify(eventRepository).save(captor.capture()); CloudbreakEvent event = captor.getValue(); Assert.assertNotNull(event); Assert.assertEquals("The user name is not the expected", "John", event.getOwner()); Assert.assertEquals( "The blueprint name is not the expected", "test-blueprint", event.getBlueprintName()); Assert.assertEquals("The blueprint id is not the expected", 1L, event.getBlueprintId()); }