-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
59 additions
and
345 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Cognite.Extractor.Common; | ||
using CogniteSdk; | ||
using CogniteSdk.Alpha; | ||
|
||
namespace Cognite.Simulator.Tests { | ||
public class TestHelpers { | ||
|
||
public static async Task SimulateProsperRunningAsync(Client cdf, string connectorName = "scheduler-test-connector" ) { | ||
var integrations = await cdf.Alpha.Simulators.ListSimulatorIntegrationsAsync( | ||
new SimulatorIntegrationQuery | ||
{ | ||
} | ||
).ConfigureAwait(false); | ||
var existing = integrations.Items.FirstOrDefault(i => i.ExternalId == connectorName && i.SimulatorExternalId == "PROSPER"); | ||
if (existing == null) { | ||
await cdf.Alpha.Simulators.CreateSimulatorIntegrationAsync( | ||
new List<SimulatorIntegrationCreate> | ||
{ | ||
new SimulatorIntegrationCreate | ||
{ | ||
ExternalId = connectorName, | ||
SimulatorExternalId = "PROSPER", | ||
DataSetId = CdfTestClient.TestDataset, | ||
Heartbeat = DateTime.UtcNow.ToUnixTimeMilliseconds(), | ||
ConnectorVersion = "N/A", | ||
SimulatorVersion = "N/A", | ||
RunApiEnabled = true, | ||
} | ||
} | ||
).ConfigureAwait(false); | ||
} else { | ||
await cdf.Alpha.Simulators.UpdateSimulatorIntegrationAsync( | ||
new List<SimulatorIntegrationUpdateItem> | ||
{ | ||
new SimulatorIntegrationUpdateItem(existing.Id) | ||
{ | ||
Update = new SimulatorIntegrationUpdate | ||
{ | ||
Heartbeat = new Update<long>(DateTime.UtcNow.ToUnixTimeMilliseconds()) | ||
} | ||
} | ||
} | ||
).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.