use of org.contextmapper.dsl.generator.mdsl.ProtectedRegionContext in project context-mapper-dsl by ContextMapper.
the class ProtectedRegionContextFactoryTest method canCreateContext4ExistingFileWithoutProtectedSections.
@Test
public void canCreateContext4ExistingFileWithoutProtectedSections() throws IOException {
// given
ProtectedRegionContextFactory factory = new ProtectedRegionContextFactory();
File expectedResultFile = new File(Paths.get("").toAbsolutePath().toString(), "/integ-test-files/mdsl/protected-region-null-test.mdsl");
String mdslInputFile = FileUtils.readFileToString(expectedResultFile);
// when
ProtectedRegionContext context = factory.createProtectedRegionContextForExistingMDSLFile(mdslInputFile);
// then
assertNull(context.getProtectedDataTypeRegion());
assertNull(context.getProtectedEndpointRegion());
assertNull(context.getProtectedProviderRegion());
assertNull(context.getProtectedClientRegion());
assertEquals(0, context.getDataTypeIdentifiers().size());
assertEquals(0, context.getEndpointIdentifiers().size());
assertEquals(0, context.getProviderIdentifiers().size());
assertEquals(0, context.getClientIdentifiers().size());
}
use of org.contextmapper.dsl.generator.mdsl.ProtectedRegionContext in project context-mapper-dsl by ContextMapper.
the class ProtectedRegionContextFactoryTest method canCreateContext4NewMDSLFile.
@Test
public void canCreateContext4NewMDSLFile() {
// given
ProtectedRegionContextFactory factory = new ProtectedRegionContextFactory();
// when
ProtectedRegionContext context = factory.createProtectedRegionContextForNewMDSLFile();
// then
assertEquals("", context.getProtectedDataTypeRegion());
assertEquals("", context.getProtectedEndpointRegion());
assertEquals("", context.getProtectedProviderRegion());
assertEquals("", context.getProtectedClientRegion());
assertEquals(0, context.getDataTypeIdentifiers().size());
assertEquals(0, context.getEndpointIdentifiers().size());
assertEquals(0, context.getProviderIdentifiers().size());
assertEquals(0, context.getClientIdentifiers().size());
}
use of org.contextmapper.dsl.generator.mdsl.ProtectedRegionContext in project context-mapper-dsl by ContextMapper.
the class MDSLContractsGenerator method generateFromContextMappingModel.
@Override
protected void generateFromContextMappingModel(ContextMappingModel model, IFileSystemAccess2 fsa, URI inputFileURI) {
MDSLModelCreator mdslModelCreator = new MDSLModelCreator(model);
for (ServiceSpecification serviceSpecification : mdslModelCreator.createServiceSpecifications()) {
String mdslFileName = inputFileURI.trimFileExtension().lastSegment() + "_" + serviceSpecification.getName() + "." + MDSL_FILE_EXT;
ProtectedRegionContext protectedRegionContext = createProtectedRegionContext(mdslFileName, fsa);
MDSLAPIDescriptionCreator dslCreator = new MDSLAPIDescriptionCreator(protectedRegionContext, inputFileURI.lastSegment());
fsa.generateFile(mdslFileName, dslCreator.createText(serviceSpecification));
}
}
use of org.contextmapper.dsl.generator.mdsl.ProtectedRegionContext in project context-mapper-dsl by ContextMapper.
the class ProtectedRegionContextFactoryTest method canCreateContext4ExistingFile.
@Test
public void canCreateContext4ExistingFile() throws IOException {
// given
ProtectedRegionContextFactory factory = new ProtectedRegionContextFactory();
File expectedResultFile = new File(Paths.get("").toAbsolutePath().toString(), "/integ-test-files/mdsl/protected-region-identifier-test.mdsl");
String mdslInputFile = FileUtils.readFileToString(expectedResultFile);
// when
ProtectedRegionContext context = factory.createProtectedRegionContextForExistingMDSLFile(mdslInputFile);
// then
assertEquals("data type Address P" + System.lineSeparator() + "data type Parameter1Type P", context.getProtectedDataTypeRegion());
assertEquals("endpoint type Customers" + System.lineSeparator() + " exposes" + System.lineSeparator() + " operation updateAddress" + System.lineSeparator() + " expecting" + System.lineSeparator() + " payload Address" + System.lineSeparator() + " delivering" + System.lineSeparator() + "" + " payload ReturnType" + System.lineSeparator() + " operation anotherMethod" + System.lineSeparator() + " expecting" + System.lineSeparator() + " payload anotherMethodParameter", context.getProtectedEndpointRegion());
assertEquals("API provider CustomerManagementContextProvider" + System.lineSeparator() + " offers Customers" + System.lineSeparator() + " at endpoint location \"http://localhost:8000\"" + System.lineSeparator() + " via protocol \"RESTful HTTP\"", context.getProtectedProviderRegion());
assertEquals("API client ContractManagementContextClient" + System.lineSeparator() + " consumes Customers", context.getProtectedClientRegion());
assertEquals(2, context.getDataTypeIdentifiers().size());
assertEquals(1, context.getEndpointIdentifiers().size());
assertEquals(1, context.getProviderIdentifiers().size());
assertEquals(1, context.getClientIdentifiers().size());
}
Aggregations