Search in sources :

Example 1 with JiraPluginResource

use of org.ligoj.app.resource.node.sample.JiraPluginResource in project ligoj-api by ligoj.

the class NodeResourceTest method prepareEvent.

/**
 * Mock the servers for event test
 */
private int prepareEvent() throws Exception {
    final ServicePluginLocator servicePluginLocator = resourceMock.locator;
    // 1 : service is down
    final JiraPluginResource jira = Mockito.mock(JiraPluginResource.class);
    Mockito.when(servicePluginLocator.getResource(ArgumentMatchers.endsWith(":jira"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(jira);
    Mockito.when(servicePluginLocator.getResourceExpected(ArgumentMatchers.endsWith(":jira"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(jira);
    Mockito.when(jira.checkStatus(ArgumentMatchers.anyString(), ArgumentMatchers.anyMap())).thenReturn(false);
    // 2 : service is up
    final SonarPluginResource sonar = Mockito.mock(SonarPluginResource.class);
    Mockito.when(servicePluginLocator.getResource(ArgumentMatchers.contains(":sonar"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(sonar);
    Mockito.when(servicePluginLocator.getResourceExpected(ArgumentMatchers.contains(":sonar"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(sonar);
    Mockito.when(sonar.checkStatus(ArgumentMatchers.anyString(), ArgumentMatchers.anyMap())).thenReturn(true);
    // 3 : service throw an exception (down)
    final JenkinsPluginResource jenkins = Mockito.mock(JenkinsPluginResource.class);
    Mockito.when(servicePluginLocator.getResource(ArgumentMatchers.contains(":jenkins"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(jenkins);
    Mockito.when(servicePluginLocator.getResourceExpected(ArgumentMatchers.contains(":jenkins"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(jenkins);
    Mockito.when(jenkins.checkStatus(ArgumentMatchers.anyString(), ArgumentMatchers.anyMap())).thenThrow(new TechnicalException("junit"));
    final int nbNodes = repository.findAllInstance().size();
    // Jirax2, Confluence, LDAP,
    Assertions.assertTrue(nbNodes >= 6);
    // SonarQube
    return nbNodes;
}
Also used : TechnicalException(org.ligoj.bootstrap.core.resource.TechnicalException) JenkinsPluginResource(org.ligoj.app.resource.node.sample.JenkinsPluginResource) JiraPluginResource(org.ligoj.app.resource.node.sample.JiraPluginResource) SonarPluginResource(org.ligoj.app.resource.node.sample.SonarPluginResource) ServicePluginLocator(org.ligoj.app.resource.ServicePluginLocator) ToolPlugin(org.ligoj.app.api.ToolPlugin)

Example 2 with JiraPluginResource

use of org.ligoj.app.resource.node.sample.JiraPluginResource in project ligoj-api by ligoj.

the class NodeResourceTest method prepareSubscriptionsEvent.

private long prepareSubscriptionsEvent() throws Exception {
    // Check previous status
    final long eventsCount = eventRepository.count();
    Assertions.assertEquals(5, eventsCount);
    final ServicePluginLocator servicePluginLocator = resourceMock.locator;
    // Service is up --> SONAR
    final SonarPluginResource sonar = Mockito.mock(SonarPluginResource.class);
    Mockito.when(servicePluginLocator.getResource(ArgumentMatchers.anyString(), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(sonar);
    Mockito.when(servicePluginLocator.getResourceExpected(ArgumentMatchers.anyString(), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(sonar);
    Mockito.when(sonar.checkSubscriptionStatus(ArgumentMatchers.anyInt(), ArgumentMatchers.anyString(), ArgumentMatchers.anyMap())).thenReturn(new SubscriptionStatusWithData());
    Mockito.when(sonar.checkStatus(ArgumentMatchers.anyString(), ArgumentMatchers.anyMap())).thenReturn(true);
    // Service is down --> JIRA
    final JiraPluginResource jira = Mockito.mock(JiraPluginResource.class);
    Mockito.when(servicePluginLocator.getResource(ArgumentMatchers.contains(":jira"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(jira);
    Mockito.when(servicePluginLocator.getResourceExpected(ArgumentMatchers.contains(":jira"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(jira);
    Mockito.when(jira.checkSubscriptionStatus(ArgumentMatchers.anyInt(), ArgumentMatchers.anyString(), ArgumentMatchers.anyMap())).thenReturn(new SubscriptionStatusWithData(false));
    // Service throw an exception --> JENKINS
    final JenkinsPluginResource jenkins = Mockito.mock(JenkinsPluginResource.class);
    Mockito.when(servicePluginLocator.getResource(ArgumentMatchers.contains(":jenkins"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(jenkins);
    Mockito.when(servicePluginLocator.getResourceExpected(ArgumentMatchers.contains(":jenkins"), ArgumentMatchers.eq(ToolPlugin.class))).thenReturn(jenkins);
    Mockito.when(jenkins.checkSubscriptionStatus(ArgumentMatchers.anyInt(), ArgumentMatchers.anyString(), ArgumentMatchers.anyMap())).thenThrow(new TechnicalException("junit"));
    return eventsCount;
}
Also used : SubscriptionStatusWithData(org.ligoj.app.api.SubscriptionStatusWithData) TechnicalException(org.ligoj.bootstrap.core.resource.TechnicalException) JenkinsPluginResource(org.ligoj.app.resource.node.sample.JenkinsPluginResource) JiraPluginResource(org.ligoj.app.resource.node.sample.JiraPluginResource) SonarPluginResource(org.ligoj.app.resource.node.sample.SonarPluginResource) ServicePluginLocator(org.ligoj.app.resource.ServicePluginLocator) ToolPlugin(org.ligoj.app.api.ToolPlugin)

Example 3 with JiraPluginResource

use of org.ligoj.app.resource.node.sample.JiraPluginResource in project ligoj-api by ligoj.

the class SubscriptionResourceTest method checkSubscriptionStatus.

@Test
public void checkSubscriptionStatus() {
    JiraPluginResource service = servicePluginLocator.getResource("service:bt:jira:4", JiraPluginResource.class);
    final SubscriptionStatusWithData status = service.checkSubscriptionStatus(null);
    Assertions.assertNotNull(status);
    Assertions.assertEquals("value", status.getData().get("property"));
}
Also used : SubscriptionStatusWithData(org.ligoj.app.api.SubscriptionStatusWithData) JiraPluginResource(org.ligoj.app.resource.node.sample.JiraPluginResource) Test(org.junit.jupiter.api.Test) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest)

Example 4 with JiraPluginResource

use of org.ligoj.app.resource.node.sample.JiraPluginResource in project ligoj-api by ligoj.

the class SubscriptionResourceTest method servicePlugin.

@Test
public void servicePlugin() {
    JiraPluginResource service = servicePluginLocator.getResource("service:bt:jira:4", JiraPluginResource.class);
    Assertions.assertEquals("Jira", service.getName());
    Assertions.assertNull(service.getVendor());
    Assertions.assertNull(service.getVersion());
    Assertions.assertEquals(0, service.compareTo(service));
}
Also used : JiraPluginResource(org.ligoj.app.resource.node.sample.JiraPluginResource) Test(org.junit.jupiter.api.Test) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest)

Aggregations

JiraPluginResource (org.ligoj.app.resource.node.sample.JiraPluginResource)4 Test (org.junit.jupiter.api.Test)2 SubscriptionStatusWithData (org.ligoj.app.api.SubscriptionStatusWithData)2 ToolPlugin (org.ligoj.app.api.ToolPlugin)2 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)2 ServicePluginLocator (org.ligoj.app.resource.ServicePluginLocator)2 JenkinsPluginResource (org.ligoj.app.resource.node.sample.JenkinsPluginResource)2 SonarPluginResource (org.ligoj.app.resource.node.sample.SonarPluginResource)2 TechnicalException (org.ligoj.bootstrap.core.resource.TechnicalException)2