Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

Commit

Permalink
Merge pull request #46 from docascode/sdp
Browse files Browse the repository at this point in the history
refine test cases and expected results
  • Loading branch information
anmeng10101 authored Sep 1, 2020
2 parents b596e8d + f7d4ce5 commit 3f98e48
Show file tree
Hide file tree
Showing 133 changed files with 2,926 additions and 4,506 deletions.
12 changes: 5 additions & 7 deletions src/test/java/com/microsoft/build/YmlFilesBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
import static org.mockito.Mockito.when;

import com.google.testing.compile.CompilationRule;
import com.microsoft.model.MetadataFile;
import com.microsoft.model.MetadataFileItem;
import com.microsoft.model.MethodParameter;
import com.microsoft.model.Syntax;
import com.microsoft.model.*;
import com.sun.source.util.DocTrees;

import java.io.File;
Expand Down Expand Up @@ -57,8 +54,9 @@ public void addConstructorsInfoWhenOnlyDefaultConstructor() {
MetadataFile container = new MetadataFile("output", "name");
when(environment.getElementUtils()).thenReturn(elements);
when(environment.getDocTrees()).thenReturn(docTrees);
TocItem toc = new TocItem("com.microsoft.samples.subpackage.Person", "com.microsoft.samples.subpackage.Person");

ymlFilesBuilder.addConstructorsInfo(element, container);
ymlFilesBuilder.addConstructorsInfo(element, container, toc);

assertThat("Wrong file name", container.getFileNameWithPath(), is("output" + File.separator + "name"));
assertThat("Container should contain constructor item", container.getItems().size(), is(1));
Expand All @@ -70,8 +68,8 @@ public void addConstructorsInfo() {
MetadataFile container = new MetadataFile("output", "name");
when(environment.getElementUtils()).thenReturn(elements);
when(environment.getDocTrees()).thenReturn(docTrees);

ymlFilesBuilder.addConstructorsInfo(element, container);
TocItem toc = new TocItem("com.microsoft.samples.SuperHero", "com.microsoft.samples.SuperHero");
ymlFilesBuilder.addConstructorsInfo(element, container, toc);

assertThat("Wrong file name", container.getFileNameWithPath(), is("output" + File.separator + "name"));
Collection<MetadataFileItem> constructorItems = container.getItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ public ResourceCollection<AgreementMetaData> get()
{
return null;
}

public ResourceCollection<AgreementMetaData> get(String id)
{
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ public interface IAgreementDetailsCollection
* @return The current agreement metadata.
*/
ResourceCollection<AgreementMetaData> get();

ResourceCollection<AgreementMetaData> get(String id);
}
18 changes: 18 additions & 0 deletions src/test/java/com/microsoft/samples/subpackage/HttpStatusCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.microsoft.samples.subpackage;

public class HttpStatusCode
{
public static final int BADREQUEST = 400;

public static final int UNAUTHORIZED = 401;

public static final int FORBIDDEN = 403;

public static final int NOTFOUND = 404;

public static final int CONFLICT = 409;

public static final int SERVICEUNAVAILABLE = 503;

public static final int EXPECTATIONFAILED = 417;
}
6 changes: 3 additions & 3 deletions src/test/java/com/microsoft/util/ElementUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void extractSortedElements() {
.stream().map(String::valueOf).collect(Collectors.toList());

// Ensure items to exclude exist.
assertThat("Wrong enclosed elements number", allElements.size(), is(6));
assertThat("Wrong enclosed elements number", allElements.size(), is(7));
assertThat("Unexpected package private class", allElements.contains("com.microsoft.samples.subpackage.InternalException"), is(true));
assertThat("Unexpected to-exclude class", allElements.contains("com.microsoft.samples.subpackage.SomeExcludedClass"), is(true));

Expand All @@ -68,10 +68,10 @@ public void extractSortedElements() {
.stream().map(String::valueOf).collect(Collectors.toList());

// Verify filtered and sorted result
assertThat("Wrong result list size", extractedElements.size(), is(4));
assertThat("Wrong result list size", extractedElements.size(), is(5));
assertThat("Unexpected first item in the result list after invoke method extractSortedElements()", extractedElements.get(0), is("com.microsoft.samples.subpackage.CustomException"));
assertThat("Unexpected second item in the result list after invoke method extractSortedElements()", extractedElements.get(1), is("com.microsoft.samples.subpackage.Display"));
assertThat("Unexpected third item in the result list after invoke method extractSortedElements()", extractedElements.get(2), is("com.microsoft.samples.subpackage.Person"));
assertThat("Unexpected third item in the result list after invoke method extractSortedElements()", extractedElements.get(2), is("com.microsoft.samples.subpackage.HttpStatusCode"));
}

@Test
Expand Down
36 changes: 19 additions & 17 deletions src/test/java/com/microsoft/util/YamlUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,31 @@ public class YamlUtilTest {
@Test
public void objectToYamlString() {
MetadataFile metadataFile = new MetadataFile("", "SomeFileName");
metadataFile.getItems().add(buildMetadataFileItem(3));
metadataFile.getReferences().add(buildMetadataFileItem(5));
metadataFile.getItems().add(buildMetadataFileItem(3, "method"));
metadataFile.getReferences().add(buildMetadataFileItem(5, ""));

String result = YamlUtil.objectToYamlString(metadataFile);
String result = YamlUtil.objectToYamlString(metadataFile, "SomeFileName");

assertThat("Wrong result", result, is(""
+ "items:\n"
+ "- uid: \"Some uid 3\"\n"
+ " id: \"Some id3\"\n"
+ " href: \"Some href3\"\n"
+ "- uid: Some uid 3\n"
+ " id: Some id3\n"
+ " href: Some href3\n"
+ " type: method\n"
+ " syntax:\n"
+ " parameters:\n"
+ " - id: \"Some id 3\"\n"
+ " type: \"Some type 3\"\n"
+ " description: \"Some desc 3\"\n"
+ " - description: Some desc 3\n"
+ " name: Some name 3\n"
+ " type: <xref href=\"Some type 3?alt=Some type 3&text=Some type 3\" data-throw-if-not-resolved=\"False\" />\n"
+ "references:\n"
+ "- uid: \"Some uid 5\"\n"
+ " id: \"Some id5\"\n"
+ " href: \"Some href5\"\n"
+ "- uid: Some uid 5\n"
+ " id: Some id5\n"
+ " href: Some href5\n"
+ " syntax:\n"
+ " parameters:\n"
+ " - id: \"Some id 5\"\n"
+ " type: \"Some type 5\"\n"
+ " description: \"Some desc 5\"\n"));
+ " - description: Some desc 5\n"
+ " name: Some name 5\n"
+ " type: <xref href=\"Some type 5?alt=Some type 5&text=Some type 5\" data-throw-if-not-resolved=\"False\" />\n"));
}

@Test
Expand All @@ -61,12 +62,13 @@ public void convertHtmlToMarkdownForBlankParam() {
assertThat("Wrong result for empty string", YamlUtil.convertHtmlToMarkdown(""), is(""));
}

private MetadataFileItem buildMetadataFileItem(int seed) {
private MetadataFileItem buildMetadataFileItem(int seed, String type) {
MetadataFileItem metadataFileItem = new MetadataFileItem("Some uid " + seed);
metadataFileItem.setId("Some id" + seed);
metadataFileItem.setHref("Some href" + seed);
metadataFileItem.setType(type);
metadataFileItem.setParameters(Collections.singletonList(
new MethodParameter("Some id " + seed, "Some type " + seed, "Some desc " + seed)));
new MethodParameter("Some name " + seed, "Some type " + seed, "Some desc " + seed)));

return metadataFileItem;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### YamlMime:JavaMember
uid: com.microsoft.samples.BasePartnerComponent.BasePartnerComponent*
fullName: com.microsoft.samples.BasePartnerComponent<TContext>.BasePartnerComponent
name: BasePartnerComponent
nameWithType: BasePartnerComponent<TContext>.BasePartnerComponent
members:
- uid: com.microsoft.samples.BasePartnerComponent.BasePartnerComponent(com.microsoft.samples.IPartner,TContext)
fullName: com.microsoft.samples.BasePartnerComponent<TContext>.BasePartnerComponent(IPartner rootPartnerOperations, TContext componentContext)
name: BasePartnerComponent(IPartner rootPartnerOperations, TContext componentContext)
nameWithType: BasePartnerComponent<TContext>.BasePartnerComponent(IPartner rootPartnerOperations, TContext componentContext)
summary: Initializes a new instance of the BasePartnerComponent class.
parameters:
- description: The root partner operations that created this component.
name: rootPartnerOperations
type: <xref href="com.microsoft.samples.IPartner?alt=com.microsoft.samples.IPartner&text=IPartner" data-throw-if-not-resolved="False" />
- description: A component context object to work with.
name: componentContext
type: <xref href="TContext?alt=TContext&text=TContext" data-throw-if-not-resolved="False" />
syntax: protected BasePartnerComponent(IPartner rootPartnerOperations, TContext componentContext)
type: constructor
metadata: {}
package: com.microsoft.samples
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### YamlMime:JavaMember
uid: com.microsoft.samples.BasePartnerComponent.testBase*
fullName: com.microsoft.samples.BasePartnerComponent<TContext>.testBase
name: testBase
nameWithType: BasePartnerComponent<TContext>.testBase
members:
- uid: com.microsoft.samples.BasePartnerComponent.testBase()
fullName: com.microsoft.samples.BasePartnerComponent<TContext>.testBase()
name: testBase()
nameWithType: BasePartnerComponent<TContext>.testBase()
syntax: protected void testBase()
type: method
metadata: {}
package: com.microsoft.samples
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### YamlMime:JavaMember
uid: com.microsoft.samples.BasePartnerComponent.testInherited*
fullName: com.microsoft.samples.BasePartnerComponent<TContext>.testInherited
name: testInherited
nameWithType: BasePartnerComponent<TContext>.testInherited
members:
- uid: com.microsoft.samples.BasePartnerComponent.testInherited()
fullName: com.microsoft.samples.BasePartnerComponent<TContext>.testInherited()
name: testInherited()
nameWithType: BasePartnerComponent<TContext>.testInherited()
syntax: protected void testInherited()
type: method
metadata: {}
package: com.microsoft.samples
Original file line number Diff line number Diff line change
@@ -1,151 +1,31 @@
### YamlMime:ManagedReference
items:
- uid: "com.microsoft.samples.BasePartnerComponent"
id: "BasePartnerComponent"
parent: "com.microsoft.samples"
children:
- "com.microsoft.samples.BasePartnerComponent.BasePartnerComponent(com.microsoft.samples.IPartner,TContext)"
- "com.microsoft.samples.BasePartnerComponent.testBase()"
- "com.microsoft.samples.BasePartnerComponent.testInherited()"
langs:
- "java"
name: "BasePartnerComponent<TContext>"
nameWithType: "BasePartnerComponent<TContext>"
fullName: "com.microsoft.samples.BasePartnerComponent<TContext>"
type: "Class"
package: "com.microsoft.samples"
summary: "Holds common partner component properties and behavior. All components should inherit from this class. The context object type."
syntax:
content: "public abstract class BasePartnerComponent<TContext>"
typeParameters:
- id: "TContext"
inheritance:
- "java.lang.Object"
inheritedMembers:
- "java.lang.Object.clone()"
- "java.lang.Object.equals(java.lang.Object)"
- "java.lang.Object.finalize()"
- "java.lang.Object.getClass()"
- "java.lang.Object.hashCode()"
- "java.lang.Object.notify()"
- "java.lang.Object.notifyAll()"
- "java.lang.Object.toString()"
- "java.lang.Object.wait()"
- "java.lang.Object.wait(long)"
- "java.lang.Object.wait(long,int)"
- uid: "com.microsoft.samples.BasePartnerComponent.BasePartnerComponent(com.microsoft.samples.IPartner,TContext)"
id: "BasePartnerComponent(com.microsoft.samples.IPartner,TContext)"
parent: "com.microsoft.samples.BasePartnerComponent"
langs:
- "java"
name: "BasePartnerComponent(IPartner rootPartnerOperations, TContext componentContext)"
nameWithType: "BasePartnerComponent<TContext>.BasePartnerComponent(IPartner rootPartnerOperations, TContext componentContext)"
fullName: "com.microsoft.samples.BasePartnerComponent<TContext>.BasePartnerComponent(IPartner rootPartnerOperations, TContext componentContext)"
overload: "com.microsoft.samples.BasePartnerComponent.BasePartnerComponent*"
type: "Constructor"
package: "com.microsoft.samples"
summary: "Initializes a new instance of the BasePartnerComponent class."
syntax:
content: "protected BasePartnerComponent(IPartner rootPartnerOperations, TContext componentContext)"
parameters:
- id: "rootPartnerOperations"
type: "com.microsoft.samples.IPartner"
description: "The root partner operations that created this component."
- id: "componentContext"
type: "TContext"
description: "A component context object to work with."
- uid: "com.microsoft.samples.BasePartnerComponent.testBase()"
id: "testBase()"
parent: "com.microsoft.samples.BasePartnerComponent"
langs:
- "java"
name: "testBase()"
nameWithType: "BasePartnerComponent<TContext>.testBase()"
fullName: "com.microsoft.samples.BasePartnerComponent<TContext>.testBase()"
overload: "com.microsoft.samples.BasePartnerComponent.testBase*"
type: "Method"
package: "com.microsoft.samples"
syntax:
content: "protected void testBase()"
- uid: "com.microsoft.samples.BasePartnerComponent.testInherited()"
id: "testInherited()"
parent: "com.microsoft.samples.BasePartnerComponent"
langs:
- "java"
name: "testInherited()"
nameWithType: "BasePartnerComponent<TContext>.testInherited()"
fullName: "com.microsoft.samples.BasePartnerComponent<TContext>.testInherited()"
overload: "com.microsoft.samples.BasePartnerComponent.testInherited*"
type: "Method"
package: "com.microsoft.samples"
syntax:
content: "protected void testInherited()"
references:
- uid: "com.microsoft.samples.IPartner"
name: "IPartner"
nameWithType: "IPartner"
fullName: "com.microsoft.samples.IPartner"
- uid: "TContext"
spec.java:
- uid: "TContext"
name: "TContext"
fullName: "TContext"
- uid: "com.microsoft.samples.BasePartnerComponent.BasePartnerComponent*"
name: "BasePartnerComponent"
nameWithType: "BasePartnerComponent<TContext>.BasePartnerComponent"
fullName: "com.microsoft.samples.BasePartnerComponent<TContext>.BasePartnerComponent"
package: "com.microsoft.samples"
- uid: "com.microsoft.samples.BasePartnerComponent.testBase*"
name: "testBase"
nameWithType: "BasePartnerComponent<TContext>.testBase"
fullName: "com.microsoft.samples.BasePartnerComponent<TContext>.testBase"
package: "com.microsoft.samples"
- uid: "com.microsoft.samples.BasePartnerComponent.testInherited*"
name: "testInherited"
nameWithType: "BasePartnerComponent<TContext>.testInherited"
fullName: "com.microsoft.samples.BasePartnerComponent<TContext>.testInherited"
package: "com.microsoft.samples"
- uid: "java.lang.Object.notify()"
name: "Object.notify()"
nameWithType: "Object.notify()"
fullName: "java.lang.Object.notify()"
- uid: "java.lang.Object.wait()"
name: "Object.wait()"
nameWithType: "Object.wait()"
fullName: "java.lang.Object.wait()"
- uid: "java.lang.Object.finalize()"
name: "Object.finalize()"
nameWithType: "Object.finalize()"
fullName: "java.lang.Object.finalize()"
- uid: "java.lang.Object.clone()"
name: "Object.clone()"
nameWithType: "Object.clone()"
fullName: "java.lang.Object.clone()"
- uid: "java.lang.Object.notifyAll()"
name: "Object.notifyAll()"
nameWithType: "Object.notifyAll()"
fullName: "java.lang.Object.notifyAll()"
- uid: "java.lang.Object.equals(java.lang.Object)"
name: "Object.equals(Object)"
nameWithType: "Object.equals(Object)"
fullName: "java.lang.Object.equals(java.lang.Object)"
- uid: "java.lang.Object.getClass()"
name: "Object.getClass()"
nameWithType: "Object.getClass()"
fullName: "java.lang.Object.getClass()"
- uid: "java.lang.Object.wait(long)"
name: "Object.wait(long)"
nameWithType: "Object.wait(long)"
fullName: "java.lang.Object.wait(long)"
- uid: "java.lang.Object.hashCode()"
name: "Object.hashCode()"
nameWithType: "Object.hashCode()"
fullName: "java.lang.Object.hashCode()"
- uid: "java.lang.Object.wait(long,int)"
name: "Object.wait(long,int)"
nameWithType: "Object.wait(long,int)"
fullName: "java.lang.Object.wait(long,int)"
- uid: "java.lang.Object.toString()"
name: "Object.toString()"
nameWithType: "Object.toString()"
fullName: "java.lang.Object.toString()"
### YamlMime:JavaType
uid: com.microsoft.samples.BasePartnerComponent
fullName: com.microsoft.samples.BasePartnerComponent<TContext>
name: BasePartnerComponent<TContext>
nameWithType: BasePartnerComponent<TContext>
summary: Holds common partner component properties and behavior. All components should inherit from this class. The context object type.
inheritances:
- <xref href="java.lang.Object" data-throw-if-not-resolved="False" />
inheritedMembers:
- java.lang.Object.clone()
- java.lang.Object.equals(java.lang.Object)
- java.lang.Object.finalize()
- java.lang.Object.getClass()
- java.lang.Object.hashCode()
- java.lang.Object.notify()
- java.lang.Object.notifyAll()
- java.lang.Object.toString()
- java.lang.Object.wait()
- java.lang.Object.wait(long)
- java.lang.Object.wait(long,int)
syntax: public abstract class BasePartnerComponent<TContext>
constructors:
- com.microsoft.samples.BasePartnerComponent.BasePartnerComponent(com.microsoft.samples.IPartner,TContext)
methods:
- com.microsoft.samples.BasePartnerComponent.testBase()
- com.microsoft.samples.BasePartnerComponent.testInherited()
type: class
typeParameters:
- name: TContext
metadata: {}
package: com.microsoft.samples
Loading

0 comments on commit 3f98e48

Please sign in to comment.