Skip to content
Snippets Groups Projects
Commit ef9493f2 authored by Gregor Schulz's avatar Gregor Schulz
Browse files

cleanup

parent 78612f3b
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ const APP_FILES_BASE_URL = 'https://gemeinschaftswerk-nachhaltigkeit.de/app/api/
export class QueryEvent {
constructor(
private readonly jasdEventGateway: FetchesJasdActivity,
private readonly jasdApi: FetchesJasdActivity,
private readonly logger: Logs,
) {}
......@@ -23,10 +23,8 @@ export class QueryEvent {
this.logger.debug(`Executing QueryEvent use case with input: ${JSON.stringify(input)}`)
const startTime = Date.now()
//https://gemeinschaftswerk-nachhaltigkeit.de/app/api/v2/activities/1234
//https://gemeinschaftswerk-nachhaltigkeit.de/app/api/v1/activities/1234
try {
const jasdActivity = await this.jasdEventGateway.fetchActivity(
const jasdActivity = await this.jasdApi.fetchActivity(
input.id,
)
......@@ -41,6 +39,7 @@ export class QueryEvent {
}
}
//todo montagsgregor: move to gateway as its duplicated
private toDomainEvent(activity: Activity): HoliEvent {
return {
id: activity.id.toString(),
......
import { assertEquals } from '@std/assert'
import { describe, it } from '@std/testing/bdd'
import { returnsNext, stub } from '@std/testing/mock'
import { QueryEvents } from './QueryEvents.ts'
import { AppApiEvent } from '../adapters/jasd/types/appapi.dto.types.ts'
import { LocalTimedEvent } from '../adapters/jasd/tests/fixtures.ts'
export type ResponsePayload = Record<string, unknown> | Error
export const fakeFetch = (response: ResponsePayload) => {
return stub(
globalThis,
'fetch',
returnsNext([Promise.resolve(new Response(JSON.stringify(response)))]),
)
}
describe('QueryEvents', () => {
const geoApiAMock = {
resolveCityName() {
......@@ -43,124 +35,7 @@ describe('QueryEvents', () => {
const jasdGatewayMock = {
fetchEvents(): Promise<{ events: AppApiEvent[]; totalCount: number }> {
return Promise.resolve({
events: [{
'name': 'RealTimedEvent',
'description':
'<p>Jeden Dienstag (bis auf eine Sommer- und Winterpause) zeigt der Verein Allerweltskino e.V. im Kölner Filmtheater Off Broadway einen Nachhaltigkeitsfilm. Das Programm ist im Internet abrufbar (siehe Kasten rechts).</p>',
'resultType': 'ACTIVITY',
'activity': {
'id': 4610,
'name': 'RealTimedEvent',
'description':
'<p>Jeden Dienstag (bis auf eine Sommer- und Winterpause) zeigt der Verein Allerweltskino e.V. im Kölner Filmtheater Off Broadway einen Nachhaltigkeitsfilm. Das Programm ist im Internet abrufbar (siehe Kasten rechts).</p>',
'sustainableDevelopmentGoals': [
4,
17,
],
'impactArea': 'LOCAL',
'contact': {
'lastName': 'Flock',
'firstName': 'Dardin',
'position': '',
'email': 'somedude@ontheinternets.de',
'phone': '',
'image': null,
},
'location': {
'address': {
'name': 'Off Broadway Filmtheater',
'street': 'Bahnhofstr.',
'streetNo': '41',
'supplement': 'Hinterhof',
'zipCode': '50674',
'city': 'Köln',
'state': 'Nordrhein-Westfalen',
'country': null,
},
'online': false,
'privateLocation': false,
'url': 'https://www.allerweltskino.de',
'coordinate': {
'type': 'Point',
'coordinates': [
50.9296771,
6.93787246,
],
},
},
'thematicFocus': [
'SUSTAINABLE_BUILDING',
'INTERNATIONAL_RESPONSIBILITY',
'GENDER_EQUITY',
'URBAN_DEVELOPMENT',
'SUSTAINABLE_BUSINESS',
'SUSTAINABLE_FINANCE',
'CULTURAL_SOCIAL_CHANGE',
'AGRICULTURE',
'BIODIVERSITY',
'SUSTAINABLE_LIFESTYLE',
'MOBILITY',
'HUMAN_RIGHTS',
'TOURISM',
'SOCIAL_JUSTICE',
'PARTICIPATION',
'PEACE',
'SUSTAINABLE_GOVERNANCE',
'CIRCULAR_ECONOMY',
'CLIMATE_PROTECTION',
],
'activityType': 'EVENT',
'externalId': null,
'registerUrl': 'https://www.allerweltskino.de',
'approvedUntil': null,
'period': {
'permanent': false,
'start': '2025-03-26T00:00:00+01:00',
'end': '2025-03-26T00:00:00+01:00',
},
'logo': '1f32e2bd-0557-408b-a4aa-90f264e8034e.png',
'image': 'activities/act5.jpg',
'socialMediaContacts': [
{
'type': 'INSTAGRAM',
'contact': 'https://www.instagram.com/allerweltskino',
},
{
'type': 'FACEBOOK',
'contact': 'https://www.facebook.com/pages/Allerweltskino/',
},
],
'bannerImageMode': 'cover',
'organisation': {
'id': 1809,
'name': 'Allerweltskino e.V.',
'logo': null,
'image': 'a41d2e24-6aee-4462-88e4-96bfb2c5e56e.png',
},
},
'location': {
'address': {
'name': 'Off Broadway Filmtheater',
'street': 'Bahnhofstr.',
'streetNo': '41',
'supplement': 'Hinterhof',
'zipCode': '50674',
'city': 'Köln',
'state': 'Nordrhein-Westfalen',
'country': null,
},
'online': false,
'privateLocation': false,
'url': 'https://www.allerweltskino.de',
'coordinate': {
'type': 'Point',
'coordinates': [
50.9296771,
6.93787246,
],
},
},
}],
events: [LocalTimedEvent as AppApiEvent],
totalCount: 1,
})
},
......
......@@ -20,7 +20,7 @@ const APP_FILES_BASE_URL = 'https://gemeinschaftswerk-nachhaltigkeit.de/app/api/
export class QueryEvents {
constructor(
private readonly jasdEventGateway: FetchesJasdEvents,
private readonly jasdApi: FetchesJasdEvents,
private readonly geoApi: ResolvesCity,
private readonly logger: Logs,
) {}
......@@ -32,7 +32,7 @@ export class QueryEvents {
try {
const location = input.geolocationId ? await this.geoApi.resolveCityName(input.geolocationId) : undefined
const jasdEvents = await this.jasdEventGateway.fetchEvents(
const jasdEvents = await this.jasdApi.fetchEvents(
input.limit,
input.offset,
input.localOnly,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment