Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

177 api vervollständigen für erstellen einer org #178

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package app.hopps.org.delegates;

import app.hopps.org.jpa.*;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.validation.Valid;

@ApplicationScoped
public class PersistOrganizationDelegate {

@Inject
OrganizationRepository organizationRepository;

@Inject
MemberRespository memberRepository;

@Inject
BommelRepository bommelRepository;

@Transactional
public void persistOrg(@Valid Organization organization, @Valid Member owner) {
memberRepository.persist(owner);
organizationRepository.persist(organization);

Bommel rootBommel = new Bommel();
rootBommel.setName(organization.getName());
rootBommel.setParent(null);
rootBommel.setOrganization(organization);
rootBommel.setEmoji(Bommel.DEFAULT_ROOT_BOMMEL_EMOJI);
rootBommel.setResponsibleMember(owner);

bommelRepository.persist(rootBommel);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ with children_query as (
""")
})
public class Bommel extends PanacheEntity {
public static final String DEFAULT_ROOT_BOMMEL_EMOJI="\uD83C\uDF33"; // tree

private String name;
private String emoji;
Expand Down
66 changes: 42 additions & 24 deletions backend/app.hopps.org/src/main/resources/bpmn/NewOrganization.bpmn
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:bpsim="http://www.bpsim.org/schemas/1.0" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:drools="http://www.jboss.org/drools" xmlns:xsi="xsi" id="_SxOV0FA6ED2c8Z-Bgliozg" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd http://www.omg.org/spec/DD/20100524/DC DC.xsd http://www.omg.org/spec/DD/20100524/DI DI.xsd " exporter="jBPM Process Modeler" exporterVersion="2.0" targetNamespace="http://www.omg.org/bpmn20">
<bpmn2:definitions xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:bpsim="http://www.bpsim.org/schemas/1.0" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:drools="http://www.jboss.org/drools" xmlns:xsi="xsi" id="_xSRJIJe-ED2ocIyyHiENHw" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd http://www.jboss.org/drools drools.xsd http://www.bpsim.org/schemas/1.0 bpsim.xsd http://www.omg.org/spec/DD/20100524/DC DC.xsd http://www.omg.org/spec/DD/20100524/DI DI.xsd " exporter="jBPM Process Modeler" exporterVersion="2.0" targetNamespace="http://www.omg.org/bpmn20">
<bpmn2:itemDefinition id="_organizationItem" structureRef="app.hopps.org.jpa.Organization"/>
<bpmn2:itemDefinition id="_ownerItem" structureRef="app.hopps.org.jpa.Member"/>
<bpmn2:itemDefinition id="_5C2FBE1C-64A6-4033-A830-7A9E1FA3BC0E_InMessageType" structureRef=""/>
Expand All @@ -10,6 +10,8 @@
<bpmn2:itemDefinition id="_A936BDBF-871F-4660-BA9F-1E6BCB301BF5_OutMessageType" structureRef=""/>
<bpmn2:itemDefinition id="_7990A710-11AA-44F2-888D-D2FE3B907C70_InMessageType" structureRef=""/>
<bpmn2:itemDefinition id="_7990A710-11AA-44F2-888D-D2FE3B907C70_OutMessageType" structureRef=""/>
<bpmn2:itemDefinition id="__7990A710-11AA-44F2-888D-D2FE3B907C70_organizationInputXItem" structureRef="app.hopps.org.jpa.Organization"/>
<bpmn2:itemDefinition id="__7990A710-11AA-44F2-888D-D2FE3B907C70_ownerInputXItem" structureRef="app.hopps.org.jpa.Member"/>
<bpmn2:itemDefinition id="_74549AA2-3408-4AA2-9036-93ACF44E8392_InMessageType" structureRef=""/>
<bpmn2:itemDefinition id="_74549AA2-3408-4AA2-9036-93ACF44E8392_OutMessageType" structureRef=""/>
<bpmn2:itemDefinition id="_E6BC1F20-7A5F-4B5E-8E6D-FAF88750FB0E_InMessageType" structureRef=""/>
Expand All @@ -18,6 +20,7 @@
<bpmn2:itemDefinition id="_DB0D419F-AB1A-46FD-8093-CD25A927EAA0_OutMessageType" structureRef=""/>
<bpmn2:itemDefinition id="__DB0D419F-AB1A-46FD-8093-CD25A927EAA0_organizationInputXItem" structureRef="app.hopps.org.jpa.Organization"/>
<bpmn2:itemDefinition id="__DB0D419F-AB1A-46FD-8093-CD25A927EAA0_ownerInputXItem" structureRef="app.hopps.org.jpa.Member"/>
<bpmn2:error id="app.hopps.org.validation.NonUniqueConstraintViolation" errorCode="app.hopps.org.validation.NonUniqueConstraintViolation"/>
<bpmn2:message id="_5C2FBE1C-64A6-4033-A830-7A9E1FA3BC0E_InMessage" itemRef="_5C2FBE1C-64A6-4033-A830-7A9E1FA3BC0E_InMessageType"/>
<bpmn2:message id="_5C2FBE1C-64A6-4033-A830-7A9E1FA3BC0E_OutMessage" itemRef="_5C2FBE1C-64A6-4033-A830-7A9E1FA3BC0E_OutMessageType"/>
<bpmn2:interface id="_5C2FBE1C-64A6-4033-A830-7A9E1FA3BC0E_ServiceInterface" name="app.hopps.org.delegates.CreationValidationDelegate" implementationRef="app.hopps.org.delegates.CreationValidationDelegate">
Expand All @@ -36,8 +39,8 @@
</bpmn2:interface>
<bpmn2:message id="_7990A710-11AA-44F2-888D-D2FE3B907C70_InMessage" itemRef="_7990A710-11AA-44F2-888D-D2FE3B907C70_InMessageType"/>
<bpmn2:message id="_7990A710-11AA-44F2-888D-D2FE3B907C70_OutMessage" itemRef="_7990A710-11AA-44F2-888D-D2FE3B907C70_OutMessageType"/>
<bpmn2:interface id="_7990A710-11AA-44F2-888D-D2FE3B907C70_ServiceInterface" name="app.hopps.org.delegates.NoopDelegate" implementationRef="app.hopps.org.delegates.NoopDelegate">
<bpmn2:operation id="_7990A710-11AA-44F2-888D-D2FE3B907C70_ServiceOperation" name="noop" implementationRef="noop">
<bpmn2:interface id="_7990A710-11AA-44F2-888D-D2FE3B907C70_ServiceInterface" name="app.hopps.org.delegates.PersistOrganizationDelegate" implementationRef="app.hopps.org.delegates.PersistOrganizationDelegate">
<bpmn2:operation id="_7990A710-11AA-44F2-888D-D2FE3B907C70_ServiceOperation" name="persistOrg" implementationRef="persistOrg">
<bpmn2:inMessageRef>_7990A710-11AA-44F2-888D-D2FE3B907C70_InMessage</bpmn2:inMessageRef>
<bpmn2:outMessageRef>_7990A710-11AA-44F2-888D-D2FE3B907C70_OutMessage</bpmn2:outMessageRef>
</bpmn2:operation>
Expand Down Expand Up @@ -66,9 +69,8 @@
<bpmn2:outMessageRef>_DB0D419F-AB1A-46FD-8093-CD25A927EAA0_OutMessage</bpmn2:outMessageRef>
</bpmn2:operation>
</bpmn2:interface>
<bpmn2:error id="app.hopps.org.validation.NonUniqueConstraintViolation" errorCode="app.hopps.org.validation.NonUniqueConstraintViolation"/>
<bpmn2:collaboration id="_B6DF5FDB-9B19-4B6F-928A-4DE01A655F13" name="Default Collaboration">
<bpmn2:participant id="_1F349A5C-D250-437B-8BC8-7C792E5DA7AE" name="Pool Participant" processRef="NewOrganization"/>
<bpmn2:collaboration id="_85337848-C5AF-4164-A2A3-62C68A8CE55C" name="Default Collaboration">
<bpmn2:participant id="_5ACFFB47-2852-47A4-ACFD-EBE697131203" name="Pool Participant" processRef="NewOrganization"/>
</bpmn2:collaboration>
<bpmn2:process id="NewOrganization" drools:packageName="app.hopps.org" drools:version="1.0" drools:adHoc="false" name="NewOrganization" isExecutable="true" processType="Public">
<bpmn2:extensionElements>
Expand All @@ -90,23 +92,23 @@
</drools:metaData>
</bpmn2:extensionElements>
</bpmn2:property>
<bpmn2:sequenceFlow id="_A7B5AA79-B3CC-4999-9489-46EBA6AF990B" sourceRef="_7B06B533-E6E5-4C47-82CA-3BAFD1F8B55F" targetRef="_B19031A2-932E-47C8-81AA-7AAE0FE4AD55"/>
<bpmn2:sequenceFlow id="_BAA6CB4D-FC5B-4453-94B8-64B9F6CE25AE" sourceRef="_B65D0829-BC5D-47A3-8708-D1F096BFEFB8" targetRef="_F78451E1-2919-4FF8-8439-026929CD8EA4"/>
<bpmn2:sequenceFlow id="_C66E29BE-E4FC-45F9-BC66-DDA7B964D0C2" sourceRef="_E6BC1F20-7A5F-4B5E-8E6D-FAF88750FB0E" targetRef="_B65D0829-BC5D-47A3-8708-D1F096BFEFB8"/>
<bpmn2:sequenceFlow id="_23D16123-FADC-4946-8230-180645C7FA16" sourceRef="_74549AA2-3408-4AA2-9036-93ACF44E8392" targetRef="_B65D0829-BC5D-47A3-8708-D1F096BFEFB8"/>
<bpmn2:sequenceFlow id="_F6C8F584-EA6B-4026-839F-67DAFA0877E3" sourceRef="_5A05E219-752D-417B-B82B-59FE3DBA7BC1" targetRef="_E6BC1F20-7A5F-4B5E-8E6D-FAF88750FB0E"/>
<bpmn2:sequenceFlow id="_C7D729AB-0DE5-40BA-8ED0-C2649EBCF884" sourceRef="_5A05E219-752D-417B-B82B-59FE3DBA7BC1" targetRef="_74549AA2-3408-4AA2-9036-93ACF44E8392">
<bpmn2:extensionElements>
<drools:metaData name="isAutoConnection.target">
<drools:metaValue><![CDATA[true]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
</bpmn2:sequenceFlow>
<bpmn2:sequenceFlow id="_F6C8F584-EA6B-4026-839F-67DAFA0877E3" sourceRef="_5A05E219-752D-417B-B82B-59FE3DBA7BC1" targetRef="_E6BC1F20-7A5F-4B5E-8E6D-FAF88750FB0E"/>
<bpmn2:sequenceFlow id="_574498AF-2A70-4024-A4B4-2ECA6360F02D" sourceRef="_7990A710-11AA-44F2-888D-D2FE3B907C70" targetRef="_5A05E219-752D-417B-B82B-59FE3DBA7BC1"/>
<bpmn2:sequenceFlow id="_0D059BE3-7B64-436C-8931-5C673605C578" sourceRef="_A936BDBF-871F-4660-BA9F-1E6BCB301BF5" targetRef="_7990A710-11AA-44F2-888D-D2FE3B907C70"/>
<bpmn2:sequenceFlow id="_B71B0E35-1727-4E64-B3BC-4CC2F3EA19D4" sourceRef="_DB0D419F-AB1A-46FD-8093-CD25A927EAA0" targetRef="_A936BDBF-871F-4660-BA9F-1E6BCB301BF5"/>
<bpmn2:sequenceFlow id="_D5CF1FD8-A964-4C91-8E25-EA9B40F43069" sourceRef="_5C2FBE1C-64A6-4033-A830-7A9E1FA3BC0E" targetRef="_DB0D419F-AB1A-46FD-8093-CD25A927EAA0"/>
<bpmn2:sequenceFlow id="_C208651A-A205-4106-9C62-5BD663671B72" sourceRef="_9485C8B1-CC61-46FB-A44C-F0829F620F01" targetRef="_5C2FBE1C-64A6-4033-A830-7A9E1FA3BC0E"/>
<bpmn2:sequenceFlow id="_A7B5AA79-B3CC-4999-9489-46EBA6AF990B" sourceRef="_7B06B533-E6E5-4C47-82CA-3BAFD1F8B55F" targetRef="_B19031A2-932E-47C8-81AA-7AAE0FE4AD55"/>
<bpmn2:endEvent id="_B19031A2-932E-47C8-81AA-7AAE0FE4AD55">
<bpmn2:incoming>_A7B5AA79-B3CC-4999-9489-46EBA6AF990B</bpmn2:incoming>
</bpmn2:endEvent>
Expand Down Expand Up @@ -168,17 +170,33 @@
</bpmn2:serviceTask>
<bpmn2:parallelGateway id="_5A05E219-752D-417B-B82B-59FE3DBA7BC1" gatewayDirection="Diverging">
<bpmn2:incoming>_574498AF-2A70-4024-A4B4-2ECA6360F02D</bpmn2:incoming>
<bpmn2:outgoing>_F6C8F584-EA6B-4026-839F-67DAFA0877E3</bpmn2:outgoing>
<bpmn2:outgoing>_C7D729AB-0DE5-40BA-8ED0-C2649EBCF884</bpmn2:outgoing>
<bpmn2:outgoing>_F6C8F584-EA6B-4026-839F-67DAFA0877E3</bpmn2:outgoing>
</bpmn2:parallelGateway>
<bpmn2:serviceTask id="_7990A710-11AA-44F2-888D-D2FE3B907C70" drools:serviceimplementation="Java" drools:serviceinterface="app.hopps.org.delegates.NoopDelegate" drools:serviceoperation="noop" name="Create JPA Entities" implementation="Java" operationRef="_7990A710-11AA-44F2-888D-D2FE3B907C70_ServiceOperation">
<bpmn2:serviceTask id="_7990A710-11AA-44F2-888D-D2FE3B907C70" drools:serviceimplementation="Java" drools:serviceinterface="app.hopps.org.delegates.PersistOrganizationDelegate" drools:serviceoperation="persistOrg" name="Create JPA Entities" implementation="Java" operationRef="_7990A710-11AA-44F2-888D-D2FE3B907C70_ServiceOperation">
<bpmn2:extensionElements>
<drools:metaData name="elementname">
<drools:metaValue><![CDATA[Create JPA Entities]]></drools:metaValue>
</drools:metaData>
</bpmn2:extensionElements>
<bpmn2:incoming>_0D059BE3-7B64-436C-8931-5C673605C578</bpmn2:incoming>
<bpmn2:outgoing>_574498AF-2A70-4024-A4B4-2ECA6360F02D</bpmn2:outgoing>
<bpmn2:ioSpecification>
<bpmn2:dataInput id="_7990A710-11AA-44F2-888D-D2FE3B907C70_organizationInputX" drools:dtype="app.hopps.org.jpa.Organization" itemSubjectRef="__7990A710-11AA-44F2-888D-D2FE3B907C70_organizationInputXItem" name="organization"/>
<bpmn2:dataInput id="_7990A710-11AA-44F2-888D-D2FE3B907C70_ownerInputX" drools:dtype="app.hopps.org.jpa.Member" itemSubjectRef="__7990A710-11AA-44F2-888D-D2FE3B907C70_ownerInputXItem" name="owner"/>
<bpmn2:inputSet>
<bpmn2:dataInputRefs>_7990A710-11AA-44F2-888D-D2FE3B907C70_organizationInputX</bpmn2:dataInputRefs>
<bpmn2:dataInputRefs>_7990A710-11AA-44F2-888D-D2FE3B907C70_ownerInputX</bpmn2:dataInputRefs>
</bpmn2:inputSet>
</bpmn2:ioSpecification>
<bpmn2:dataInputAssociation>
<bpmn2:sourceRef>organization</bpmn2:sourceRef>
<bpmn2:targetRef>_7990A710-11AA-44F2-888D-D2FE3B907C70_organizationInputX</bpmn2:targetRef>
</bpmn2:dataInputAssociation>
<bpmn2:dataInputAssociation>
<bpmn2:sourceRef>owner</bpmn2:sourceRef>
<bpmn2:targetRef>_7990A710-11AA-44F2-888D-D2FE3B907C70_ownerInputX</bpmn2:targetRef>
</bpmn2:dataInputAssociation>
</bpmn2:serviceTask>
<bpmn2:serviceTask id="_A936BDBF-871F-4660-BA9F-1E6BCB301BF5" drools:serviceimplementation="Java" drools:serviceinterface="app.hopps.org.delegates.NoopDelegate" drools:serviceoperation="noop" name="Create User in Keycloak" implementation="Java" operationRef="_A936BDBF-871F-4660-BA9F-1E6BCB301BF5_ServiceOperation">
<bpmn2:extensionElements>
Expand Down Expand Up @@ -229,6 +247,9 @@
</bpmn2:process>
<bpmndi:BPMNDiagram>
<bpmndi:BPMNPlane bpmnElement="NewOrganization">
<bpmndi:BPMNShape id="shape__7B06B533-E6E5-4C47-82CA-3BAFD1F8B55F" bpmnElement="_7B06B533-E6E5-4C47-82CA-3BAFD1F8B55F">
<dc:Bounds height="56" width="56" x="701.7846153846153" y="268"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape__9485C8B1-CC61-46FB-A44C-F0829F620F01" bpmnElement="_9485C8B1-CC61-46FB-A44C-F0829F620F01">
<dc:Bounds height="56" width="56" x="521" y="217"/>
</bpmndi:BPMNShape>
Expand Down Expand Up @@ -259,12 +280,14 @@
<bpmndi:BPMNShape id="shape__DB0D419F-AB1A-46FD-8093-CD25A927EAA0" bpmnElement="_DB0D419F-AB1A-46FD-8093-CD25A927EAA0">
<dc:Bounds height="102" width="154" x="881" y="194"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape__7B06B533-E6E5-4C47-82CA-3BAFD1F8B55F" bpmnElement="_7B06B533-E6E5-4C47-82CA-3BAFD1F8B55F">
<dc:Bounds height="56" width="56" x="701.7846153846153" y="268"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="shape__B19031A2-932E-47C8-81AA-7AAE0FE4AD55" bpmnElement="_B19031A2-932E-47C8-81AA-7AAE0FE4AD55">
<dc:Bounds height="56" width="56" x="816" y="441"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="edge_shape__7B06B533-E6E5-4C47-82CA-3BAFD1F8B55F_to_shape__B19031A2-932E-47C8-81AA-7AAE0FE4AD55" bpmnElement="_A7B5AA79-B3CC-4999-9489-46EBA6AF990B">
<di:waypoint x="729.7846153846153" y="296"/>
<di:waypoint x="729.7846153846153" y="469"/>
<di:waypoint x="844" y="469"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge_shape__9485C8B1-CC61-46FB-A44C-F0829F620F01_to_shape__5C2FBE1C-64A6-4033-A830-7A9E1FA3BC0E" bpmnElement="_C208651A-A205-4106-9C62-5BD663671B72">
<di:waypoint x="549" y="245"/>
<di:waypoint x="729" y="245"/>
Expand All @@ -285,15 +308,15 @@
<di:waypoint x="1493" y="245"/>
<di:waypoint x="1575" y="245"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge_shape__5A05E219-752D-417B-B82B-59FE3DBA7BC1_to_shape__E6BC1F20-7A5F-4B5E-8E6D-FAF88750FB0E" bpmnElement="_F6C8F584-EA6B-4026-839F-67DAFA0877E3">
<di:waypoint x="1603" y="245"/>
<di:waypoint x="1726" y="245"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge_shape__5A05E219-752D-417B-B82B-59FE3DBA7BC1_to_shape__74549AA2-3408-4AA2-9036-93ACF44E8392" bpmnElement="_C7D729AB-0DE5-40BA-8ED0-C2649EBCF884">
<di:waypoint x="1603" y="245"/>
<di:waypoint x="1603" y="401"/>
<di:waypoint x="1754" y="350"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge_shape__5A05E219-752D-417B-B82B-59FE3DBA7BC1_to_shape__E6BC1F20-7A5F-4B5E-8E6D-FAF88750FB0E" bpmnElement="_F6C8F584-EA6B-4026-839F-67DAFA0877E3">
<di:waypoint x="1603" y="245"/>
<di:waypoint x="1726" y="245"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge_shape__74549AA2-3408-4AA2-9036-93ACF44E8392_to_shape__B65D0829-BC5D-47A3-8708-D1F096BFEFB8" bpmnElement="_23D16123-FADC-4946-8230-180645C7FA16">
<di:waypoint x="1803" y="401"/>
<di:waypoint x="1988" y="400.9999999999889"/>
Expand All @@ -307,11 +330,6 @@
<di:waypoint x="2016" y="245"/>
<di:waypoint x="2096" y="245"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="edge_shape__7B06B533-E6E5-4C47-82CA-3BAFD1F8B55F_to_shape__B19031A2-932E-47C8-81AA-7AAE0FE4AD55" bpmnElement="_A7B5AA79-B3CC-4999-9489-46EBA6AF990B">
<di:waypoint x="729.7846153846153" y="296"/>
<di:waypoint x="729.7846153846153" y="469"/>
<di:waypoint x="844" y="469"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmn2:relationship type="BPSimData">
Expand Down Expand Up @@ -449,7 +467,7 @@
</bpsim:Scenario>
</bpsim:BPSimData>
</bpmn2:extensionElements>
<bpmn2:source>_SxOV0FA6ED2c8Z-Bgliozg</bpmn2:source>
<bpmn2:target>_SxOV0FA6ED2c8Z-Bgliozg</bpmn2:target>
<bpmn2:source>_xSRJIJe-ED2ocIyyHiENHw</bpmn2:source>
<bpmn2:target>_xSRJIJe-ED2ocIyyHiENHw</bpmn2:target>
</bpmn2:relationship>
</bpmn2:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.validation.ConstraintViolationException;
import org.flywaydb.core.Flyway;
import org.hamcrest.core.IsInstanceOf;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -23,7 +24,7 @@
import static org.junit.jupiter.api.Assertions.assertThrows;

@QuarkusTest
public class CreationValidationDelegateTests {
class CreationValidationDelegateTests {

@Inject
CreationValidationDelegate delegate;
Expand All @@ -32,13 +33,12 @@ public class CreationValidationDelegateTests {
OrganizationRepository organizationRepository;

@Inject
MemberRespository memberRespository;
Flyway flyway;

@BeforeEach
@Transactional
void setUp() {
organizationRepository.deleteAll();
memberRespository.deleteAll();
public void cleanDatabase() {
flyway.clean();
flyway.migrate();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package app.hopps.org.delegates;

import app.hopps.org.jpa.*;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.collection.IsIterableWithSize.iterableWithSize;

@QuarkusTest
public class PersistOrganizationDelegateTests {
d135-1r43 marked this conversation as resolved.
Show resolved Hide resolved

@Inject
PersistOrganizationDelegate persistOrganizationDelegate;

@Inject
BommelRepository bommelRepository;

@Inject
OrganizationRepository organizationRepository;

@Inject
MemberRespository memberRepository;

@BeforeEach
@Transactional
void cleanupDB()
{
bommelRepository.deleteAll();
organizationRepository.deleteAll();
memberRepository.deleteAll();
}

@Test
void shouldCreateRootBommel()
{
// given
Organization kegelclub = new Organization();
kegelclub.setName("Kegelklub 777");
kegelclub.setType(Organization.TYPE.EINGETRAGENER_VEREIN);
kegelclub.setSlug("kegelklub-777");

Member kevin = new Member();
kevin.setFirstName("Kevin");
kevin.setLastName("Kegelkönig");
kevin.setEmail("[email protected]");

// when
persistOrganizationDelegate.persistOrg(kegelclub, kevin);

// then
assertThat(organizationRepository.listAll(), iterableWithSize(1));
assertThat(bommelRepository.listAll(), iterableWithSize(1));
assertThat(bommelRepository.listAll(), hasItem(hasProperty("emoji", equalTo("\uD83C\uDF33"))));
}
}
Loading
Loading