-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed autoscaler label content to contain operation id and added tests
- Loading branch information
1 parent
0047f78
commit 5c6f428
Showing
9 changed files
with
74 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 22 additions & 2 deletions
24
...cess/src/test/java/org/cloudfoundry/multiapps/controller/process/steps/StepsTestUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
package org.cloudfoundry.multiapps.controller.process.steps; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import com.sap.cloudfoundry.client.facade.CloudControllerClient; | ||
import com.sap.cloudfoundry.client.facade.domain.CloudApplication; | ||
import org.cloudfoundry.client.v3.Metadata; | ||
import org.cloudfoundry.multiapps.common.util.JsonUtil; | ||
import org.cloudfoundry.multiapps.controller.client.lib.domain.CloudApplicationExtended; | ||
import org.cloudfoundry.multiapps.controller.core.cf.metadata.MtaMetadataLabels; | ||
import org.cloudfoundry.multiapps.controller.process.variables.Variables; | ||
import org.flowable.engine.delegate.DelegateExecution; | ||
import org.mockito.Mockito; | ||
|
||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class StepsTestUtil { | ||
|
||
public static void mockApplicationsToDeploy(List<CloudApplicationExtended> applications, DelegateExecution execution) { | ||
if (applications == null || applications.isEmpty()) { | ||
return; | ||
} | ||
var stubbing = Mockito.when(execution.getVariable(Variables.APP_TO_PROCESS.getName())); | ||
var stubbing = when(execution.getVariable(Variables.APP_TO_PROCESS.getName())); | ||
for (var app : applications) { | ||
stubbing = stubbing.thenReturn(JsonUtil.toJson(app)); | ||
} | ||
} | ||
|
||
public static void prepareDisablingAutoscaler(ProcessContext context, CloudControllerClient client, CloudApplication application, | ||
UUID uid) { | ||
context.setVariable(Variables.CORRELATION_ID, ""); | ||
when(client.getApplicationGuid(application.getName())).thenReturn(uid); | ||
} | ||
|
||
public static void testIfEnabledOrDisabledAutoscaler(CloudControllerClient client, String labelValue, UUID uid) { | ||
Metadata metadata = Metadata.builder() | ||
.label(MtaMetadataLabels.AUTOSCALER_LABEL, labelValue) | ||
.build(); | ||
verify(client).updateApplicationMetadata(uid, metadata); | ||
} | ||
} |