diff options
Diffstat (limited to 'common/src')
9 files changed, 0 insertions, 641 deletions
diff --git a/common/src/main/java/org/onap/so/client/ruby/RubyClient.java b/common/src/main/java/org/onap/so/client/ruby/RubyClient.java deleted file mode 100644 index 6c8f48884d..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/RubyClient.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.ruby; - -import java.io.IOException; -import java.time.ZoneOffset; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import org.onap.so.client.dmaap.DmaapPublisher; -import org.onap.so.client.ruby.beans.Event; -import org.onap.so.client.ruby.beans.MsoRequest; -import org.onap.so.client.ruby.beans.Ruby; -import org.onap.so.client.ruby.dmaap.RubyCreateTicketRequestPublisher; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - - -public class RubyClient { - - private static final String REQUEST_CLIENT_NAME = "MSO"; - private static final String ACTION = "Create Ticket"; - - protected String buildRequest(String requestId, String sourceName, String reason, String workflowId, - String notification) throws JsonProcessingException { - final MsoRequest request = new MsoRequest(); - request.withRequestClientName(REQUEST_CLIENT_NAME).withRequestId(requestId).withSourceName(sourceName) - .withWorkflowId(workflowId).withAction(ACTION); - - request.withRequestTime(this.getTime()); - - if (reason.length() <= 255) { - request.withReason(reason); - } else { - throw new IllegalArgumentException("reason exceeds 255 characters"); - } - if (notification.length() <= 1024) { - request.withNotification(notification); - } else { - throw new IllegalArgumentException("notification exceeds 1024 characters"); - } - final Event event = new Event(); - event.setMsoRequest(request); - final Ruby ruby = new Ruby(); - ruby.setEvent(event); - return this.getJson(ruby); - } - - protected String getJson(Ruby obj) throws JsonProcessingException { - final ObjectMapper mapper = new ObjectMapper(); - return mapper.writeValueAsString(obj); - } - - protected DmaapPublisher getPublisher() throws IOException { - return new RubyCreateTicketRequestPublisher(); - } - - protected String getTime() { - final ZonedDateTime currentDateTime = ZonedDateTime.now(ZoneOffset.UTC); - final DateTimeFormatter format = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z"); - return currentDateTime.format(format); - } - - public void rubyCreateTicketCheckRequest(String requestId, String sourceName, String reason, String workflowId, - String notification) throws Exception { - String request = this.buildRequest(requestId, sourceName, reason, workflowId, notification); - final DmaapPublisher publisher = this.getPublisher(); - publisher.send(request); - } -} diff --git a/common/src/main/java/org/onap/so/client/ruby/beans/Event.java b/common/src/main/java/org/onap/so/client/ruby/beans/Event.java deleted file mode 100644 index 2737342adc..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/beans/Event.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.ruby.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"msoRequest"}) -public class Event { - - @JsonProperty("msoRequest") - private MsoRequest msoRequest; - - /** - * No args constructor for use in serialization - * - */ - public Event() {} - - /** - * - * @param msoRequest - */ - public Event(MsoRequest msoRequest) { - super(); - this.msoRequest = msoRequest; - } - - @JsonProperty("msoRequest") - public MsoRequest getMsoRequest() { - return msoRequest; - } - - @JsonProperty("msoRequest") - public void setMsoRequest(MsoRequest msoRequest) { - this.msoRequest = msoRequest; - } - - public Event withMsoRequest(MsoRequest msoRequest) { - this.msoRequest = msoRequest; - return this; - } - -} diff --git a/common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java b/common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java deleted file mode 100644 index 15cfc9222f..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/beans/MsoRequest.java +++ /dev/null @@ -1,199 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.ruby.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"requestClientName", "requestId", "requestTime", "sourceName", "reason", "action", "workflowId", - "notification"}) -public class MsoRequest { - - @JsonProperty("requestClientName") - private String requestClientName; - @JsonProperty("requestId") - private String requestId; - @JsonProperty("requestTime") - private String requestTime; - @JsonProperty("sourceName") - private String sourceName; - @JsonProperty("reason") - private String reason; - @JsonProperty("action") - private String action; - @JsonProperty("workflowId") - private String workflowId; - @JsonProperty("notification") - private String notification; - - /** - * No args constructor for use in serialization - * - */ - public MsoRequest() {} - - /** - * - * @param requestClientName - * @param requestTime - * @param reason - * @param requestId - * @param workflowId - * @param sourceName - * @param action - * @param notification - */ - public MsoRequest(String requestClientName, String requestId, String requestTime, String sourceName, String reason, - String action, String workflowId, String notification) { - super(); - this.requestClientName = requestClientName; - this.requestId = requestId; - this.requestTime = requestTime; - this.sourceName = sourceName; - this.reason = reason; - this.action = action; - this.workflowId = workflowId; - this.notification = notification; - } - - @JsonProperty("requestClientName") - public String getRequestClientName() { - return requestClientName; - } - - @JsonProperty("requestClientName") - public void setRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - } - - public MsoRequest withRequestClientName(String requestClientName) { - this.requestClientName = requestClientName; - return this; - } - - @JsonProperty("requestId") - public String getRequestId() { - return requestId; - } - - @JsonProperty("requestId") - public void setRequestId(String requestId) { - this.requestId = requestId; - } - - public MsoRequest withRequestId(String requestId) { - this.requestId = requestId; - return this; - } - - @JsonProperty("requestTime") - public String getRequestTime() { - return requestTime; - } - - @JsonProperty("requestTime") - public void setRequestTime(String requestTime) { - this.requestTime = requestTime; - } - - public MsoRequest withRequestTime(String requestTime) { - this.requestTime = requestTime; - return this; - } - - @JsonProperty("sourceName") - public String getSourceName() { - return sourceName; - } - - @JsonProperty("sourceName") - public void setSourceName(String sourceName) { - this.sourceName = sourceName; - } - - public MsoRequest withSourceName(String sourceName) { - this.sourceName = sourceName; - return this; - } - - @JsonProperty("reason") - public String getReason() { - return reason; - } - - @JsonProperty("reason") - public void setReason(String reason) { - this.reason = reason; - } - - public MsoRequest withReason(String reason) { - this.reason = reason; - return this; - } - - @JsonProperty("action") - public String getAction() { - return action; - } - - @JsonProperty("action") - public void setAction(String action) { - this.action = action; - } - - public MsoRequest withAction(String action) { - this.action = action; - return this; - } - - @JsonProperty("workflowId") - public String getWorkflowId() { - return workflowId; - } - - @JsonProperty("workflowId") - public void setWorkflowId(String workflowId) { - this.workflowId = workflowId; - } - - public MsoRequest withWorkflowId(String workflowId) { - this.workflowId = workflowId; - return this; - } - - @JsonProperty("notification") - public String getNotification() { - return notification; - } - - @JsonProperty("notification") - public void setNotification(String notification) { - this.notification = notification; - } - - public MsoRequest withNotification(String notification) { - this.notification = notification; - return this; - } - -} diff --git a/common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java b/common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java deleted file mode 100644 index 708b91638b..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/beans/Ruby.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.ruby.beans; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; - -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"event"}) -public class Ruby { - - @JsonProperty("event") - private Event event; - - /** - * No args constructor for use in serialization - * - */ - public Ruby() {} - - /** - * - * @param event - */ - public Ruby(Event event) { - super(); - this.event = event; - } - - @JsonProperty("event") - public Event getEvent() { - return event; - } - - @JsonProperty("event") - public void setEvent(Event event) { - this.event = event; - } - - public Ruby withEvent(Event event) { - this.event = event; - return this; - } - -} diff --git a/common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java b/common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java deleted file mode 100644 index 10402d9921..0000000000 --- a/common/src/main/java/org/onap/so/client/ruby/dmaap/RubyCreateTicketRequestPublisher.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.ruby.dmaap; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Optional; -import org.onap.so.client.dmaap.DmaapPublisher; - -public class RubyCreateTicketRequestPublisher extends DmaapPublisher { - public RubyCreateTicketRequestPublisher() throws FileNotFoundException, IOException { - super(); - } - - @Override - public String getAuth() { - return msoProperties.get("ruby.create-ticket-request.dmaap.auth"); - } - - @Override - public String getKey() { - return msoProperties.get("mso.msoKey"); - } - - @Override - public String getTopic() { - return msoProperties.get("ruby.create-ticket-request.publisher.topic"); - } - - @Override - public Optional<String> getHost() { - return Optional.ofNullable(msoProperties.get("ruby.create-ticket-request.publisher.host")); - } - -} - - diff --git a/common/src/test/java/org/onap/so/BeansTest.java b/common/src/test/java/org/onap/so/BeansTest.java index 9e8a0184ab..01bdc4db38 100644 --- a/common/src/test/java/org/onap/so/BeansTest.java +++ b/common/src/test/java/org/onap/so/BeansTest.java @@ -63,7 +63,6 @@ public class BeansTest { test("org.onap.so.appc.orchestrator.service.beans"); test("org.onap.so.client.policy.entities"); test("org.onap.so.client.grm.beans"); - test("org.onap.so.client.ruby.beans"); test("org.onap.so.client.sdno.beans"); test("org.onap.so.entity"); test("org.onap.so.serviceinstancebeans"); diff --git a/common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java b/common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java deleted file mode 100644 index 1ca8942ac1..0000000000 --- a/common/src/test/java/org/onap/so/client/ruby/RubyCheckClientTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.ruby; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.text.ParseException; -import java.time.format.DateTimeFormatter; -import org.junit.Test; -import org.onap.so.client.ruby.beans.Ruby; -import static org.apache.commons.lang3.StringUtils.*; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class RubyCheckClientTest { - private final String fileLocation = "src/test/resources/org/onap/so/client/ruby/create-ticket/"; - private static final String REQUEST_ID = "abc123"; - private static final String SOURCE_NAME = "source-name"; - private static final String TIME = "test-time"; - private static final String REASON = "reason"; - private static final String WORK_FLOW_ID = "work-flow-Id"; - private static final String NOTIFICATION = "notification"; - - - - @Test - public void verifyRubyCreateTicketRequest() throws IOException, ParseException { - String content = this.getJson("create-ticket-request.json"); - ObjectMapper mapper = new ObjectMapper(); - Ruby expected = mapper.readValue(content, Ruby.class); - RubyClient client = new RubyClient(); - RubyClient spy = spy(client); - when(spy.getTime()).thenReturn(TIME); - String actual = spy.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, NOTIFICATION); - assertEquals("payloads are equal", mapper.writeValueAsString(expected), actual); - } - - - @Test - public void verifyTimeFormat() { - RubyClient client = new RubyClient(); - String time = client.getTime(); - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss Z"); - formatter.parse(time); - } - - - @Test - public void verifyReasonCharLimit() throws IOException { - final String reasonLong = repeat("*", 256); - RubyClient client = new RubyClient(); - try { - client.buildRequest(REQUEST_ID, SOURCE_NAME, reasonLong, WORK_FLOW_ID, NOTIFICATION); - fail("Should have thrown IllegalArgumentException but did not!"); - } catch (final IllegalArgumentException e) { - final String msg = "reason exceeds 255 characters"; - assertEquals(msg, e.getMessage()); - } - } - - @Test - public void verifyNotificationCharLimit() throws IOException { - final String notificationLong = repeat("*", 1025); - RubyClient client = new RubyClient(); - try { - client.buildRequest(REQUEST_ID, SOURCE_NAME, REASON, WORK_FLOW_ID, notificationLong); - fail("Should have thrown IllegalArgumentException but did not!"); - } catch (final IllegalArgumentException e) { - final String msg = "notification exceeds 1024 characters"; - assertEquals(msg, e.getMessage()); - } - } - - private String getJson(String filename) throws IOException { - return new String(Files.readAllBytes(Paths.get(fileLocation + filename))); - } - -} - diff --git a/common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java b/common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java deleted file mode 100644 index ca80930468..0000000000 --- a/common/src/test/java/org/onap/so/client/ruby/beans/RubyBeansTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.client.ruby.beans; - -import org.junit.Test; -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterPackageInfo; -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; - -public class RubyBeansTest { - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - @Test - public void pojoStructure() { - test("org.onap.so.client.ruby.beans"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create().with(new GetterMustExistRule()).with(new SetterMustExistRule()) - .with(new SetterTester()).with(new GetterTester()).build(); - validator.validate(pojoPackage, new FilterPackageInfo(), new FilterEnum(), filterTestClasses); - } - - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -} diff --git a/common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json b/common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json deleted file mode 100644 index e388d3e9ad..0000000000 --- a/common/src/test/resources/org/onap/so/client/ruby/create-ticket/create-ticket-request.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "event": { - "msoRequest": { - "requestClientName": "MSO", - "requestId": "abc123", - "requestTime": "test-time", - "sourceName": "source-name", - "reason": "reason", - "action": "Create Ticket", - "workflowId": "work-flow-Id", - "notification": "notification" - } -} -} - |