Skip to content

Commit

Permalink
Rename ContentItemVariant to LanguageVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
gormal committed Sep 24, 2021
1 parent 4f60406 commit ac62e4f
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 199 deletions.
12 changes: 6 additions & 6 deletions Kentico.Kontent.Management.Tests/EndpointUrlBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void BuildContentItemVariantsUrl_ItemIdVariantId_ReturnsCorrectUrl()
{
var itemIdentifier = Reference.ById(ITEM_ID);
var variantIdentifier = Reference.ById(VARIANT_ID);
var identifier = new ContentItemVariantIdentifier(itemIdentifier, variantIdentifier);
var identifier = new LanguageVariantIdentifier(itemIdentifier, variantIdentifier);
var actualUrl = _builder.BuildVariantsUrl(identifier);
var expectedUrl = $"{ENDPOINT}/projects/{PROJECT_ID}/items/{ITEM_ID}/variants/{VARIANT_ID}";

Expand All @@ -78,7 +78,7 @@ public void BuildContentItemVariantsUrl_ItemIdVariantCodename_ReturnsCorrectUrl(
{
var itemIdentifier = Reference.ById(ITEM_ID);
var variantIdentifier = Reference.ByCodename(VARIANT_CODENAME);
var identifier = new ContentItemVariantIdentifier(itemIdentifier, variantIdentifier);
var identifier = new LanguageVariantIdentifier(itemIdentifier, variantIdentifier);
var actualUrl = _builder.BuildVariantsUrl(identifier);
var expectedUrl = $"{ENDPOINT}/projects/{PROJECT_ID}/items/{ITEM_ID}/variants/codename/{VARIANT_CODENAME}";

Expand All @@ -90,7 +90,7 @@ public void BuildContentItemVariantsUrl_ItemCodenameVariantId_ReturnsCorrectUrl(
{
var itemIdentifier = Reference.ByCodename(ITEM_CODENAME);
var variantIdentifier = Reference.ById(VARIANT_ID);
var identifier = new ContentItemVariantIdentifier(itemIdentifier, variantIdentifier);
var identifier = new LanguageVariantIdentifier(itemIdentifier, variantIdentifier);
var actualUrl = _builder.BuildVariantsUrl(identifier);
var expectedUrl = $"{ENDPOINT}/projects/{PROJECT_ID}/items/codename/{ITEM_CODENAME}/variants/{VARIANT_ID}";

Expand All @@ -102,7 +102,7 @@ public void BuildContentItemVariantsUrl_ItemCodenameVariantCodename_ReturnsCorre
{
var itemIdentifier = Reference.ByCodename(ITEM_CODENAME);
var variantIdentifier = Reference.ByCodename(VARIANT_CODENAME);
var identifier = new ContentItemVariantIdentifier(itemIdentifier, variantIdentifier);
var identifier = new LanguageVariantIdentifier(itemIdentifier, variantIdentifier);
var actualUrl = _builder.BuildVariantsUrl(identifier);
var expectedUrl = $"{ENDPOINT}/projects/{PROJECT_ID}/items/codename/{ITEM_CODENAME}/variants/codename/{VARIANT_CODENAME}";

Expand All @@ -114,7 +114,7 @@ public void BuildContentItemVariantsUrl_ItemExternalIdVariantId_ReturnsCorrectUr
{
var itemIdentifier = Reference.ByExternalId(ITEM_EXTERNAL_ID);
var variantIdentifier = Reference.ById(VARIANT_ID);
var identifier = new ContentItemVariantIdentifier(itemIdentifier, variantIdentifier);
var identifier = new LanguageVariantIdentifier(itemIdentifier, variantIdentifier);
var actualUrl = _builder.BuildVariantsUrl(identifier);
var expectedUrl = $"{ENDPOINT}/projects/{PROJECT_ID}/items/external-id/{EXPECTED_ITEM_EXTERNAL_ID}/variants/{VARIANT_ID}";

Expand All @@ -126,7 +126,7 @@ public void BuildContentItemVariantsUrl_ItemExternalIdVariantCodename_ReturnsCor
{
var itemIdentifier = Reference.ByExternalId(ITEM_EXTERNAL_ID);
var variantIdentifier = Reference.ByCodename(VARIANT_CODENAME);
var identifier = new ContentItemVariantIdentifier(itemIdentifier, variantIdentifier);
var identifier = new LanguageVariantIdentifier(itemIdentifier, variantIdentifier);
var actualUrl = _builder.BuildVariantsUrl(identifier);
var expectedUrl = $"{ENDPOINT}/projects/{PROJECT_ID}/items/external-id/{EXPECTED_ITEM_EXTERNAL_ID}/variants/codename/{VARIANT_CODENAME}";

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ public async void ChangeWorkflowStepOfVariant_ChangesWorkflowStepOfVariant()
// Test
var itemIdentifier = Reference.ByExternalId(externalId);
var languageIdentifier = Reference.ByCodename(EXISTING_LANGUAGE_CODENAME);
var variantIdentifier = new ContentItemVariantIdentifier(itemIdentifier, languageIdentifier);
var variantIdentifier = new LanguageVariantIdentifier(itemIdentifier, languageIdentifier);

var identifier = new WorkflowIdentifier(itemIdentifier, languageIdentifier, Reference.ByCodename("test"));

await _client.ChangeWorkflowStep(identifier);

var updatedVariant = await _client.GetContentItemVariantAsync(variantIdentifier);
var updatedVariant = await _client.GetLanguageVariantAsync(variantIdentifier);
_ = await _client.ListWorkflowStepsAsync();

Assert.Equal(CUSTOM_WORKFLOW_STEP_ID, updatedVariant.WorkflowStep.Id);
Expand All @@ -75,11 +75,11 @@ public async void PublishVariant_PublishesVariant()
// Test
var itemIdentifier = Reference.ByExternalId(externalId);
var languageIdentifier = Reference.ByCodename(EXISTING_LANGUAGE_CODENAME);
var variantIdentifier = new ContentItemVariantIdentifier(itemIdentifier, languageIdentifier);
var variantIdentifier = new LanguageVariantIdentifier(itemIdentifier, languageIdentifier);

await _client.PublishContentItemVariant(variantIdentifier);
await _client.PublishLanguageVariant(variantIdentifier);

var updatedVariant = await _client.GetContentItemVariantAsync(variantIdentifier);
var updatedVariant = await _client.GetLanguageVariantAsync(variantIdentifier);

Assert.Equal(PUBLISHED_WORKFLOW_STEP_ID, updatedVariant.WorkflowStep.Id);

Expand All @@ -99,13 +99,13 @@ public async void UnpublishVariant_UnpublishesVariant()
// Test
var itemIdentifier = Reference.ByExternalId(externalId);
var languageIdentifier = Reference.ByCodename(EXISTING_LANGUAGE_CODENAME);
var variantIdentifier = new ContentItemVariantIdentifier(itemIdentifier, languageIdentifier);
var variantIdentifier = new LanguageVariantIdentifier(itemIdentifier, languageIdentifier);

await _client.PublishContentItemVariant(variantIdentifier);
await _client.PublishLanguageVariant(variantIdentifier);

await _client.UnpublishContentItemVariant(variantIdentifier);
await _client.UnpublishLangaugeVariant(variantIdentifier);

var updatedVariant = await _client.GetContentItemVariantAsync(variantIdentifier);
var updatedVariant = await _client.GetLanguageVariantAsync(variantIdentifier);

Assert.Equal(ARCHIVED_WORKFLOW_STEP_ID, updatedVariant.WorkflowStep.Id);

Expand All @@ -125,12 +125,12 @@ public async void CreateNewVersionsOfVariant_CreatesNewVersionsOfVariant()
// Test
var itemIdentifier = Reference.ByExternalId(externalId);
var languageIdentifier = Reference.ByCodename(EXISTING_LANGUAGE_CODENAME);
var variantIdentifier = new ContentItemVariantIdentifier(itemIdentifier, languageIdentifier);
var variantIdentifier = new LanguageVariantIdentifier(itemIdentifier, languageIdentifier);

await _client.PublishContentItemVariant(variantIdentifier);
await _client.CreateNewVersionOfContentItemVariant(variantIdentifier);
await _client.PublishLanguageVariant(variantIdentifier);
await _client.CreateNewVersionOfLanguageVariant(variantIdentifier);

var updatedVariant = await _client.GetContentItemVariantAsync(variantIdentifier);
var updatedVariant = await _client.GetLanguageVariantAsync(variantIdentifier);

Assert.Equal(DRAFT_WORKFLOW_STEP_ID, updatedVariant.WorkflowStep.Id);

Expand All @@ -150,11 +150,11 @@ public async void SchedulePublishingOfVariant_SchedulesPublishingOfVariant()
// Test
var itemIdentifier = Reference.ByExternalId(externalId);
var languageIdentifier = Reference.ByCodename(EXISTING_LANGUAGE_CODENAME);
var variantIdentifier = new ContentItemVariantIdentifier(itemIdentifier, languageIdentifier);
var variantIdentifier = new LanguageVariantIdentifier(itemIdentifier, languageIdentifier);

await _client.SchedulePublishingOfContentItemVariant(variantIdentifier, new ScheduleModel { ScheduleTo = new DateTimeOffset(2050, 1, 1, 10, 10, 0, TimeSpan.FromHours(2)) });
await _client.SchedulePublishingOfLangaugeVariant(variantIdentifier, new ScheduleModel { ScheduleTo = new DateTimeOffset(2050, 1, 1, 10, 10, 0, TimeSpan.FromHours(2)) });

var updatedVariant = await _client.GetContentItemVariantAsync(variantIdentifier);
var updatedVariant = await _client.GetLanguageVariantAsync(variantIdentifier);

Assert.Equal(SCHEDULED_WORKFLOW_STEP_ID, updatedVariant.WorkflowStep.Id);

Expand All @@ -174,18 +174,18 @@ public async void ScheduleUnpublishingOfVariant_SchedulesUnpublishingOfVariant()
// Test
var itemIdentifier = Reference.ByExternalId(externalId);
var languageIdentifier = Reference.ByCodename(EXISTING_LANGUAGE_CODENAME);
var variantIdentifier = new ContentItemVariantIdentifier(itemIdentifier, languageIdentifier);
var variantIdentifier = new LanguageVariantIdentifier(itemIdentifier, languageIdentifier);

await _client.PublishContentItemVariant(variantIdentifier);
await _client.PublishLanguageVariant(variantIdentifier);

await _client.ScheduleUnpublishingOfContentItemVariant(variantIdentifier, new ScheduleModel { ScheduleTo = new DateTimeOffset(2050, 1, 1, 10, 10, 0, TimeSpan.FromHours(2)) });
await _client.ScheduleUnpublishingOfLanguageVariant(variantIdentifier, new ScheduleModel { ScheduleTo = new DateTimeOffset(2050, 1, 1, 10, 10, 0, TimeSpan.FromHours(2)) });

var updatedVariant = await _client.GetContentItemVariantAsync(variantIdentifier);
var updatedVariant = await _client.GetLanguageVariantAsync(variantIdentifier);

Assert.Equal(PUBLISHED_WORKFLOW_STEP_ID, updatedVariant.WorkflowStep.Id);

// Cleanup
await _client.UnpublishContentItemVariant(variantIdentifier);
await _client.UnpublishLangaugeVariant(variantIdentifier);
var itemToClean = Reference.ByExternalId(externalId);
await _client.DeleteContentItemAsync(itemToClean);
}
Expand All @@ -201,12 +201,12 @@ public async void CancelPublishingOfVariant_CancelsPublishingOfVariant()
// Test
var itemIdentifier = Reference.ByExternalId(externalId);
var languageIdentifier = Reference.ByCodename(EXISTING_LANGUAGE_CODENAME);
var variantIdentifier = new ContentItemVariantIdentifier(itemIdentifier, languageIdentifier);
var variantIdentifier = new LanguageVariantIdentifier(itemIdentifier, languageIdentifier);

await _client.SchedulePublishingOfContentItemVariant(variantIdentifier, new ScheduleModel { ScheduleTo = new DateTimeOffset(2050, 1, 1, 10, 10, 0, TimeSpan.FromHours(2)) });
await _client.CancelPublishingOfContentItemVariant(variantIdentifier);
await _client.SchedulePublishingOfLangaugeVariant(variantIdentifier, new ScheduleModel { ScheduleTo = new DateTimeOffset(2050, 1, 1, 10, 10, 0, TimeSpan.FromHours(2)) });
await _client.CancelPublishingOfLanguageVariant(variantIdentifier);

var updatedVariant = await _client.GetContentItemVariantAsync(variantIdentifier);
var updatedVariant = await _client.GetLanguageVariantAsync(variantIdentifier);

Assert.Equal(DRAFT_WORKFLOW_STEP_ID, updatedVariant.WorkflowStep.Id);

Expand All @@ -226,13 +226,13 @@ public async void CancelUnpublishingOfVariant_CancelsUnpublishingOfVariant()
// Test
var itemIdentifier = Reference.ByExternalId(externalId);
var languageIdentifier = Reference.ByCodename(EXISTING_LANGUAGE_CODENAME);
var variantIdentifier = new ContentItemVariantIdentifier(itemIdentifier, languageIdentifier);
var variantIdentifier = new LanguageVariantIdentifier(itemIdentifier, languageIdentifier);

await _client.PublishContentItemVariant(variantIdentifier);
await _client.ScheduleUnpublishingOfContentItemVariant(variantIdentifier, new ScheduleModel { ScheduleTo = new DateTimeOffset(2050,1,1,10,10,0, TimeSpan.FromHours(2)) });
await _client.CancelUnpublishingOfContentItemVariant(variantIdentifier);
await _client.PublishLanguageVariant(variantIdentifier);
await _client.ScheduleUnpublishingOfLanguageVariant(variantIdentifier, new ScheduleModel { ScheduleTo = new DateTimeOffset(2050,1,1,10,10,0, TimeSpan.FromHours(2)) });
await _client.CancelUnpublishingOfLanguageVariant(variantIdentifier);

var updatedVariant = await _client.GetContentItemVariantAsync(variantIdentifier);
var updatedVariant = await _client.GetLanguageVariantAsync(variantIdentifier);

Assert.Equal(PUBLISHED_WORKFLOW_STEP_ID, updatedVariant.WorkflowStep.Id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public ModelProviderTests()
public void GetContentItemVariantModel_ReturnsExpected()
{
var expected = GetTestModel();
var model = new ContentItemVariantModel
var model = new LanguageVariantModel
{
Elements = PrepareMockDynamicResponse(expected)
};
var actual = _modelProvider.GetContentItemVariantModel<ComplexTestModel>(model).Elements;
var actual = _modelProvider.GetLanguageVariantModel<ComplexTestModel>(model).Elements;

Assert.Equal(expected.Title.Value, actual.Title.Value);
Assert.Equal(expected.Rating.Value, actual.Rating.Value);
Expand All @@ -55,7 +55,7 @@ public void GetContentItemVariantUpsertModel_ReturnsExpected()
var model = GetTestModel();
var type = model.GetType();

var upsertVariantElements = _modelProvider.GetContentItemVariantUpsertModel(model).Elements;
var upsertVariantElements = _modelProvider.GetLanguageVariantUpsertModel(model).Elements;

var titleValue = upsertVariantElements.SingleOrDefault(elementObject =>
elementObject.element.id == type.GetProperty(nameof(model.Title))?.GetKontentElementId()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task ActionInvokerSerializeElementContainingZero_SerializedJsonCont
var httpClient = new FakeManagementHttpClient();
var actionInvoker = new ActionInvoker(httpClient, new MessageCreator("{api_key}"));

var contentItemVariantUpsertModel = new ContentItemVariantUpsertModel()
var contentItemVariantUpsertModel = new LanguageVariantUpsertModel()
{
Elements = new List<dynamic>
{
Expand All @@ -53,7 +53,7 @@ public async Task ActionInvokerSerializeElementContainingZero_SerializedJsonCont
},
};

await actionInvoker.InvokeMethodAsync<ContentItemVariantUpsertModel, dynamic>("{endpoint_url}", HttpMethod.Get, contentItemVariantUpsertModel);
await actionInvoker.InvokeMethodAsync<LanguageVariantUpsertModel, dynamic>("{endpoint_url}", HttpMethod.Get, contentItemVariantUpsertModel);
Assert.Equal($"{{\"elements\":[{{\"zero\":{s},\"optZero\":{s}}}]}}", httpClient.requestBody);
}

Expand Down
8 changes: 4 additions & 4 deletions Kentico.Kontent.Management.Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ internal static async Task<ContentItemModel> PrepareTestItem(ManagementClient cl
}
}

internal static async Task<ContentItemVariantModel> PrepareTestVariant(ManagementClient client, string languageCodename, IEnumerable<dynamic> elements, ContentItemModel item)
internal static async Task<LanguageVariantModel> PrepareTestVariant(ManagementClient client, string languageCodename, IEnumerable<dynamic> elements, ContentItemModel item)
{
var addedItemIdentifier = Reference.ByCodename(item.Codename);
var addedLanguageIdentifier = Reference.ByCodename(languageCodename);
var addedContentItemLanguageIdentifier = new ContentItemVariantIdentifier(addedItemIdentifier, addedLanguageIdentifier);
var variantUpdateModel = new ContentItemVariantUpsertModel() { Elements = elements };
var addedContentItemLanguageIdentifier = new LanguageVariantIdentifier(addedItemIdentifier, addedLanguageIdentifier);
var variantUpdateModel = new LanguageVariantUpsertModel() { Elements = elements };

return await client.UpsertContentItemVariantAsync(addedContentItemLanguageIdentifier, variantUpdateModel);
return await client.UpsertLanguageVariantAsync(addedContentItemLanguageIdentifier, variantUpdateModel);
}
}
}
Loading

0 comments on commit ac62e4f

Please sign in to comment.