src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
EventConverter { public static OpsBaseEvent convert(OpsEvent oEvent) { OpsBaseEvent bEvent = new OpsBaseEvent(); bEvent.setCiId(oEvent.getCiId()); bEvent.setBucket(oEvent.getBucket()); bEvent.setCiState(oEvent.getCiState()); bEvent.setName(oEvent.getName()); bEvent.setManifestId(oEvent.getManifestId()); bEvent.setSourc...
@Test public void testEventClosed(){ OpsCloseEvent opsCloseEvent = new OpsCloseEvent(); opsCloseEvent.setBucket(BUCKET); opsCloseEvent.setCiId(CI_ID); opsCloseEvent.setCiState(CI_STATE); opsCloseEvent.setManifestId(CI_MANIFEST_ID); opsCloseEvent.setSource(CI_SOURCE); opsCloseEvent.setType(CI_TYPE); opsCloseEvent.setTim...
CmsDJValidator { public CIValidationResult validateRfcCi(CmsRfcCI rfcCi) { CIValidationResult result = new CIValidationResult(); result.setValidated(true); if (rfcCi.getCiName() == null || rfcCi.getCiName().length()==0) { result.setValidated(false); result.setErrorMsg("CI Name can not be empty!"); return result; } CmsC...
@Test public void testEmptyName(){ CmsRfcCI rfcCi = new CmsRfcCI(); rfcCi.setCiName(""); CIValidationResult result = this.validator.validateRfcCi(rfcCi); assertTrue(result.getErrorMsg().startsWith("CI Name can not be empty!"),"unex:"+result.getErrorMsg()); assertEquals(result.isValidated(),false); }
CmsUtil { public void processAllVars(CmsCI ci,CmsCI env , CmsCI cloud, CmsCI plat) { processAllVars(ci, getCloudVars(cloud), getGlobalVars(env), getLocalVars(plat)); } static String likefyNsPath(String queryParam); static String likefyNsPathWithBom(String queryParam); static String likefyNsPathWithoutEndingSlash(Strin...
@Test public void processAllVarsTest() { String[] cloudValues = new String[]{"cbar", "cfoo", "cbaz"}; String[] globalValues = new String[]{"gbat", "gfee", "gbiz"}; String[] localValues = new String[]{"lbaz", "lfuu", "lbuz"}; Map<String, String> cloudVars = getVariablesMap(cloudValues); logger.info("cloud values have be...
SensorWsController { @RequestMapping(method = RequestMethod.POST, value = "/monitors/start") @ResponseBody public String startTracking( @RequestBody CmsWorkOrderSimple woSimple, @RequestHeader(value = "X-Cms-Scope", required = false) String scope) { logger.info("Inserting fake events for " + woSimple.rfcCi.getCiName() ...
@Test public void startTrackingTest() { String scope = ""; CmsWorkOrderSimple woSimple = new CmsWorkOrderSimple(); CmsRfcCISimple rfcCi = new CmsRfcCISimple(); rfcCi.setCiName("mocked"); rfcCi.setCiId(0); rfcCi.setRfcAction("update"); woSimple.setRfcCi(rfcCi); Map<String, List<CmsRfcCISimple>> payLoad = new HashMap<Str...
CmsUtil { private String getErrorMessage(VariableContext variableContext, String resolvedValue, String varName, String varPfx) { return getErrorMessage(variableContext.getCiName(), variableContext.getNsPath(), variableContext.getAttrName(), resolvedValue, varName, varPfx) ; } static String likefyNsPath(String queryPar...
@Test public void testErrorMessage() { String errorMessage = "tomcat@p1/1 attribute '' [pre_shutdown_command] references unknown local variable 'DEPLOYCONTEXT'"; assertEquals( util.getErrorMessage("tomcat", "/LOCAL2/A1/testEnv2/manifest/p1/1", "pre_shutdown_command", null, "DEPLOYCONTEXT", "\\$OO_LOCAL\\{"), errorMessa...
SensorWsController { @RequestMapping(value = "/ops/states", method = RequestMethod.GET) @ResponseBody public List<Map<String, String>> getCisStatesGet( @RequestParam(value = "ciIds", required = true) String ciIdsStr) { String[] ciIdsAr = ciIdsStr.split(","); List<Long> ciIds = new ArrayList<Long>(); for (String ciId : ...
@Test public void getStates() { String ciIdsStr = CI_ID_A + ",20,30"; List<Map<String, String>> states = this.sensorWsController .getCisStatesGet(ciIdsStr); assert (states.size() == 3); List<String> gottenKeys = new ArrayList<String>(3); for (Map<String, String> m : states) { gottenKeys.add(m.get("id")); } String[] exp...
SensorWsController { @RequestMapping(value = "/ops/states/{ciId}", method = RequestMethod.GET) @ResponseBody public Map<String, String> getCIstate(@PathVariable long ciId) { String ciState = coProcessor.getCIstate(ciId); Map<String, String> result = new HashMap<String, String>(); result.put("id", String.valueOf(ciId));...
@Test public void getCIState() { Map<String, String> stateMap = new HashMap<String, String>(1); stateMap = this.sensorWsController.getCIstate(CI_ID_A); assert (CI_ID_AVAL.equals(stateMap.get("state"))); }
SensorWsController { @RequestMapping(value = "/ops/events/{ciId}/send", method = RequestMethod.GET) @ResponseBody public String sendEmptyEvent(@PathVariable long ciId, @RequestParam(value = "source", required = true) String source, @RequestParam(value = "manifestId", required = true) long manifestId) { sensor.insertFak...
@Test public void emptyEvent() { String wasSent = this.sensorWsController.sendEmptyEvent(100, "mocker", 200); assertEquals(wasSent, "Sent"); }
CmsUtil { public static boolean isOrgLevel(String nsPath) { String trimmedPath = null; if (nsPath.length() > 1) { if (nsPath.endsWith("/")) { trimmedPath = nsPath.substring(1, nsPath.length() - 1); } else if (nsPath.startsWith("/")) { trimmedPath = nsPath.substring(1); } if (trimmedPath != null && trimmedPath.split("/"...
@Test public void nsPathOrgCheck() { assertTrue(CmsUtil.isOrgLevel("/test-org/")); assertTrue(CmsUtil.isOrgLevel("/test-org")); assertFalse(CmsUtil.isOrgLevel("/test-org/a1")); assertFalse(CmsUtil.isOrgLevel("/test-org/a2/")); assertFalse(CmsUtil.isOrgLevel("/test-org/a2/dev")); assertFalse(CmsUtil.isOrgLevel("/test-or...
CmsUtil { private static void maskSecure(CmsCISimple ci) { if (ci.getAttrProps() != null && ci.getAttrProps().get(CmsConstants.SECURED_ATTRIBUTE) != null) { for (Entry<String, String> secAttr : ci.getAttrProps().get(CmsConstants.SECURED_ATTRIBUTE).entrySet()) { if ("true".equals(secAttr.getValue()) && ! StringUtils.isE...
@Test public void testMaskSecuredAttributes(){ CmsRfcCISimple aRfc = new CmsRfcCISimple(); Map<String,String> rfcAttributes = new HashMap<>(); rfcAttributes.put("secureAtrribute1","secureValue"); rfcAttributes.put("attrib2","attrib2"); aRfc.setCiAttributes(rfcAttributes); Map<String,String> baseAttributes = new HashMap...
CmsCmProcessor { public CmsCI upsertCmsCI(CmsCI cmsCi) { if (cmsCi.getCiId() == 0 ) { CmsCI createdCi = createCI(cmsCi); return getCiById(createdCi.getCiId()); } else { CmsCI updatedCi = updateCI(cmsCi); return getCiById(updatedCi.getCiId()); } } CmsCmProcessor(); void setMdProcessor(CmsMdProcessor mdProcessor); void s...
@Test public void upsertCmsCiTest() throws Exception { CmsCI ci = new CmsCI(); ci.setCiClassId(100); ci.setCiName("Test"); CmsCI ci1 = cmProcessor.upsertCmsCI(ci); System.out.println("CmsCI id = "+ci1.getCiId()); Assert.assertNotNull("Loaded CmsCI is null", ci1); }
CmsRfcUtil { public CmsRfcCI mergeRfcAndCi(CmsRfcCI rfcCi, CmsCI ci, String valueType) { if (rfcCi == null && ci == null) return null; if (ci != null) { if (rfcCi == null) rfcCi = new CmsRfcCI(); rfcCi.setCiId(ci.getCiId()); rfcCi.setCiClassName(ci.getCiClassName()); rfcCi.setCiClassId(ci.getCiClassId()); if (rfcCi.get...
@Test public void testMergeRfcAndCi() { CmsRfcCI rfc = new CmsRfcCI(); CmsRfcAttribute rfcAttribute_1 = createRfcAttribute("1"); rfc.addAttribute(rfcAttribute_1); CmsRfcAttribute rfcAttribute_2 = createRfcAttribute("2"); rfc.addAttribute(rfcAttribute_2); CmsCI ci = new CmsCI(); ci.setNsPath("/test/ns/path"); CmsRfcUtil...
CapacityProcessor { public boolean isCapacityManagementEnabled(String nsPath) { CmsVar softQuotaEnabled = cmProcessor.getCmSimpleVar(CAPACITY_MANAGEMENT_VAR_NAME); if (softQuotaEnabled != null) { String value = softQuotaEnabled.getValue(); if (Boolean.TRUE.toString().equalsIgnoreCase(value)) return true; if (nsPath != ...
@Test public void capacityManagementEnabled() { cmsVarCapacityManagement.setValue("false"); boolean enabled = capacityProcessor.isCapacityManagementEnabled(null); assertEquals(enabled, false, "Capacity Management should be disabled when CAPACITY_MANAGEMENT=false"); cmsVarCapacityManagement.setValue("true"); enabled = c...
CapacityProcessor { public void reserveCapacityForDeployment(CmsDeployment deployment) { String nsPath = deployment.getNsPath(); if (!isCapacityManagementEnabled(nsPath)) return; deleteReservations(getReservationNsPath(nsPath)); Map<String, Object> mappings = getCloudProviderMappings(); if (mappings == null) return; lo...
@Test public void testReserve() throws ReservationException { CmsDeployment deployment = new CmsDeployment(); long deploymentId = 1L; long releaseId = 1L; String createdBy = "user1"; deployment.setReleaseId(deploymentId); deployment.setDeploymentId(releaseId); deployment.setNsPath(ENV_NS_PATH + "/bom"); deployment.setC...
CapacityProcessor { public void commitCapacity(CmsWorkOrder workOrder) { CmsRfcCI rfcCi = workOrder.getRfcCi(); String nsPath = getReservationNsPath(rfcCi.getNsPath()); if (!isCapacityManagementEnabled(nsPath)) return; Map<String, Object> mappings = getCloudProviderMappings(); if (mappings == null) return; List<CmsRfcR...
@Test public void testCommit() throws IOException { long deploymentId = 1L; bomCIs.clear(); bomRels.clear(); createComputeRfc(1L, "add", "M", azureCloud); CmsWorkOrder workOrder = new CmsWorkOrder(); workOrder.setRfcCi(bomCIs.get(0)); workOrder.setCloud(azureCloud); workOrder.setDeploymentId(deploymentId); Map<String, ...
SensorWsController { @RequestMapping(value = "/ops/events/{ciId}", method = RequestMethod.GET) @ResponseBody public Map<Long, Map<String, List<CiOpenEvent>>> getCIOpenEvents(@PathVariable long ciId) { List<CiOpenEvent> openEvents = oeDao.getCiOpenEvents(ciId); Map<Long, Map<String, List<CiOpenEvent>>> result = new Hash...
@Test public void getCiOpens() { Map<Long, Map<String, List<CiOpenEvent>>> outMap = sensorWsController .getCIOpenEvents(CI_ID_A); assert (outMap.size() == 1); }
CapacityProcessor { public void releaseCapacity(CmsWorkOrder workOrder) { CmsRfcCI rfcCi = workOrder.getRfcCi(); String nsPath = getReservationNsPath(rfcCi.getNsPath()); if (!isCapacityManagementEnabled(nsPath)) return; Map<String, Object> mappings = getCloudProviderMappings(); if (mappings == null) return; List<CmsCIR...
@Test public void testRelease() throws IOException { long deploymentId = 1L; bomCIs.clear(); bomRels.clear(); createComputeRfc(1L, "add", "M", azureCloud); CmsWorkOrder workOrder = new CmsWorkOrder(); workOrder.setRfcCi(bomCIs.get(0)); workOrder.setCloud(azureCloud); workOrder.setDeploymentId(deploymentId); Map<String,...
SubscriberService { public List<BasicSubscriber> getSubscribersForNs(String nsPath) { try { return sinkCache.instance().get(new SinkKey(nsPath)); } catch (Exception e) { logger.error("Can't retrieve subscribers for nspath " + nsPath + " from sink cache", e); return Collections.singletonList(defaultSystemSubscriber); } ...
@Test public void getSubscribersForNsTest() { }
ChatPresence { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } ChatPresence other = (ChatPresence) obj; if (chatConference == null) { if (other.chatConference != null) { return false; } } else if (!cha...
@Test public void equalsTest() { ChatPresence c1 = new ChatPresence(chatServer, chatPort, chatConference, chatRoom, chatUser, chatPassword); ChatPresence c2 = new ChatPresence(chatServer, chatPort, chatConference, chatRoom, chatUser, chatPassword); assertEquals(c1, c2); } @Test public void unequalsTest() { ChatPresence...
XMPPMsgService implements NotificationSender { @Override public boolean postMessage(NotificationMessage msg, BasicSubscriber sub) { if (msg == null) throw new IllegalArgumentException("XMPP notification msg is null"); XMPPSubscriber xmppSub = (XMPPSubscriber) sub; String[] nsParts = msg.getNsPath().split("/"); String o...
@Test(expectedExceptions = ClassCastException.class) public void negativeCastTest() throws Exception { this.svc.postMessage(new NotificationMessage(), new EmailSubscriber()); }
HTTPMsgService implements NotificationSender { @Override public boolean postMessage(NotificationMessage msg, BasicSubscriber sub) { URLSubscriber urlSub = (URLSubscriber) sub; boolean isHpom = urlSub.hasHpomXfmr(); CloseableHttpClient httpClient = HttpClients.createDefault(); HttpPost req = new HttpPost(urlSub.getUrl()...
@Test public void badHttpMessageUrlPost() { URLSubscriber sub = new URLSubscriber(); sub.setUserName(this.getClass().getName()); sub.setUrl("this-is-not-valid: boolean result = service.postMessage(null, sub); assertEquals(result, false); } @Test public void testEmailNotification() { URLSubscriber sub = new URLSubscribe...
EmailService implements NotificationSender { @Override public boolean postMessage(NotificationMessage msg, BasicSubscriber subscriber) { EmailSubscriber esub; if (subscriber instanceof EmailSubscriber) { esub = (EmailSubscriber) subscriber; } else { throw new ClassCastException("invalid subscriber " + subscriber.getCla...
@Test public void postMessage() { NotificationMessage msg = new NotificationMessage(); EmailSubscriber sub = mock(EmailSubscriber.class); when(sub.getEmail()).thenReturn(null); boolean result = this.emailService.postMessage(msg, sub); assertTrue(result); }
Dispatcher { public void dispatch(NotificationMessage msg) { if (msg.getNsPath() == null) { String nsPath = getNsPath(msg); if (nsPath != null) { msg.setNsPath(nsPath); } else { logger.error("Can not figure out nsPath for msg " + gson.toJson(msg)); return; } } List<BasicSubscriber> subscribers = sbrService.getSubscribe...
@Test public void testDispatch() { NotificationMessage notificationMessage = new NotificationMessage(); notificationMessage.setNsPath("/a/b"); notificationMessage.setType(NotificationType.ci); notificationMessage.setCmsId(TEST_CID); this.dispatcher.dispatch(notificationMessage); } @Test public void testDispatchNulNs() ...
SensorWsController { @RequestMapping(value = "/ops/events", method = RequestMethod.GET) @ResponseBody public List<Map<Long, Map<String, List<CiOpenEvent>>>> getOpenEvents( @RequestParam(value = "ciIds", required = true) String ciIdsStr) { String[] ciIdsAr = ciIdsStr.split(","); List<Long> ciIds = new ArrayList<Long>();...
@Test public void getOpens() { List<Map<Long, Map<String, List<CiOpenEvent>>>> thoseOpen = this.sensorWsController .getOpenEvents(CI_ID_AVAL + "," + CI_ID_AVAL + "1," + CI_ID_AVAL + "2"); assert (thoseOpen.size() == 0); }
AntennaListener implements MessageListener { public void onMessage(Message msg) { msgs.mark(); Context tc = msgTime.time(); try { NotificationMessage notify = null; if (msg instanceof TextMessage) { try { notify = parseMsg((TextMessage) msg); } catch (JsonParseException e) { logger.error("Got the bad message, not a val...
@Test public void onBadMessage() { TextMessage mockMessage = mock(TextMessage.class); try { when(mockMessage.getText()).thenReturn(""); } catch (JMSException e) { ; } this.listener.onMessage(mockMessage); }
CMSClient { public void checkDpmt(DelegateExecution exec) throws GeneralSecurityException { CmsDeployment dpmt = (CmsDeployment) exec.getVariable(DPMT); try { CmsDeployment cmsDpmt = cmsDpmtProcessor.getDeployment(dpmt.getDeploymentId()); if (cmsDpmt == null) { throw new DJException(CmsError.DJ_NO_DEPLOYMENT_WITH_GIVEN...
@SuppressWarnings("unchecked") @Test(priority=11) public void checkDeploymentTest() throws Exception{ DelegateExecution delegateExecution = mock(DelegateExecution.class); CmsDeployment cmsDeployment = new CmsDeployment(); cmsDeployment.setCreatedBy("created-by-mock"); when(delegateExecution.getVariable("dpmt")).thenRet...
CMSClient { public List<CmsActionOrderSimple> getActionOrders(CmsOpsProcedure proc, int execOrder) throws GeneralSecurityException { logger.info("Geting action orders for procedure id = " + proc.getProcedureId()); long startTime = System.currentTimeMillis(); try { List<CmsActionOrderSimple> aoList = cmsWoProvider.getAc...
@Test(priority=14) public void getActionOrdersTest() throws GeneralSecurityException{ DelegateExecution delegateExecution = mock(DelegateExecution.class); CmsOpsProcedure cmsOpsProcedure = mock(CmsOpsProcedure.class); when(cmsOpsProcedure.getProcedureId()).thenReturn(PROCEDURE_ID); when(delegateExecution.getVariable("p...
CMSClient { public void getEnv4Release(DelegateExecution exec) throws GeneralSecurityException { CmsRelease release = (CmsRelease) exec.getVariable("release"); String[] nsParts = release.getNsPath().split("/"); if (nsParts.length < NSPARTS_SIZE_MIN) { return; } String envNsPath = "/" + nsParts[1] + "/" + nsParts[2]; St...
@Test public void getEnv4ReleaseTest() throws GeneralSecurityException{ DelegateExecution delegateExecution = mock(DelegateExecution.class); CmsRelease cmsRelease = mock(CmsRelease.class); when(cmsRelease.getNsPath()).thenReturn("/dev/int/qa/stage/prod/super"); when(delegateExecution.getVariable("release")).thenReturn(...
CMSClient { public void updateProcedureState(DelegateExecution exec, CmsOpsProcedure proc) { NotificationMessage notify = new NotificationMessage(); notify.setType(NotificationType.procedure); if (proc.getProcedureState().equals(OpsProcedureState.active)) { proc.setProcedureState(OpsProcedureState.complete); } logger.i...
@Test(priority=33) public void updateProcedureStateTest(){ DelegateExecution exec = mock(DelegateExecution.class); CmsCI anchorCi = mock( CmsCI.class); when(anchorCi.getCiId()).thenReturn(TEST_CI_ID); when(anchorCi.getNsPath()).thenReturn("/x/y/z.1"); when(anchorCi.getCiName()).thenReturn("CI_NAME_A"); when(anchorCi.ge...
CMSClient { public void updateActionOrderState(DelegateExecution exec, CmsActionOrderSimple aos, String newState) { aos.setActionState(OpsActionState.valueOf(newState)); try { if (newState.equalsIgnoreCase(COMPLETE)) { CmsActionOrder ao = cmsUtil.custSimple2ActionOrder(aos); opsProcedureProcessor.completeActionOrder(ao...
@Test public void updateActionOrderStateTest(){ DelegateExecution delegateExecution = mock(DelegateExecution.class); CmsOpsProcedure cmsOpsProcedure = mock(CmsOpsProcedure.class); when(delegateExecution.getVariable("proc")).thenReturn(cmsOpsProcedure); CmsActionOrderSimple cmsActionOrderSimple= new CmsActionOrderSimple...
InductorPublisher { protected String getCtxtId(CmsWorkOrderSimpleBase wo) { String ctxtId = ""; if (wo instanceof CmsWorkOrderSimple) { CmsWorkOrderSimple woSimple = CmsWorkOrderSimple.class.cast(wo); ctxtId = "d-" + woSimple.getDeploymentId() + "-" + woSimple.rfcCi.getRfcId() + "-" + woSimple.rfcCi.getExecOrder() + "-...
@Test public void getCtxtId(){ CmsActionOrderSimple ao = new CmsActionOrderSimple(); ao.setProcedureId(1234); ao.setActionId(456); ao.setCiId(789); Assert.assertEquals("a-1234-456-789",publisher.getCtxtId(ao)); } @Test public void getCtxtIdForDeployment(){ CmsWorkOrderSimple wo = new CmsWorkOrderSimple(); wo.setDeploym...
InductorPublisher { String getQueue(CmsWorkOrderSimpleBase wo) { String queueName = null; String location = wo.getCloud().getCiAttributes().get("location"); if ("true".equals(System.getProperty(USE_SHARED_FLAG))) { String cloudName = StringUtils.substringAfterLast(location, "/"); if (StringUtils.isNotBlank(cloudName)) ...
@Test public void getQueueForWo() { CmsWorkOrderSimple wo = new CmsWorkOrderSimple(); CmsCISimple cloud = new CmsCISimple(); cloud.setCiName("openstack-cld1"); wo.setCloud(cloud); cloud.addCiAttribute("location", "/public/oneops/clouds/openstack-cld1"); String queue = publisher.getQueue(wo); Assert.assertEquals(queue, ...
InductorPublisher { public void cleanup() { logger.info("Closing AMQ connection"); closeConnection(); } void setConnFactory(ActiveMQConnectionFactory connFactory); void init(); void publishMessage(DelegateExecution exec, String waitTaskName, String woType); void publishMessage(String processId, String execId, CmsWorkO...
@Test (priority=2) public void cleanupTest() throws Exception{ publisher.getConnectionStats(); publisher.cleanup(); }
SensorWsController { @RequestMapping(value = "/ops/events/{ciId}/close/{eventName}", method = RequestMethod.GET) @ResponseBody public List<CiOpenEvent> closeCIevent(@PathVariable long ciId, @PathVariable String eventName) { oeDao.removeOpenEventForCi(ciId, eventName); return oeDao.getCiOpenEvents(ciId); } void setSens...
@Test public void closeEventTest() { List<CiOpenEvent> closed = this.sensorWsController.closeCIevent( CI_ID_A, OUTAGE_EVENT); assert (closed == null || !closed.contains(CI_ID_A)); }
CmsListener implements MessageListener { public void onMessage(Message message) { try { if (message instanceof TextMessage) { try { logger.info("got message: " + ((TextMessage) message).getText()); processMessage((TextMessage) message); } catch (ActivitiException ae) { logger.error("ActivityException in onMessage", ae)...
@Test public void msgOpsProcedure() throws Exception{ TextMessage message = mock(TextMessage.class); when(message.getStringProperty("source")).thenReturn("opsprocedure"); when(message.getJMSCorrelationID()).thenReturn(null); String msgJson = gson.toJson(createCmsOpsProcedure(OpsProcedureState.active)); when(message.get...
InductorListener implements MessageListener { public void onMessage(Message message) { try { if (message instanceof TextMessage) { if (logger.isDebugEnabled()) { logger.debug("got message: " + ((TextMessage) message).getText()); } try { processResponseMessage((TextMessage) message); } catch (ActivitiException ae) { log...
@Test public void testBadMessage() throws JMSException { TextMessage message = mock(TextMessage.class); when(message.getJMSCorrelationID()).thenThrow(new JMSException("mock-force")); listener.onMessage(message); }
WorkflowController { public String startDpmtProcess(String processKey, Map<String,Object> params){ CmsDeployment dpmt = (CmsDeployment)params.get("dpmt"); String processId = dpmt.getProcessId(); if (processId == null) { logger.info("starting new process for " + processKey + " with params: " + params.toString()); Proces...
@Test (priority=1) public void startDpmtProcessTest(){ Map<String, Object> params = new HashMap<String, Object>(); CmsDeployment theDeployment = new CmsDeployment(); theDeployment.setProcessId(null); params.put("dpmt", theDeployment); wfc.setRuntimeService(runtimeServiceProcessMock); DeploymentNotifier notifier = new D...
WorkflowController { public void pokeSubProcess(String processId, String executionId, Map<String,Object> params){ List<Execution> subExecutions = runtimeService.createExecutionQuery().processInstanceId(processId).activityId("pwo").list(); int retries = subExecutions.size() > 0 ? subExecutions.size() + 1 : 3; for (int i...
@Test public void pokeSubprocessTest(){ Map<String, Object> params = new HashMap<String, Object>(); params.put("k", "v"); wfc.setRuntimeService(runtimeServiceExecutionMock); wfc.pokeSubProcess(RUNNER_PID, EXECUTION_ID, params); }
WorkflowController { public String startReleaseProcess(String processKey, Map<String,Object> params){ logger.info("starting process for " + processKey + " with params: " + params.toString()); ProcessInstance pi = runtimeService.startProcessInstanceByKey(processKey, params); logger.info("started process with id - " + pi...
@Test public void startReleaseProcessTest(){ Map<String, Object> params = new HashMap<String, Object>(); params.put("k", "v"); wfc.setRuntimeService(runtimeServiceExecutionMock); String pid = wfc.startReleaseProcess(RUNNER_PID, params); assertEquals(pid,NEW_PID); }
WorkflowController { public String startOpsProcess(String processKey, Map<String,Object> params){ logger.info("starting process for " + processKey + " with params: " + params.toString()); ProcessInstance pi = runtimeService.startProcessInstanceByKey(processKey, params); logger.info("started process with id - " + pi.get...
@Test public void startOpsProcessTest(){ Map<String, Object> params = new HashMap<String, Object>(); params.put("k", "v"); wfc.setRuntimeService(runtimeServiceExecutionMock); String pid = wfc.startOpsProcess(RUNNER_PID, params); assertEquals(pid,NEW_PID); }
WoDispatcher { public void processWOResult(WoProcessResponse woResult) { String[] props = woResult.getProcessId().split("!"); String processId = props[0]; String executionId = props[1]; logger.info("Got inductor respose"); logger.info(gson.toJson(woResult)); Map<String, Object> params = new HashMap<String, Object>(); p...
@Test public void processWORResultTest(){ WoProcessResponse woResultOut = new WoProcessResponse(); woResultOut.setWoProcessResult("result-mocked"); woResultOut.setProcessId("11!22!33"); CmsWorkOrderSimple woResult = new CmsWorkOrderSimple(); woResultOut.setWo(woResult); wod.processWOResult(woResultOut); }
WoDispatcher { public void dispatchWO(WorkOrderContext woContext, CmsWorkOrderSimple assembledWo) throws Exception { try { if (assembledWo.rfcCi.getImpl() == null) { inductorPublisher.publishMessage( Long.toString(assembledWo.getDeploymentId()), Long.toString(assembledWo.getDpmtRecordId()), assembledWo, "", "deploybom"...
@Test public void distachWOTest(){ DelegateExecution delegateExecution = mock(DelegateExecution.class); CmsWorkOrderSimple cmsWorkOrderSimple = new CmsWorkOrderSimple(); CmsRfcCISimple rfcCi = new CmsRfcCISimple(); rfcCi.setImpl("class::com.oneops.controller.workflow.WoProcessorMockImpl::rfc::impl"); cmsWorkOrderSimple...
StmtBuilder { public ThresholdStatements getThresholdStatements(long manifestId, String source, long checksum, String thresholdsJson, boolean isHeartbeat, String hbDuration) { ThresholdStatements trStatements = new ThresholdStatements(); trStatements.setChecksum(checksum); if (thresholdsJson != null && thresholdsJson.l...
@Test public void getThreshStmtTest() { StmtBuilder builder = new StmtBuilder(); Gson gson = new Gson(); Map<String, ThresholdDef> trsholds = new HashMap<>(); trsholds.put(NAME_THRESH, THRESH_DEF); String thresholdsJson = gson.toJson(trsholds); ThresholdStatements stmt = builder.getThresholdStatements(MANI_ID, SOURCE, ...
CtrlrServlet { @RequestMapping(method=RequestMethod.POST, value="/wo/result") @ResponseBody public Map<String, String> createCIRelation( @RequestBody WoProcessResponse woResult) { woDispatcher.processWOResult(woResult); return null; } void setRuntimeService(RuntimeService runtimeService); void setWoDispatcher(WoDispat...
@Test public void createCIRTest(){ this.servlet.createCIRelation(null); }
CtrlrServlet { @RequestMapping(method=RequestMethod.GET, value="/resumeall") @ResponseBody public String test() { logger.info("Resuming crashed processes!!!"); List<ProcessInstance> processes = runtimeService.createProcessInstanceQuery().active().list(); for (ProcessInstance process : processes) { ExecutionEntity exec ...
@Test public void test(){ String message= this.servlet.test(); assertEquals(message,"Resumed all processes"); }
FqdnExecutor implements ComponentWoExecutor { @Override public Response execute(CmsWorkOrderSimple wo, String dataDir) { String logKey = woHelper.getLogKey(wo); if (isFqdnInstance(wo) && isLocalWo(wo) && isGdnsEnabled(wo) && isTorbitServiceType(wo)) { executeInternal(wo, logKey, "deployment", dataDir, (t, i) -> { if (i...
@Test public void shouldNotMatchIfGdnsDisabled() { CmsWorkOrderSimple wo = woWith2Clouds(); wo.getPayLoadEntry("Environment").get(0).addCiAttribute("global_dns", "false"); Response response = fqdnExecutor.execute(wo, "/tmp"); assertThat(response.getResult(), is(Result.NOT_MATCHED)); } @Test public void shouldNotMatchFo...
ProcessRunner { public ProcessResult executeProcessRetry(ExecutionContext executionContext) { boolean shutdown = config.hasCloudShutdownFor(executionContext.getWo()); int maxRetries = executionContext.getRetryCount(); if (shutdown) { maxRetries = 0; long timeout = config.getCmdTimeout(); for (int i = 0; i < executionCo...
@Test public void testExecuteProcessRetry() { Config c = new Config(); c.setChefTimeout(10); ProcessRunner pr = new ProcessRunner(c); String[] cmd = new String[2]; cmd[0] = "echo"; cmd[1] = "\"hey there \""; ProcessResult procResult = pr.executeProcessRetry(cmd, "", 3); assertTrue(procResult.getResultCode() == 0); } @T...
StmtBuilder { public String buildTriggerStmt(long manifestId, String source, String trsName, ThresholdDef def) { String name = source + ":" + trsName; int duration = def.getTrigger().getDuration(); duration = (duration > WNDW_SIZE_MAX) ? WNDW_SIZE_MAX : duration; String coolOff = def.getCooloff(); coolOff = (coolOff !=...
@Test public void buildTriggerStmtTest() { String triggerStmt = "insert into OpsEvent select ciId, manifestId, timestamp, bucket, metrics, 'open' as state, 'metric' " + "as type, source, 15 as coolOff, 'opsmq-compute-cpu:HighCpuUtil' as name, 'notify' as ciState, count(1) as count from " + "PerfEvent(manifestId = 48232...
OpampWsController { @RequestMapping(value="/status/{ciId}", method = RequestMethod.GET) @ResponseBody public String getCIOpenEvents(@PathVariable long ciId) { logger.info(ciId); return null; } @RequestMapping(value="/status/{ciId}", method = RequestMethod.GET) @ResponseBody String getCIOpenEvents(@PathVariable long ci...
@Test public void testController(){ OpampWsController wsController = new OpampWsController(); String eventsOut = wsController.getCIOpenEvents(-1); assertNull(eventsOut); }
BadStateProcessor { public void processGoodState( CiChangeStateEvent event) { notifier.sendOpsEventNotification(event); } void setOpsProcProcessor(OpsProcedureProcessor opsProcProcessor); void setCoProcessor(CiOpsProcessor coProcessor); void setEnvProcessor(EnvPropsProcessor envProcessor); void setCmProcessor(CmsCmPro...
@Test public void processGoodStateTest(){ Long aCid = 678L; BadStateProcessor bsp = new BadStateProcessor(); bsp.setNotifier(mock(Notifications.class)); EnvPropsProcessor envProcessorMock= mock(EnvPropsProcessor.class); CmsCI cmsCI = new CmsCI(); when(envProcessorMock.isAutorepairEnabled(aCid)).thenReturn(true); bsp.se...
BadStateProcessor { public void processUnhealthyState(CiChangeStateEvent event) throws OpampException { long ciId = event.getCiId(); long unhealthyStartTime = getUnhealthyStartTime(ciId); long currentTimeMillis = System.currentTimeMillis(); long unhealthySinceMillis = (currentTimeMillis - unhealthyStartTime); long repa...
@Test public void processUnhealthyStateTest() throws OpampException{ Long aCid = 321L; BadStateProcessor bsp = new BadStateProcessor(); bsp.setNotifier(mock(Notifications.class)); CiOpsProcessor copMock=mock(CiOpsProcessor.class); when(copMock.getCIstate(aCid)).thenReturn("unhealthy"); bsp.setCoProcessor(copMock); EnvP...
BadStateProcessor { public static long getNextRepairTime(long delayStartTime, long coolOffPeriod, double exponentialFactor, long repairRetriesCountSinceDelay, long repairRetriesMaxPeriod) { long max = Math.min(repairRetriesCountSinceDelay + 1, (long) Math.ceil((Math.log(1 + repairRetriesMaxPeriod / coolOffPeriod) / Mat...
@Test public void testExponentialDelayFunction() throws Exception { int coolOff = 15 * 60 * 1000; int exponentialFactor = 2; int repairRetriesCountSinceDelay = 6; int maxDaysRepair = 11; Calendar calendar_Oct05_0000_2016 = new GregorianCalendar(2016, 9, 5); long maxRepairRetryPeriod = maxDaysRepair * 24 * 60 * 60 * 100...
Notifications { public void sendDependsOnUnhealthyNotification(OpsBaseEvent opsEvent) { long ciId = opsEvent.getCiId(); CmsCI ci = cmProcessor.getCiById(ciId); if (ci == null) { logger.error("Can not get CmsCI for id - " + ciId); return; } String text = buildNotificationPrefix(ci.getNsPath()) + " ci: " + ci.getCiName()...
@Test public void testSendDependsOnUnhealthyNotification(){ Notifications noti = new Notifications(); noti.setAntennaClient(antennaClientMock); noti.setCmProcessor(cmProcessorMock); noti.setEnvProcessor(envProcessorMock); EventUtil eventUtil = new EventUtil(); eventUtil.setGson(new Gson()); noti.setEventUtil(eventUtil)...
FlexStateProcessor { public void processOverutilized(CiChangeStateEvent event, boolean isNewState) throws OpampException{ long ciId = event.getCiId(); if (CI_STATE_OVERUTILIZED.equals(coProcessor.getCIstate(ciId))) { CmsCI env; if (envProcessor.isAutoscaleEnabled(ciId) && (env = envProcessor.getEnv4Bom(ciId)) != null) ...
@Test public void processOverutilized(){ CiOpsProcessor cop = mock(CiOpsProcessor.class); when(cop.getCIstate(ID_WITH_AUTO_SCALING)).thenReturn("overutilized"); when(cop.getCIstate(ID_WITHOUT_AUTO_SCALING)).thenReturn("other-state"); FlexStateProcessor fsp = new FlexStateProcessor(); fsp.setCoProcessor(cop); fsp.setEnv...
FlexStateProcessor { public void processUnderutilized(CiChangeStateEvent event, boolean isNewState, long originalEventTimestamp) throws OpampException{ long ciId = event.getCiId(); if ("underutilized".equals(coProcessor.getCIstate(ciId))) { CmsCI env; if (envProcessor.isAutoscaleEnabled(ciId) && (env = envProcessor.get...
@Test public void processUnderutilized(){ CiOpsProcessor cop = mock(CiOpsProcessor.class); when(cop.getCIstate(ID_WITH_AUTO_SCALING)).thenReturn("underutilized"); when(cop.getCIstate(0L)).thenReturn("other-state"); FlexStateProcessor processor = new FlexStateProcessor(); processor.setCoProcessor(cop); processor.setEnvP...
OpsEventListener implements MessageListener { public void onMessage(Message msg) { try { logger.debug(msg); if (!envProcessor.isOpAmpSuspended() && (msg instanceof TextMessage)) { envProcessor.refreshMdCache(); try { String type = msg.getStringProperty("type"); if ("ci-change-state".equals(type)) { CiChangeStateEvent e...
@Test public void testOnMessage() { String eventJson = makeJson(UNHEALTHY, "oldstate"); String eventJson1 = makeJson(NOTIFY, "oldstate"); String eventJson2 = makeJson("overutilized", "oldstate"); String eventJson3 = makeJson("underutilized", "oldstate"); String eventJson4 = makeJson("good", UNHEALTHY); String eventJson...
CIEventReader extends BaseEventReader { @Override protected CMSEvent populateEvent(CMSEventRecord record) { switch (EventSource.toEventSource(record.getSourceName())) { case cm_ci: return getCi(record); case cm_ci_rel: return getCiRel(record); case rfc_ci: return getRfcCi(record); case rfc_relation: return getRfcRelati...
@Test public void eventForDesignCi() { addCiWithNsPath("/org1/assembly1/_design/plt1", "catalog.Compute"); CmsCI orgCi = new CmsCI(); orgCi.setCiId(1400); orgCi.setNsPath("/"); orgCi.setCiClassName("account.Organization"); orgCi.setCiName("org1"); orgCi.setCiStateId(100); CmsCIAttribute tagAttr = new CmsCIAttribute(); ...
StmtBuilder { public String buildResetStmt(long manifestId, String source, String trsName, ThresholdDef def) { String name = source + ":" + trsName; int duration = def.getReset().getDuration(); duration = (duration > WNDW_SIZE_MAX) ? WNDW_SIZE_MAX : duration; return new StringBuilder(400) .append("insert into OpsEvent ...
@Test public void buildResetStmtTest() { String resetStmt = "insert into OpsEvent select ciId, manifestId, timestamp, bucket, metrics, 'reset' as state, 'metric' " + "as type, source, 'daqws-compute-disk:LowDiskSpace' as name, 'notify' as ciState, count(1) as count from " + "PerfEvent(manifestId = 5351305 and bucket = ...
StmtBuilder { public String buildHeartbeatStmt(long manifestId, String source, String duration) { return new StringBuilder(100) .append("insert into OpsEvent select lastEvent.ciId as ciId, lastEvent.manifestId as manifestId, lastEvent.channel as channel, lastEvent.timestamp as timestamp, 'open' as state, 'heartbeat' as...
@Test public void buildHeartbeatStmtTest() { String hbStmt = "insert into OpsEvent select lastEvent.ciId as ciId, lastEvent.manifestId as manifestId, lastEvent.channel " + "as channel, lastEvent.timestamp as timestamp, 'open' as state, 'heartbeat' as type, lastEvent.source as source, " + "lastEvent.source || ':Heartbea...
Sensor { public Map<String, String> getAllLoadedStmts() { Map<String, String> stmts = new HashMap<>(); for (String stmtName : epService.getEPAdministrator().getStatementNames()) { stmts.put(stmtName, epService.getEPAdministrator().getStatement(stmtName).getText()); } return stmts; } void setStmtBuilder(StmtBuilder stm...
@Test public void checkAllLoadedStatements() { Map<String, String> outMap = baseSensor.getAllLoadedStmts(); assert (outMap.size() > 0); }
Sensor { public boolean loadStatements(long manifestId, String source) { Threshold tr = getThreshold(manifestId, source); if (tr == null) { return false; } ThresholdStatements stmts = stmtBuilder.getThresholdStatements( manifestId, source, tr.getCrc(), tr.getThresholdJson(), tr.isHeartbeat(), tr.getHbDuration()); for (...
@Test public void loadStatementsTest() { baseSensor.setTsDao(mock(ThresholdsDao.class)); baseSensor.loadStatements(0, "mock-source"); }
OpsEventPublisher { public void cleanup() { logger.info("Closing AMQ connection"); closeConnection(); } void setConnectionFactory(ActiveMQConnectionFactory connectionFactory); void setQueue(String queue); void setPersistent(boolean persistent); void setTimeToLive(long timeToLive); void init(); void publishCiStateMessa...
@Test public void cleanupTest(){ OpsEventPublisher oep = new OpsEventPublisher(); oep.cleanup(); }
CloudUtil { public Set<String> getMissingServices(long manifestPlatformId){ Set<String> requiredServices = getServicesForPlatform(manifestPlatformId); return getMissingCloudServices(manifestPlatformId,requiredServices).keySet(); } void check4missingServices(Set<Long> platformIds); Set<String> getMissingServices(long m...
@Test public void testGetMissingServices() throws Exception { }
BomRfcBulkProcessor { void processAndValidateVars(List<CmsCI> cis, Map<String, String> cloudVars, Map<String, String> globalVars, Map<String, String> localVars) { ExceptionConsolidator ec = CIValidationException.consolidator(CmsError.TRANSISTOR_CM_ATTRIBUTE_HAS_BAD_GLOBAL_VAR_REF, cmsUtil.getCountOfErrorsToReport()); f...
@Test public void processAndValidateVars(){ ArrayList<CmsCI> cis = new ArrayList<>(); CmsCI ci = new CmsCI(); ci.setCiName("testCi"); ci.setNsPath("/path"); CmsCIAttribute attribute1 = new CmsCIAttribute(); attribute1.setAttributeName("testAttribute1"); attribute1.setDjValue("$OO_GLOBAL{test1}"); attribute1.setDfValue(...
BomManagerImpl implements BomManager { SortedMap<Integer, SortedMap<Integer, List<CmsCIRelation>>> getOrderedClouds(List<CmsCIRelation> cloudRels, boolean reverse) { SortedMap<Integer, SortedMap<Integer, List<CmsCIRelation>>> result = reverse ? new TreeMap<>(Collections.reverseOrder()) : new TreeMap<>(); for (CmsCIRela...
@Test public void testEmptyDeploymentOrderDoesNotThrowNFE(){ CmsCmProcessor cmProcessor =mock(CmsCmProcessor.class); BomManagerImpl impl = getInstance(cmProcessor); String[] primaryClouds = {"c1", "c2"}; List<CmsCIRelation> platformCloudRels = Stream.of(primaryClouds) .map(s -> (createPrimaryCloud(s))) .collect(toList(...
BomManagerImpl implements BomManager { Map<Integer, List<CmsCI>> getOrderedPlatforms(EnvBomGenerationContext context) { List<CmsCI> platforms = context.getPlatforms(); List<CmsCIRelation> allLinksToRels = context.getLinksToRelations(); Map<Long, Integer> plat2ExecOrderMap = new HashMap<>(); Map<Long, CmsCI> platformIdM...
@Test(expectedExceptions = {}) public void verifyOrderDeploymentOrder() { CmsCI p1 = ci("p1", 1); CmsCI p2 = ci("p2", 2); CmsCI p3 = ci("p3", 3); CmsCI p4 = ci("p4", 4); CmsCI p5 = ci("p5", 5); List<CmsCI> plats = Arrays.asList(p1, p2, p3, p4, p5); List<CmsCIRelation> links = new ArrayList<>(); links.add(relation(CmsCo...
BomManagerImpl implements BomManager { void check4Secondary(PlatformBomGenerationContext context, List<CmsCIRelation> platformCloudRels) { String nsPath = context.getBomNsPath(); List<CmsCIRelation> entryPoints = context.getEntryPoints(); if(entryPoints.size() == 0) { logger.info("Skipping secondary check - there is no...
@Test(expectedExceptions = {}) public void somePrimaryOnManifestAllPrimaryDeployed() throws Exception { CmsCmProcessor cmProcessor =mock(CmsCmProcessor.class); BomManagerImpl impl = getInstance(cmProcessor); String[] primaryClouds = {"c1", "c2"}; String[] secondaryClouds = {"c3", "c4"}; List<CmsCIRelation> platformClou...
PlatformHADRCrawlerPlugin extends AbstractCrawlerPlugin { public String IsHA(Platform platform) { if (platform.getActiveClouds().size() >= 2) { return "HA"; } return "Non-HA"; } PlatformHADRCrawlerPlugin(); SearchDal getSearchDal(); void setSearchDal(SearchDal searchDal); void readConfig(); void processEnvironment(Envi...
@Test(enabled = true) private void test_IsHA() { plugin = new PlatformHADRCrawlerPlugin(); Platform platform = new Platform(); List<String> activeClouds = new ArrayList<String>(); activeClouds.add("dc1-TestCloud1"); activeClouds.add("dc1-TestCloud2"); platform.setActiveClouds(activeClouds); assertEquals(plugin.IsHA(pla...
BomManagerImpl implements BomManager { void checkPackCloudWhiteList(CmsCI platform, CmsCI cloud) { CmsVar cmsVar = cmProcessor.getCmSimpleVar(PACK_CLOUD_NS_WHITELIST_CMS_VAR_NAME); if (cmsVar == null ) return; String json = cmsVar.getValue(); if (json == null || json.isEmpty()) return; try { Map<String, Map<String, Lis...
@Test(expectedExceptions = {}) public void passPackCloudWhiteList() { CmsCmProcessor cmProcessor = mock(CmsCmProcessor.class); BomManagerImpl impl = getInstance(cmProcessor); impl.gson = new Gson(); CmsCI platform = platform(); CmsCI cloud = cloud(); CmsVar var = new CmsVar(); var.setName(BomManagerImpl.PACK_CLOUD_NS_W...
InMemoryDJMapper implements DJMapper { @Override public long getNextDjId() { return djId++; } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getReleaseStateId(String stateN...
@Test public void testGetNextDjId() throws Exception { assertEquals(mapper.getNextDjId(), 1); assertEquals(mapper.getNextDjId(), 2); }
InMemoryDJMapper implements DJMapper { @Override public long getNextCiId() { return ciId++; } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getReleaseStateId(String stateN...
@Test public void testGetNextCiId() throws Exception { assertEquals(mapper.getNextCiId(), 1); assertEquals(mapper.getNextCiId(), 2); }
InMemoryDJMapper implements DJMapper { @Override public Integer getReleaseStateId(String stateName) { return 1; } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getReleaseS...
@Test public void testGetReleaseStateId() throws Exception { assertEquals(mapper.getReleaseStateId(""), new Integer(1)); }
InMemoryDJMapper implements DJMapper { @Override public Integer getRfcCiActionId(String stateName) { throw new UnsupportedOperationException(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(...
@Test public void testGetRfcCiActionId() throws Exception { assertThrows(UnsupportedOperationException.class, () -> mapper.getRfcCiActionId("")); }
InMemoryDJMapper implements DJMapper { @Override public void createRelease(CmsRelease release) { this.release = release; } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer ge...
@Test public void testCreateRelease() throws Exception { CmsRelease release = new CmsRelease(); release.setReleaseId(1); mapper.createRelease(release); assertEquals(mapper.getReleaseById(1), release); }
InMemoryDJMapper implements DJMapper { @Override public void brushReleaseExecOrder(long releaseId) { List<CmsRfcCI> orderedCIs = cis.values().stream() .sorted(Comparator.comparingInt(ci -> ci.getExecOrder())) .collect(Collectors.toList()); int lastExecOrder = 0; int newExecOrder = 0; for (CmsRfcCI ci : orderedCIs) { if...
@Test public void testBrushReleaseExecOrder() throws Exception { }
InMemoryDJMapper implements DJMapper { @Override public CmsRelease getReleaseById(long releaseId) { return release; } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getRele...
@Test public void testGetReleaseById() throws Exception { assertNull(mapper.getReleaseById(1)); CmsRelease release = new CmsRelease(); release.setReleaseId(1); mapper.createRelease(release); assertEquals(mapper.getReleaseById(1), release); }
InMemoryDJMapper implements DJMapper { @Override public List<CmsRelease> getReleaseBy3(String nsPath, String releaseName, String releaseState) { return new ArrayList<>(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); ...
@Test public void testGetReleaseBy3() throws Exception { assertEquals(mapper.getReleaseBy3("", "", ""), new ArrayList()); }
InMemoryDJMapper implements DJMapper { @Override public int updateRelease(CmsRelease release) { this.release = release; return release.getReleaseStateId(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long ...
@Test public void testUpdateRelease() throws Exception { assertNull(mapper.getReleaseById(1)); CmsRelease release = new CmsRelease(); release.setReleaseId(1); mapper.createRelease(release); assertEquals(mapper.getReleaseById(1), release); CmsRelease release2 = new CmsRelease(); release2.setReleaseId(2); mapper.updateRe...
InMemoryDJMapper implements DJMapper { @Override public int deleteRelease(long releaseId) { return 0; } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getReleaseStateId(Str...
@Test public void testDeleteRelease() throws Exception { }
InMemoryDJMapper implements DJMapper { @Override public void commitRelease(long releaseId, Boolean setDfValue, Integer newCiState, boolean delete4real, String userId, String desc) { throw new UnsupportedOperationException(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); C...
@Test public void testCommitRelease() throws Exception { assertThrows(UnsupportedOperationException.class, () -> mapper.commitRelease(1, true, 1, true, "", "")); }
InMemoryDJMapper implements DJMapper { @Override public void createRfcCI(CmsRfcCI rfcCi) { rfcCi.setIsActiveInRelease(true); cis.put(rfcCi.getRfcId(), rfcCi); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override lo...
@Test public void testCreateRfcCI() throws Exception { assertEquals(mapper.getCis().size(), 0); CmsRfcCI rfcCi = new CmsRfcCI(); rfcCi.setRfcId(1); mapper.createRfcCI(rfcCi); assertEquals(mapper.getCis().size(), 1); assertEquals(mapper.getCis().get(1L), rfcCi); }
InMemoryDJMapper implements DJMapper { @Override public void createRfcLog(CmsRfcCI rfcCi) { } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getReleaseStateId(String stateN...
@Test public void testCreateRfcLog() throws Exception { }
InMemoryDJMapper implements DJMapper { @Override public int rmRfcCIfromRelease(long rfcId) { throw new UnsupportedOperationException(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Over...
@Test public void testRmRfcCIfromRelease() throws Exception { assertThrows(UnsupportedOperationException.class, () -> mapper.rmRfcCIfromRelease(1)); }
PlatformHADRCrawlerPlugin extends AbstractCrawlerPlugin { public String parseAssemblyNameFromNsPath(String path) { if (path != null && !path.isEmpty()) { String[] parsedArray = path.split("/"); return parsedArray[2]; } else { return ""; } } PlatformHADRCrawlerPlugin(); SearchDal getSearchDal(); void setSearchDal(Search...
@Test(enabled = true) private void test_parseAssemblyNameFromNsPath() { plugin = new PlatformHADRCrawlerPlugin(); String nsPath = "/orgname/assemblyname/platformname/bom/env-dev/1"; assertEquals(plugin.parseAssemblyNameFromNsPath(nsPath), "assemblyname"); }
InMemoryDJMapper implements DJMapper { @Override public void updateRfcCI(CmsRfcCI rfcCI) { cis.put(rfcCI.getRfcId(), rfcCI); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Intege...
@Test public void testUpdateRfcCI() throws Exception { assertEquals(mapper.getCis().size(), 0); CmsRfcCI rfcCi = new CmsRfcCI(); rfcCi.setRfcId(1); mapper.createRfcCI(rfcCi); assertEquals(mapper.getCis().size(), 1); assertEquals(mapper.getCis().get(1L), rfcCi); CmsRfcCI rfcCi2 = new CmsRfcCI(); rfcCi2.setRfcId(1); mapp...
InMemoryDJMapper implements DJMapper { @Override public void updateRfcLog(CmsRfcCI rfcCI) { } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getReleaseStateId(String stateN...
@Test public void testUpdateRfcLog() throws Exception { }
InMemoryDJMapper implements DJMapper { @Override public void insertRfcCIAttribute(CmsRfcAttribute attr) { } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getReleaseStateId...
@Test public void testInsertRfcCIAttribute() throws Exception { }
InMemoryDJMapper implements DJMapper { @Override public void updateRfcCIAttribute(CmsRfcAttribute attr) { } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getReleaseStateId...
@Test public void testUpdateRfcCIAttribute() throws Exception { }
InMemoryDJMapper implements DJMapper { @Override public CmsRfcCI getRfcCIById(long rfcId) { return cis.get(rfcId); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Override Integer getRelea...
@Test public void testGetRfcCIById() throws Exception { CmsRfcCI rfcCi = new CmsRfcCI(); rfcCi.setRfcId(1); mapper.createRfcCI(rfcCi); assertEquals(mapper.getCis().size(), 1); assertEquals(mapper.getCis().get(1L), rfcCi); }
InMemoryDJMapper implements DJMapper { @Override public CmsRfcCI getOpenRfcCIByCiId(long ciId) { for (CmsRfcCI rfc : cis.values()) { if ((ciId == rfc.getCiId()) && rfc.getIsActiveInRelease()) return rfc; } return null; } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRele...
@Test public void testGetOpenRfcCIByCiId() throws Exception { CmsRfcCI rfcCi = new CmsRfcCI(); rfcCi.setRfcId(1); rfcCi.setCiId(1); mapper.createRfcCI(rfcCi); CmsRfcCI rfcCi2 = new CmsRfcCI(); rfcCi2.setRfcId(2); rfcCi2.setCiId(2); mapper.createRfcCI(rfcCi2); rfcCi2.setIsActiveInRelease(false); assertEquals(mapper.getO...
InMemoryDJMapper implements DJMapper { @Override public List<CmsRfcCI> getOpenRfcCIByCiIdList(List<Long> ciIds) { return cis.values().stream() .filter(r -> (ciIds.contains(r.getCiId())) ) .collect(Collectors.toList()); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRele...
@Test public void testGetOpenRfcCIByCiIdList() { CmsRfcCI rfcCi = new CmsRfcCI(); rfcCi.setRfcId(1); rfcCi.setCiId(1); mapper.createRfcCI(rfcCi); CmsRfcCI rfcCi2 = new CmsRfcCI(); rfcCi2.setRfcId(2); rfcCi2.setCiId(2); mapper.createRfcCI(rfcCi2); ArrayList<Long> ciIds = new ArrayList<>(); ciIds.add(1L); ciIds.add(2L); ...
InMemoryDJMapper implements DJMapper { @Override public List<CmsRfcCI> getRfcCIBy3(long releaseId, Boolean isActive, Long ciId) { return cis.values().stream() .filter(r -> (ciId == null || ciId.equals(r.getCiId())) && (isActive == null || isActive == r.getIsActiveInRelease())) .collect(Collectors.toList()); } InMemoryD...
@Test public void testGetRfcCIBy3() throws Exception { CmsRfcCI rfcCi = new CmsRfcCI(); rfcCi.setRfcId(1); rfcCi.setCiId(1); mapper.createRfcCI(rfcCi); CmsRfcCI rfcCi2 = new CmsRfcCI(); rfcCi2.setRfcId(2); rfcCi2.setCiId(2); mapper.createRfcCI(rfcCi2); List<CmsRfcCI> list = mapper.getRfcCIBy3(1, true, 2L); assertEquals...
InMemoryDJMapper implements DJMapper { @Override public List<CmsRfcCI> getRfcCIByClazzAndName(String nsPath, String clazzName, String ciName, Boolean isActive, String state) { return cis.values().stream() .filter(r -> (nsPath == null || nsPath.equals(r.getNsPath())) && (clazzName == null || clazzName.equals(r.getCiClas...
@Test public void testGetRfcCIByClazzAndName() throws Exception { CmsRfcCI rfcCi = new CmsRfcCI(); rfcCi.setRfcId(1); rfcCi.setCiId(1); rfcCi.setNsPath("/test"); rfcCi.setCiName("test"); rfcCi.setCiState("open"); rfcCi.setCiClassName("clazz"); CmsRfcCI rfcCi2 = new CmsRfcCI(); rfcCi2.setRfcId(2); rfcCi2.setCiId(2); rfc...
InMemoryDJMapper implements DJMapper { @Override public List<CmsRfcCI> getOpenRfcCIByClazzAndNameLower(String nsPath, String clazzName, String ciName) { throw new UnsupportedOperationException(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Over...
@Test public void testGetOpenRfcCIByClazzAndNameLower() throws Exception { assertThrows(UnsupportedOperationException.class, () -> mapper.getOpenRfcCIByClazzAndNameLower("", "", "")); }
PlatformHADRCrawlerPlugin extends AbstractCrawlerPlugin { public String getOOURL(String path) { return oo_baseUrl + "/r/ns?path=" + path; } PlatformHADRCrawlerPlugin(); SearchDal getSearchDal(); void setSearchDal(SearchDal searchDal); void readConfig(); void processEnvironment(Environment env, Map<String, Organization>...
@Test(enabled = true) private void test_getOOURL() { System.setProperty("hadr.oo.baseurl", "https: plugin = new PlatformHADRCrawlerPlugin(); String nsPath = "/orgname/assemblyname/platformname/bom/env-dev/1"; String expectedOOURLString = "https: assertEquals(plugin.getOOURL(nsPath), expectedOOURLString); } @Test(enable...
InMemoryDJMapper implements DJMapper { @Override public List<CmsRfcCI> getOpenRfcCIByNsLike(String ns, String nsLike, String clazzName, String ciName) { throw new UnsupportedOperationException(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Over...
@Test public void testGetOpenRfcCIByNsLike() throws Exception { assertThrows(UnsupportedOperationException.class, () -> mapper.getOpenRfcCIByNsLike("", "", "", "")); }
InMemoryDJMapper implements DJMapper { @Override public List<CmsRfcCI> getOpenRfcCIByClazzAnd2Names(String nsPath, String clazzName, String ciName, String altCiName) { throw new UnsupportedOperationException(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getR...
@Test public void testGetOpenRfcCIByClazzAnd2Names() throws Exception { assertThrows(UnsupportedOperationException.class, () -> mapper.getOpenRfcCIByClazzAnd2Names("", "", "", "")); }
InMemoryDJMapper implements DJMapper { @Override public List<CmsRfcCI> getClosedRfcCIByCiId(long ciId) { throw new UnsupportedOperationException(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextC...
@Test public void testGetClosedRfcCIByCiId() throws Exception { assertThrows(UnsupportedOperationException.class, () -> mapper.getClosedRfcCIByCiId(1)); }
InMemoryDJMapper implements DJMapper { @Override public List<CmsRfcCI> getRollUpRfc(long ciId, long rfcId) { throw new UnsupportedOperationException(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getN...
@Test public void testGetRollUpRfc() throws Exception { assertThrows(UnsupportedOperationException.class, () -> mapper.getRollUpRfc(1L, 1)); }
InMemoryDJMapper implements DJMapper { @Override public List<CmsRfcAttribute> getRfcCIAttributes(long rfcId) { return new ArrayList<>(); } InMemoryDJMapper(); Map<Long, CmsRfcCI> getCis(); Map<Long, CmsRfcRelation> getRelations(); CmsRelease getRelease(); @Override long getNextDjId(); @Override long getNextCiId(); @Ove...
@Test public void testGetRfcCIAttributes() throws Exception { assertEquals(mapper.getRfcCIAttributes(1), new ArrayList()); }