### Question:
ForceJPAClassRenderer implements AttributeRenderer { @Override public String toString(Object o) { return ""; }  @Override String toString(Object o); @Override String toString(Object o, String format);  }### Answer:
@Test public void testClassAnnotationFormat() { DescribeSObjectResult dsr = new DescribeSObjectResult(); dsr.setName("ns__Custom_Object__c"); ForceJPAClassRenderer renderer = new ForceJPAClassRenderer(); assertEquals(renderer.toString(dsr, "classAnnotation"), "@javax.annotation.Generated(value=\"com.force.sdk.codegen.ForceJPAClassGenerator\")\n" + "@Table(name=\"ns__Custom_Object__c\")\n" + "@Entity(name=\"NsCustomObject\")\n" + "@com.force.sdk.jpa.annotation.CustomObject(readOnlySchema=true)", "Unexpected result for DescribeSObjectResultRenderer classAnnotation format"); }
@Test public void testCaseClassAnnotationFormat() { DescribeSObjectResult dsr = new DescribeSObjectResult(); dsr.setName("Case"); ForceJPAClassRenderer renderer = new ForceJPAClassRenderer(); assertEquals(renderer.toString(dsr, "classAnnotation"), "@javax.annotation.Generated(value=\"com.force.sdk.codegen.ForceJPAClassGenerator\")\n" + "@Table(name=\"Case\")\n" + "@Entity(name=\"CaseEntity\")\n" + "@com.force.sdk.jpa.annotation.CustomObject(readOnlySchema=true)", "Unexpected result for DescribeSObjectResultRenderer classAnnotation format"); }
@Test(dataProvider = "classNameFormatProvider") public void testClassNameFormat(String objectName, String expectedRenderedString) { DescribeSObjectResult dsr = new DescribeSObjectResult(); dsr.setName(objectName); ForceJPAClassRenderer renderer = new ForceJPAClassRenderer(); assertEquals(renderer.toString(dsr, "className"), expectedRenderedString, "Unexpected result for DescribeSObjectResultRenderer className format"); }
@Test public void testSuperClassNameFormat() { DescribeSObjectResult dsr = new DescribeSObjectResult(); dsr.setCustom(true); ForceJPAClassRenderer renderer = new ForceJPAClassRenderer(); assertEquals(renderer.toString(dsr, "superClassName"), "com.force.sdk.jpa.model.BaseForceCustomObject", "Unexpected result for DescribeSObjectResultRenderer superClassName format for a custom object"); dsr.setCustom(false); assertEquals(renderer.toString(dsr, "superClassName"), "com.force.sdk.jpa.model.BaseForceObject", "Unexpected result for DescribeSObjectResultRenderer superClassName format for a standard object " + "with missing common fields"); Field idField = new Field(); idField.setName("Id"); idField.setType(FieldType.id); Field nameField = new Field(); nameField.setName("Name"); nameField.setType(FieldType.string); Field ownerField = new Field(); ownerField.setName("OwnerId"); ownerField.setType(FieldType.reference); ownerField.setReferenceTo(new String[] { "User" }); Field createdByIdField = new Field(); createdByIdField.setName("CreatedById"); createdByIdField.setType(FieldType.reference); createdByIdField.setReferenceTo(new String[] { "User" }); Field createdDateField = new Field(); createdDateField.setName("CreatedDate"); createdDateField.setType(FieldType.datetime); Field lastModifiedByIdField = new Field(); lastModifiedByIdField.setName("LastModifiedById"); lastModifiedByIdField.setType(FieldType.reference); lastModifiedByIdField.setReferenceTo(new String[] { "User" }); Field lastModifiedDateField = new Field(); lastModifiedDateField.setName("LastModifiedDate"); lastModifiedDateField.setType(FieldType.datetime); Field systemModstampField = new Field(); systemModstampField.setName("SystemModstamp"); systemModstampField.setType(FieldType.datetime); dsr.setFields(new Field[] { idField, nameField, ownerField, createdByIdField, createdDateField, lastModifiedByIdField, lastModifiedDateField, systemModstampField }); assertEquals(renderer.toString(dsr, "superClassName"), "com.force.sdk.jpa.model.BaseForceStandardObject", "Unexpected result for DescribeSObjectResultRenderer superClassName format for a standard object " + "with all common fields"); }