Skip to content

Commit

Permalink
Fix reclassify (#37810)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamzhao87 authored Jul 24, 2023
1 parent 434b76d commit db809d6
Show file tree
Hide file tree
Showing 5 changed files with 548 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ public virtual async Task<Response> ReclassifyJobAsync(
{
var response = await RestClient.ReclassifyJobActionAsync(
id: jobId,
new ReclassifyJobRequest(),
cancellationToken: cancellationToken).ConfigureAwait(false);
return response.GetRawResponse();
}
Expand Down Expand Up @@ -579,6 +580,7 @@ public virtual Response ReclassifyJob(
{
var response = RestClient.ReclassifyJobAction(
id: jobId,
new ReclassifyJobRequest(),
cancellationToken: cancellationToken);
return response.GetRawResponse();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using Azure.Core;

namespace Azure.Communication.JobRouter
{
/// <summary>
/// An assignment of a worker to a queue.
/// </summary>
internal class ReclassifyJobRequest : IUtf8JsonSerializable
{
/// <summary>
/// Write empty object.
/// </summary>
/// <param name="writer"></param>
void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
writer.WriteEndObject();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,39 @@ public async Task CreateJobWithScheduleAndSuspendMode()
Assert.IsNull(createJob1.MatchingMode.QueueAndMatchMode);
}

[Test]
public async Task ReclassifyJob()
{
JobRouterClient routerClient = CreateRouterClientWithConnectionString();
JobRouterAdministrationClient routerAdminClient = CreateRouterAdministrationClientWithConnectionString();
var channelId = GenerateUniqueId($"{nameof(ReclassifyJob)}-Channel");

// Setup queue
var createQueueResponse = await CreateQueueAsync(nameof(ReclassifyJob));
var createQueue = createQueueResponse.Value;

var classificationPolicy = await routerAdminClient.CreateClassificationPolicyAsync(
new CreateClassificationPolicyOptions(GenerateUniqueId($"{IdPrefix}{nameof(ReclassifyJob)}-policy"))
{
PrioritizationRule = new StaticRouterRule(new LabelValue(1))
});
AddForCleanup(new Task(async () => await routerAdminClient.DeleteClassificationPolicyAsync(classificationPolicy.Value.Id)));

// Create 1 job
var jobId1 = GenerateUniqueId($"{IdPrefix}{nameof(ReclassifyJob)}-job");
var createJob1Response = await routerClient.CreateJobWithClassificationPolicyAsync(
new CreateJobWithClassificationPolicyOptions(jobId1, channelId, classificationPolicy.Value.Id)
{
QueueId = createQueue.Id
});
var createJob1 = createJob1Response.Value;
AddForCleanup(new Task(async () => await routerClient.DeleteJobAsync(createJob1.Id)));

await routerClient.ReclassifyJobAsync(jobId1);

Assert.AreEqual(createJob1.QueueId, createQueue.Id);
}

#endregion Job Tests

}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit db809d6

Please sign in to comment.