<repo_name>jitanderkapil/API-Project<file_sep>/README.md
# API-Project
API
<file_sep>/iu-qa-api/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.mycom.kernel</groupId>
    <artifactId>nova-parent</artifactId>
    <version>5.0-SNAPSHOT</version>
  </parent>
  <groupId>com.mycom.iu</groupId>
  <artifactId>iu-qa-api</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <properties>
    <cucumber-reporting.version>0.0.21</cucumber-reporting.version>
    <cucumber.version>1.1.8</cucumber.version>
    <deploy.http.timeout>200</deploy.http.timeout>
    <deploy.it.tomcat.url>http://qa-rhel-vm4.mycom-internal.com:8080</deploy.it.tomcat.url>
    <deploy.it.tomcat.url1>http://inqa-rhel7-3.mycom-internal.com:7070</deploy.it.tomcat.url1>
    <deploy.properties.path>${basedir}/src/main/resources</deploy.properties.path>
    <deploy.war.path>${project.build.directory}</deploy.war.path>
    <deployer.app.url>${deploy.it.tomcat.url}/nova.db-deployer-4.2</deployer.app.url>
    <it.skip>true</it.skip>
    <junit.version>4.11</junit.version>
    <maven-surefire-plugin.version>2.16</maven-surefire-plugin.version>
    <maven.test.failure.ignore>false</maven.test.failure.ignore>
    <nova-qa-automation-commons.version>5.0-SNAPSHOT</nova-qa-automation-commons.version>
    <perforce.root.dir>//depot/kernel/05.00/qa/myappname/qa-myappname-test-api</perforce.root.dir>
    <poi.poi-ooxml.version>3.7</poi.poi-ooxml.version>

    <poi.version>3.10.1</poi.version>
    <properties-maven-plugin.version>2.0.1</properties-maven-plugin.version>
    <scribe.version>1.3.5</scribe.version>
    <sonar.build-stability.url>Jenkins:http://mycom-ci.mycom-internal.com:8080/jenkins/job/${project.artifactId}%20${sonar.branch}/</sonar.build-stability.url>
    <zip4j.version>1.3.1</zip4j.version>

  </properties>
  <dependencies>
    <dependency>
      <groupId>com.mycom.kernel</groupId>
      <artifactId>nova-qa-automation-commons</artifactId>
      <version>${nova-qa-automation-commons.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi</artifactId>
      <version>${poi.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.poi</groupId>
      <artifactId>poi-ooxml</artifactId>
      <version>${poi.poi-ooxml.version}</version>
    </dependency>
    <dependency>
      <groupId>com.jayway.restassured</groupId>
      <artifactId>rest-assured</artifactId>
      <version>${rest-assured.version}</version>
    </dependency>
    <dependency>
      <groupId>com.jayway.restassured</groupId>
      <artifactId>json-path</artifactId>
      <version>${rest-assured.version}</version>
    </dependency>
    <dependency>
      <groupId>org.kuali.maven.plugins</groupId>
      <artifactId>properties-maven-plugin</artifactId>
      <version>${properties-maven-plugin.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>${commons-io.version}</version>
    </dependency>
    <dependency>
      <groupId>commons-configuration</groupId>
      <artifactId>commons-configuration</artifactId>
      <version>${commons-configuration.version}</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jersey.media</groupId>
      <artifactId>jersey-media-multipart</artifactId>
      <version>${jersey.version}</version>
    </dependency>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-core</artifactId>
      <version>${cucumber.version}</version>
    </dependency>
    <!-- to prevent error when launch tomcat with tomcat7-maven-plugin -->
    <dependency>
      <groupId>org.codehaus.enunciate</groupId>
      <artifactId>enunciate-jersey-rt</artifactId>
      <version>${enunciate.version}</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion>
          <groupId>javax.ws.rs</groupId>
          <artifactId>jsr311-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.sun.jersey</groupId>
          <artifactId>jersey-server</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.scribe</groupId>
      <artifactId>scribe</artifactId>
      <version>${scribe.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-java</artifactId>
      <version>${cucumber.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>info.cukes</groupId>
      <artifactId>cucumber-junit</artifactId>
      <version>${cucumber.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings 
          only. It has no influence on the Maven build itself. -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <versionRange>[1.7,)</versionRange>
                    <goals>
                      <goal>run</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore></ignore>
                  </action>
                </pluginExecution>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>com.google.code.sortpom</groupId>
                    <artifactId>maven-sortpom-plugin</artifactId>
                    <versionRange>[2.3.0,)</versionRange>
                    <goals>
                      <goal>sort</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore></ignore>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>net.masterthought</groupId>
        <artifactId>cucumber-reporting</artifactId>
        <version>${cucumber-reporting.version}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <redirectTestOutputToFile>false</redirectTestOutputToFile>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <ciManagement>
    <system>Jenkins</system>
    <url>http://mycom-ci.mycom-int.fr:8080/jenkins/job/${project.artifactId} ${sonar.branch}/</url>
  </ciManagement>
  <!-- setup the CI profile settings -->
  <profiles>
    <profile>
      <id>qa-test-api</id>
      <activation></activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <systemPropertyVariables>
                <service.url>${deploy.it.tomcat.url}/</service.url>
                <base.url>${deploy.it.tomcat.url1}/mox/api</base.url>
                <oauth.id>nova.interfaces</oauth.id>
                <oauth.url>${deploy.it.tomcat.url}/nova.oauth-4.2/oauth</oauth.url>
              </systemPropertyVariables>
            </configuration>
            <executions>
              <execution>
                <id>api-test</id>
                <goals>
                  <goal>test</goal>
                </goals>
                <phase>integration-test</phase>
                <configuration>
                  <runOrder>alphabetical</runOrder>
                  <includes>
                    <include>**/ITRunCukesAPI.java</include>
                  </includes>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
<file_sep>/iu-qa-api/src/main/java/com/mycom/test/iu/api/domain/AlertSync.java
package com.mycom.test.iu.api.domain;

import com.mycom.test.nova.utils.RestRequest;

public class AlertSync
{
   private AlertSync()
   {

   }

   private static String URL_GenAlert = "/mox/updateNxalert";
   private static String DEFAULT_BASE_URL_PROPERTY = "base.url";
   private static String alertDef = "";
   private static String alertManageObj = "";
   private static String affectedClass = "";
   private static final String confHeaderAccept = "application/json";
   private static final String confContentType = "application/json";

   public static void setAlertDetails(String alertName, String amo, String amoClass)
   {
      alertDef = alertName;
      alertManageObj = amo;
      affectedClass = amoClass;
   }

   public static String getPayLoad()
   {
      StringBuffer payLoad = new StringBuffer();
      payLoad = getAlertGenPayload(payLoad);
      String newPayLoad = payLoad.toString().replaceAll(",}", "}");
      System.out.println(newPayLoad);
      return newPayLoad;
   }

   private static String alertDef()
   {
      StringBuffer buffer = new StringBuffer();
      buffer.append(String.format("\"alarmName\":\"%s\",", alertDef));
      return buffer.toString();
   }

   private static String alertManageObj()
   {
      StringBuffer buffer = new StringBuffer();
      buffer.append(String.format("\"alarmManagedObjectInstance\":\"%s\",", alertManageObj));
      return buffer.toString();
   }

   private static String affectedClass()
   {
      StringBuffer buffer = new StringBuffer();
      buffer.append(String.format("\"alarmManagedObjectClass\":\"%s\",", affectedClass));
      return buffer.toString();
   }

   public static StringBuffer getAlertGenPayload(StringBuffer payLoad)
   {
      payLoad.append(String.format("{"));
      if (alertDef != null && !alertDef.isEmpty())
      {
         payLoad.append(alertDef());
      }
      if (alertManageObj != null && !alertManageObj.isEmpty())
      {
         payLoad.append(alertManageObj());
      }
      if (affectedClass != null && !affectedClass.isEmpty())
      {
         payLoad.append(affectedClass());
      }
      payLoad.append(String.format("}"));
      return payLoad;
   }

   public static void setBaseURL()
   {
      DEFAULT_BASE_URL_PROPERTY = System.getProperty("base.url");
   }

   public static void genAlert(int statusCode)
   {
      RestRequest.setAddURLV1(false);
      RestRequest.getBasicAuth(DEFAULT_BASE_URL_PROPERTY, confHeaderAccept, confContentType).sendRequest(URL_GenAlert, "post", getPayLoad(), statusCode);
   }
}
