use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.
the class RESTURLsRelativeRESTURLsSpec method _moreComplexRelativeRESTURL.
/**
* Relative REST URLs start with `/`, and continue with a resource path
* @filter('''|.dataSourceAccessMethodUrlShouldBe.*)
*/
@Test
@Named("More complex relative REST URL")
@Order(2)
public void _moreComplexRelativeRESTURL() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("entity Person {}");
_builder.newLine();
_builder.append("datasource PersonDataSource {");
_builder.newLine();
_builder.append("\t");
_builder.append("baseUrl: http://localhost/persons");
_builder.newLine();
_builder.append("\t");
_builder.append("resource: Person");
_builder.newLine();
_builder.append("\t");
_builder.append("post(Person person) GET /boo/bar/baz/persons");
_builder.newLine();
_builder.append("}");
_builder.newLine();
this.dataSourceAccessMethodUrlShouldBe(_builder, "/boo/bar/baz/persons");
}
use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.
the class APIClientGeneratorEntityAPIClientAPIClientCodeSpec method _implementationFile.
/**
* @filter('''|.isGenerated.*)
*/
@Test
@Named("Implementation file")
@Order(2)
public void _implementationFile() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("#import \"PersonAPIClient.h\"");
_builder.newLine();
_builder.newLine();
_builder.append("static NSString *const kBaseUrl = @\"http://localhost:2403\";");
_builder.newLine();
_builder.newLine();
_builder.append("@implementation PersonAPIClient");
_builder.newLine();
_builder.newLine();
_builder.append("+ (PersonAPIClient *)sharedClient {");
_builder.newLine();
_builder.append("\t");
_builder.append("static dispatch_once_t onceToken;");
_builder.newLine();
_builder.append("\t");
_builder.append("static PersonAPIClient *defaultInstance = nil;");
_builder.newLine();
_builder.append("\t");
_builder.append("dispatch_once(&onceToken, ^{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("defaultInstance = [[PersonAPIClient alloc] initWithBaseURL:[NSURL URLWithString:kBaseUrl]];");
_builder.newLine();
_builder.append("\t");
_builder.append("});");
_builder.newLine();
_builder.append("\t");
_builder.append("return defaultInstance;");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("- (instancetype)initWithBaseURL:(NSURL *)url");
_builder.newLine();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("self = [super initWithBaseURL:url];");
_builder.newLine();
_builder.append("\t");
_builder.append("if (self) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializer];");
_builder.newLine();
_builder.append("\t\t");
_builder.append("responseSerializer.readingOptions = NSJSONReadingAllowFragments;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("self.responseSerializer = responseSerializer;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("self.requestSerializer = [AFJSONRequestSerializer serializer];");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("return self;");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("@end");
_builder.newLine();
this.isGeneratedModuleFileFromModel(_builder, "Person", this.simplePersonEntity);
}
use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.
the class EntityDataAccessGeneratorGeneratingDataAccessCodeForEntitiesDataAccessCodeSpec method _implementationFile.
/**
* @filter('''|.isGenerated.*)
*/
@Test
@Named("Implementation file")
@Order(2)
public void _implementationFile() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("#import \"Person+DataAccess.h\"");
_builder.newLine();
_builder.append("#import \"PersonAPIClient.h\"");
_builder.newLine();
_builder.append("#import \"Person+DataMapping.h\"");
_builder.newLine();
_builder.newLine();
_builder.append("@implementation Person (DataAccess)");
_builder.newLine();
_builder.newLine();
_builder.append("static NSString *const kAllPersonsPath = @\"/persons\";");
_builder.newLine();
_builder.newLine();
_builder.append("+ (void)allPersons:(void (^)(NSArray *persons, NSError *error))block");
_builder.newLine();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("[[PersonAPIClient sharedClient] GET:kAllPersonsPath parameters:nil success:^(NSURLSessionDataTask *task, id responseObject)");
_builder.newLine();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("NSArray *elementsFromJSON = responseObject;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("NSMutableArray *result = [[NSMutableArray alloc] initWithCapacity:[elementsFromJSON count]];");
_builder.newLine();
_builder.append("\t\t");
_builder.append("for (NSDictionary *attributes in elementsFromJSON) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("Person *mappedElement = [[Person alloc] initWithAttributes:attributes];");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("[result addObject:mappedElement];");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block([result copy], nil);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("} failure:^(NSURLSessionDataTask *task, NSError *error)");
_builder.newLine();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if (block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block(@[], error);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}];");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("static NSString *const kCreatePath = @\"/persons\";");
_builder.newLine();
_builder.newLine();
_builder.append("- (void)create:(void (^)(Person *person, NSError *error))block");
_builder.newLine();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("NSDictionary *elementDictionary = [self attributes];");
_builder.newLine();
_builder.append("\t");
_builder.append("[[PersonAPIClient sharedClient] POST:kCreatePath parameters:elementDictionary success:^(NSURLSessionDataTask *task, id responseObject)");
_builder.newLine();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Person *postedElement = responseObject;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block(postedElement, nil);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("} failure:^(NSURLSessionDataTask *task, NSError *error)");
_builder.newLine();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block(nil, error);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}];");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("static NSString *const kUpdatePath = @\"/persons\";");
_builder.newLine();
_builder.newLine();
_builder.append("- (void)update:(void (^)(Person *person, NSError *error))block");
_builder.newLine();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("NSDictionary *elementDictionary = [self attributes];");
_builder.newLine();
_builder.append("\t");
_builder.append("[[PersonAPIClient sharedClient] PUT:kUpdatePath parameters:elementDictionary success:^(NSURLSessionDataTask *task, id responseObject)");
_builder.newLine();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("Person *postedElement = responseObject;");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block(postedElement, nil);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("} failure:^(NSURLSessionDataTask *task, NSError *error)");
_builder.newLine();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block(nil, error);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}];");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("static NSString *const kRemovePath = @\"/persons/%@\";");
_builder.newLine();
_builder.newLine();
_builder.append("- (void)remove:(void (^)(Person *person, NSError *error))block");
_builder.newLine();
_builder.append("{");
_builder.newLine();
_builder.append("\t");
_builder.append("NSString *urlString = [NSString stringWithFormat:kRemovePath, self.id];");
_builder.newLine();
_builder.append("\t");
_builder.append("[[PersonAPIClient sharedClient] DELETE:urlString parameters:nil success:^(NSURLSessionDataTask *task, id responseObject)");
_builder.newLine();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block(self, nil);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("} failure:^(NSURLSessionDataTask *task, NSError *error)");
_builder.newLine();
_builder.append("\t");
_builder.append("{");
_builder.newLine();
_builder.append("\t\t");
_builder.append("if(block) {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("block(nil, error);");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}];");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.newLine();
_builder.append("@end");
_builder.newLine();
this.isGeneratedModuleFileFromModel(_builder, "PersonDataSource", this.simpleDataSource);
}
use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.
the class InfoPlistStringsGeneratorPlistStringsFileSpec method _plistStringsFile.
/**
* @filter('''|.isGenerated.*)
*/
@Test
@Named("Plist Strings file")
@Order(1)
public void _plistStringsFile() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("/* Localized versions of Info.plist keys */");
_builder.newLine();
this.isGeneratedModuleFile(_builder);
}
use of org.eclipse.xtend2.lib.StringConcatenation in project applause by applause.
the class MainClassGeneratorMainClassSpec method _implementationFile.
/**
* @filter('''|.isGenerated.*)
*/
@Test
@Named("Implementation file")
@Order(1)
public void _implementationFile() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("#import <UIKit/UIKit.h>");
_builder.newLine();
_builder.newLine();
_builder.append("#import \"AppDelegate.h\"");
_builder.newLine();
_builder.newLine();
_builder.append("int main(int argc, char * argv[])");
_builder.newLine();
_builder.append("{");
_builder.newLine();
_builder.append(" ");
_builder.append("@autoreleasepool {");
_builder.newLine();
_builder.append(" ");
_builder.append("return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
this.isGeneratedModuleFile(_builder);
}
Aggregations