* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.sdc.controller.installer;
-import com.att.aft.dme2.internal.apache.commons.io.IOUtils;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
+import org.apache.commons.io.IOUtils;
import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException;
import org.onap.sdc.api.notification.IArtifactInfo;
}
public synchronized void save(IDistributionClientDownloadResult resultArtifact)
- throws SdcArtifactInstallerException, SdcToscaParserException {
+ throws SdcArtifactInstallerException, SdcToscaParserException {
try {
logger.info("Writing CSAR file to: " + csarFilePath + " UUID " + artifactElement.getArtifactUUID() + ")");
Path path = Paths.get(csarFilePath);
this.loadDcaeBlueprint();
} catch (IOException e) {
throw new SdcArtifactInstallerException(
- "Exception caught when trying to write the CSAR on the file system to " + csarFilePath, e);
+ "Exception caught when trying to write the CSAR on the file system to " + csarFilePath, e);
}
}
private IResourceInstance searchForResourceByInstanceName(String blueprintResourceInstanceName)
- throws SdcArtifactInstallerException {
+ throws SdcArtifactInstallerException {
for (IResourceInstance resource : this.sdcNotification.getResources()) {
String filteredString = resource.getResourceInstanceName().replaceAll("-", "");
filteredString = filteredString.replaceAll(" ", "");
}
}
throw new SdcArtifactInstallerException("Error when searching for " + blueprintResourceInstanceName
- + " as ResourceInstanceName in Sdc notification and did not find it");
+ + " as ResourceInstanceName in Sdc notification and did not find it");
}
private void loadDcaeBlueprint() throws IOException, SdcArtifactInstallerException {
if (entry.getName().contains(BLUEPRINT_TYPE)) {
BlueprintArtifact blueprintArtifact = new BlueprintArtifact();
blueprintArtifact.setBlueprintArtifactName(
- entry.getName().substring(entry.getName().lastIndexOf('/') + 1, entry.getName().length()));
+ entry.getName().substring(entry.getName().lastIndexOf('/') + 1, entry.getName().length()));
blueprintArtifact
- .setBlueprintInvariantServiceUuid(this.getSdcNotification().getServiceInvariantUUID());
+ .setBlueprintInvariantServiceUuid(this.getSdcNotification().getServiceInvariantUUID());
try (InputStream stream = zipFile.getInputStream(entry)) {
blueprintArtifact.setDcaeBlueprint(IOUtils.toString(stream));
}
blueprintArtifact.setResourceAttached(searchForResourceByInstanceName(entry.getName().substring(
- entry.getName().indexOf(RESOURCE_INSTANCE_NAME_PREFIX)
- + RESOURCE_INSTANCE_NAME_PREFIX.length(),
- entry.getName().indexOf(RESOURCE_INSTANCE_NAME_SUFFIX))));
+ entry.getName().indexOf(RESOURCE_INSTANCE_NAME_PREFIX) + RESOURCE_INSTANCE_NAME_PREFIX.length(),
+ entry.getName().indexOf(RESOURCE_INSTANCE_NAME_SUFFIX))));
this.mapOfBlueprints.put(blueprintArtifact.getResourceAttached().getResourceInstanceName(),
- blueprintArtifact);
+ blueprintArtifact);
logger.info("Found a blueprint entry in the CSAR " + blueprintArtifact.getBlueprintArtifactName()
- + " for resource instance Name "
- + blueprintArtifact.getResourceAttached().getResourceInstanceName());
+ + " for resource instance Name "
+ + blueprintArtifact.getResourceAttached().getResourceInstanceName());
}
}
logger.info(this.mapOfBlueprints.size() + " blueprint(s) will be converted to closed loop");
package org.onap.clamp.clds.sdc.controller.installer;
-import com.att.aft.dme2.internal.apache.commons.io.IOUtils;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.node.ObjectNode;
import javax.annotation.PostConstruct;
import javax.xml.transform.TransformerException;
+import org.apache.commons.io.IOUtils;
import org.json.simple.parser.ParseException;
import org.onap.clamp.clds.client.DcaeInventoryServices;
import org.onap.clamp.clds.config.sdc.BlueprintParserFilesConfiguration;
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.it;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import com.att.aft.dme2.internal.apache.commons.lang.RandomStringUtils;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import javax.ws.rs.NotFoundException;
import org.apache.commons.codec.DecoderException;
+import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Setup the variable before the tests execution.
- *
+ *
* @throws IOException
- * In case of issues when opening the files
+ * In case of issues when opening the files
*/
@Before
public void setupBefore() throws IOException {
newModel.setTemplateId(newTemplate.getId());
newModel.setDocText(newTemplate.getPropText());
CldsEvent.insEvent(cldsDao, newModel, "user", CldsEvent.ACTION_RESTART, CldsEvent.ACTION_STATE_COMPLETED,
- "process-instance-id");
+ "process-instance-id");
}
@Test
@Test
public void testCldsServiceCache() throws GeneralSecurityException, DecoderException, IOException {
CldsServiceData cldsServiceData = sdcCatalogServices
- .getCldsServiceDataWithAlarmConditions("4cc5b45a-1f63-4194-8100-cd8e14248c92");
+ .getCldsServiceDataWithAlarmConditions("4cc5b45a-1f63-4194-8100-cd8e14248c92");
// Test not in cache so should be null
CldsServiceData cldsServiceDataCache = cldsDao.getCldsServiceCache("4cc5b45a-1f63-4194-8100-cd8e14248c92");
assertNull(cldsServiceDataCache);
assertNotNull(cldsServiceDataCache.getAgeOfRecord());
assertEquals(4, cldsServiceDataCache.getCldsVfs().get(0).getCldsVfcs().size());
assertEquals("07e266fc-49ab-4cd7-8378-ca4676f1b9ec",
- cldsServiceDataCache.getCldsVfs().get(0).getVfInvariantResourceUUID());
+ cldsServiceDataCache.getCldsVfs().get(0).getVfInvariantResourceUUID());
assertEquals(0, cldsServiceDataCache.getCldsVfs().get(0).getCldsKPIList().size());
// Second update
cldsServiceData.setCldsVfs(null);
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.att.aft.dme2.internal.apache.commons.lang.RandomStringUtils;
-
import java.io.IOException;
import java.io.InputStream;
import java.security.GeneralSecurityException;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
+
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.NotFoundException;
import javax.xml.transform.TransformerException;
import org.apache.commons.codec.DecoderException;
+import org.apache.commons.lang3.RandomStringUtils;
import org.json.JSONException;
import org.json.simple.parser.ParseException;
import org.junit.Before;
import org.springframework.http.ResponseEntity;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
+import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
assertTrue(CldsModel.STATUS_ACTIVE.equals(((CldsModel) responseEntity.getBody()).getStatus()));
assertTrue(CldsModel.STATUS_ACTIVE.equals(cldsService.getModel(randomNameModel).getStatus()));
- responseEntity = cldsService.putModelAndProcessAction(CldsEvent.ACTION_STOP,
- randomNameModel, "false", cldsService.getModel(randomNameModel));
+ responseEntity = cldsService.putModelAndProcessAction(CldsEvent.ACTION_STOP, randomNameModel, "false",
+ cldsService.getModel(randomNameModel));
assertTrue(responseEntity.getStatusCode().equals(HttpStatus.OK));
assertNotNull(responseEntity.getBody());
assertTrue(CldsModel.STATUS_STOPPED.equals(((CldsModel) responseEntity.getBody()).getStatus()));
assertTrue(CldsModel.STATUS_STOPPED.equals(cldsService.getModel(randomNameModel).getStatus()));
- responseEntity = cldsService.putModelAndProcessAction(CldsEvent.ACTION_RESTART,
- randomNameModel, "false", cldsService.getModel(randomNameModel));
+ responseEntity = cldsService.putModelAndProcessAction(CldsEvent.ACTION_RESTART, randomNameModel, "false",
+ cldsService.getModel(randomNameModel));
assertTrue(responseEntity.getStatusCode().equals(HttpStatus.OK));
assertNotNull(responseEntity.getBody());
assertTrue(CldsModel.STATUS_ACTIVE.equals(((CldsModel) responseEntity.getBody()).getStatus()));
assertTrue(CldsModel.STATUS_ACTIVE.equals(cldsService.getModel(randomNameModel).getStatus()));
- responseEntity = cldsService.putModelAndProcessAction(CldsEvent.ACTION_UPDATE,
- randomNameModel, "false", cldsService.getModel(randomNameModel));
+ responseEntity = cldsService.putModelAndProcessAction(CldsEvent.ACTION_UPDATE, randomNameModel, "false",
+ cldsService.getModel(randomNameModel));
assertTrue(responseEntity.getStatusCode().equals(HttpStatus.OK));
assertNotNull(responseEntity.getBody());
assertTrue(CldsModel.STATUS_ACTIVE.equals(((CldsModel) responseEntity.getBody()).getStatus()));
assertTrue(CldsModel.STATUS_DISTRIBUTED.equals(((CldsModel) responseEntity.getBody()).getStatus()));
assertTrue(CldsModel.STATUS_DISTRIBUTED.equals(cldsService.getModel(randomNameModel).getStatus()));
- responseEntity = cldsService.putModelAndProcessAction(CldsEvent.ACTION_DELETE,
- randomNameModel, "false", cldsService.getModel(randomNameModel));
+ responseEntity = cldsService.putModelAndProcessAction(CldsEvent.ACTION_DELETE, randomNameModel, "false",
+ cldsService.getModel(randomNameModel));
assertNotNull(responseEntity);
assertTrue(responseEntity.getStatusCode().equals(HttpStatus.OK));
assertNotNull(responseEntity.getBody());
try {
cldsService.getModel(randomNameModel);
fail("Should have raised an NotFoundException exception");
- } catch(NotFoundException ne) {
+ } catch (NotFoundException ne) {
}
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.att.aft.dme2.internal.apache.commons.io.IOUtils;
-import com.att.aft.dme2.internal.apache.commons.lang.RandomStringUtils;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.RandomStringUtils;
import org.json.JSONException;
import org.junit.Test;
import org.junit.runner.RunWith;
* limitations under the License.
* ============LICENSE_END============================================
* ===================================================================
- *
+ *
*/
package org.onap.clamp.clds.sdc.controller.installer;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.att.aft.dme2.internal.apache.commons.io.IOUtils;
-
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException;
private IDistributionClientDownloadResult buildFakeSdcResut() throws IOException {
IDistributionClientDownloadResult resultArtifact = Mockito.mock(IDistributionClientDownloadResult.class);
Mockito.when(resultArtifact.getArtifactPayload()).thenReturn(
- IOUtils.toByteArray(ResourceFileUtil.getResourceAsStream("example/sdc/service-Simsfoimap0112.csar")));
+ IOUtils.toByteArray(ResourceFileUtil.getResourceAsStream("example/sdc/service-Simsfoimap0112.csar")));
return resultArtifact;
}
@Test
public void testSave()
- throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
+ throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
CsarHandler csar = new CsarHandler(buildFakeSdcNotification(), "test-controller", "/tmp/csar-handler-tests");
// Test the save
csar.save(buildFakeSdcResut());
assertTrue(blueprint.contains("DCAE-VES-PM-EVENT-v1"));
// Test additional properties from Sdc notif
assertEquals(BLUEPRINT1_NAME,
- csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintArtifactName());
- assertEquals(RESOURCE1_UUID, csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getResourceAttached()
- .getResourceInvariantUUID());
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintArtifactName());
+ assertEquals(RESOURCE1_UUID,
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getResourceAttached().getResourceInvariantUUID());
assertEquals(SERVICE_UUID,
- csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintInvariantServiceUuid());
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintInvariantServiceUuid());
// Do some cleanup
Path path = Paths.get(SDC_FOLDER + "/test-controller/" + CSAR_ARTIFACT_NAME);
Files.deleteIfExists(path);
@Test
public void testDoubleSave()
- throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
+ throws SdcArtifactInstallerException, SdcToscaParserException, CsarHandlerException, IOException {
CsarHandler csar = new CsarHandler(buildFakeSdcNotification(), "test-controller", "/tmp/csar-handler-tests");
// Test the save
csar.save(buildFakeSdcResut());
assertTrue(blueprint.contains("DCAE-VES-PM-EVENT-v1"));
// Test additional properties from Sdc notif
assertEquals(BLUEPRINT1_NAME,
- csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintArtifactName());
- assertEquals(RESOURCE1_UUID, csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getResourceAttached()
- .getResourceInvariantUUID());
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintArtifactName());
+ assertEquals(RESOURCE1_UUID,
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getResourceAttached().getResourceInvariantUUID());
assertEquals(SERVICE_UUID,
- csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintInvariantServiceUuid());
+ csar.getMapOfBlueprints().get(RESOURCE1_INSTANCE_NAME).getBlueprintInvariantServiceUuid());
Path path = Paths.get(SDC_FOLDER + "/test-controller/" + CSAR_ARTIFACT_NAME);
// A double save should simply overwrite the existing
csar.save(buildFakeSdcResut());