-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26b68f1
commit 68115ee
Showing
17 changed files
with
178 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
openbas-api/src/main/java/io/openbas/rest/mapper/export/MapperExportMixins.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package io.openbas.rest.mapper.export; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIncludeProperties; | ||
|
||
public class MapperExportMixins { | ||
|
||
private MapperExportMixins() { | ||
|
||
} | ||
|
||
@JsonIncludeProperties(value = { | ||
"import_mapper_name", | ||
"import_mapper_inject_type_column", | ||
"import_mapper_inject_importers", | ||
}) | ||
public static class ImportMapper { | ||
} | ||
|
||
@JsonIncludeProperties(value = { | ||
"inject_importer_type_value", | ||
"inject_importer_injector_contract", | ||
"inject_importer_rule_attributes", | ||
}) | ||
public static class InjectImporter { | ||
} | ||
|
||
@JsonIncludeProperties(value = { | ||
"rule_attribute_columns", | ||
"rule_attribute_name", | ||
"rule_attribute_default_value", | ||
"rule_attribute_additional_config", | ||
}) | ||
public static class RuleAttribute { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
openbas-api/src/test/java/io/openbas/service/MapperServiceExportTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.openbas.service; | ||
|
||
import io.openbas.IntegrationTest; | ||
import io.openbas.database.model.ImportMapper; | ||
import io.openbas.database.repository.ImportMapperRepository; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class MapperServiceExportTest extends IntegrationTest { | ||
|
||
@Autowired | ||
private ImportMapperRepository importMapperRepository; | ||
|
||
@Autowired | ||
private MapperService mapperService; | ||
|
||
@DisplayName("Test exporting a mapper") | ||
@Test | ||
void exportMapper() throws Exception { | ||
// -- PREPARE -- | ||
ImportMapper mapper = new ImportMapper(); | ||
mapper.setName("Test Mapper"); | ||
mapper.setInjectTypeColumn("injectType"); | ||
mapper.setInjectImporters(new ArrayList<>()); | ||
ImportMapper mapperSaved = this.importMapperRepository.save(mapper); | ||
|
||
// -- EXECUTE -- | ||
String json = this.mapperService.exportMappers(List.of(mapperSaved.getId())); | ||
|
||
// -- ASSERT -- | ||
assertEquals("[{" | ||
+ "\"import_mapper_name\":\"Test Mapper\"," | ||
+ "\"import_mapper_inject_type_column\":\"injectType\"," | ||
+ "\"import_mapper_inject_importers\":[]" | ||
+ "}]", json); | ||
|
||
// -- CLEAN -- | ||
this.importMapperRepository.delete(mapperSaved); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.